Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appservice Can't set alias #2009

Open
nkitsaini opened this issue Sep 16, 2021 · 2 comments
Open

Appservice Can't set alias #2009

nkitsaini opened this issue Sep 16, 2021 · 2 comments
Labels
C-App-Services T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues.

Comments

@nkitsaini
Copy link

nkitsaini commented Sep 16, 2021

Same as #661 which is closed but I can still reproduce the issue.

Background information

  • dendrite v0.5
  • Monolith
  • Sqlite3
  • In Docker

Description

Appservice can't set alias in it's own namespace.
Request fails with error message: Alias is reserved by an application service

Steps to reproduce

  • Start Dendrite with a appservice
  • Try to set alias using appservice

Logs

Can't find anything relevant in debug logs.

@kegsay
Copy link
Member

kegsay commented Jan 21, 2022

× AS can make room aliases

In sytest, which is probably why this isn't possible.

@nkitsaini
Copy link
Author

nkitsaini commented Feb 3, 2022

I went through the code and found some relevant stuff (I might be wrong as not familiar with go)

When the Room is created

  • We don't check if the alias is exclusive.
  • Anyone can use exclusive Alias
    if roomAlias != "" {
    aliasReq := roomserverAPI.SetRoomAliasRequest{
    Alias: roomAlias,
    RoomID: roomID,
    UserID: userID,
    }
    var aliasResp roomserverAPI.SetRoomAliasResponse
    err = rsAPI.SetRoomAlias(req.Context(), &aliasReq, &aliasResp)
    if err != nil {

While there's a request to set alias after room is created:

  • We only check if alias is exclusive.
  • Even the Appservice having exclusive access cannot set the alias
    // Check that the alias does not fall within an exclusive namespace of an
    // application service
    for _, appservice := range cfg.Derived.ApplicationServices {
    if userNamespaces, ok := appservice.NamespaceMap["users"]; ok {
    for _, namespace := range userNamespaces {
    if namespace.Exclusive && namespace.RegexpObject.MatchString(alias) {
    return util.JSONResponse{
    Code: http.StatusBadRequest,
    JSON: jsonerror.ASExclusive("Alias is reserved by an application service"),
    }
    }
    }
    }
    }

Psuedo Code for fix:

alias_owner = getExclusiveOwner(alias)
if alias_owner == None:
      proceed and create the alias
else:
      if alias_owner != appservice_who_sent_the_request:
           return AliasIsExclusive() # shouldn't create alias
      else:
           proceed and create the alias

(Similar thing should be confirmed for other namespaces, namely user and room_id

@kegsay kegsay added T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues. and removed bug labels Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-App-Services T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues.
Projects
None yet
Development

No branches or pull requests

2 participants