Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Internal server error when looking up a invalid room alias #13104

Closed
DMRobertson opened this issue Jun 18, 2022 · 2 comments · Fixed by #13106
Closed

Internal server error when looking up a invalid room alias #13104

DMRobertson opened this issue Jun 18, 2022 · 2 comments · Fixed by #13106
Labels
good first issue Good for newcomers P4 (OBSOLETE: use S- labels.) Okay backlog: will not schedule, will accept patches S-Tolerable Minor significance, cosmetic issues, low or no impact to users. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues.

Comments

@DMRobertson
Copy link
Contributor

https://sentry.tools.element.io/organizations/element/issues/923/?project=2&query=is%3Aunresolved

ValueError: At least one of the arguments destination and destination_is must be a nonempty bytestring.
  File "synapse/http/server.py", line 366, in _async_render_wrapper
    callback_return = await self._async_render(request)
  File "synapse/http/server.py", line 572, in _async_render
    callback_return = await raw_callback_return
  File "synapse/rest/client/directory.py", line 57, in on_GET
    res = await self.directory_handler.get_association(room_alias_obj)
  File "synapse/handlers/directory.py", line 262, in get_association
    fed_result: Optional[JsonDict] = await self.federation.make_query(
  File "synapse/federation/federation_client.py", line 183, in make_query
    return await self.transport_layer.make_query(
  File "synapse/federation/transport/client.py", line 260, in make_query
    return await self.client.get_json(
  File "synapse/http/matrixfederationclient.py", line 1069, in get_json
    response = await self._send_request_with_optional_trailing_slash(
  File "synapse/http/matrixfederationclient.py", line 405, in _send_request_with_optional_trailing_slash
    response = await self._send_request(request, **send_request_args)
  File "synapse/http/matrixfederationclient.py", line 555, in _send_request
    auth_headers = self.build_auth_headers(
  File "synapse/http/matrixfederationclient.py", line 735, in build_auth_headers
    raise ValueError(

This came from a GET request for url: /_matrix/client/r0/directory/room/%23Computer-security%3A, .

That's an invalid room alias because it doesn't contain a domain name. Very similar to #12690, then.

@DMRobertson DMRobertson added S-Tolerable Minor significance, cosmetic issues, low or no impact to users. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues. labels Jun 18, 2022
@DMRobertson
Copy link
Contributor Author

To fix:

  • There are three calls to RoomAlias.from_string in synapse.rest.client.directory.
  • These should only be called if RoomAlias.is_valid confirms that the given alias is valid.
  • If not, raise a SynapseError. Consult the CS spec to see what HTTP status code and what matrix error code is appropriate.

@DMRobertson DMRobertson added good first issue Good for newcomers P4 (OBSOLETE: use S- labels.) Okay backlog: will not schedule, will accept patches labels Jun 18, 2022
@santhoshivan23
Copy link
Contributor

@DMRobertson I'll work on this!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Good for newcomers P4 (OBSOLETE: use S- labels.) Okay backlog: will not schedule, will accept patches S-Tolerable Minor significance, cosmetic issues, low or no impact to users. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants