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

createRoom fails with a 500 error if a badly-formatted mxid is in the invitees list #4088

Closed
richvdh opened this issue Oct 25, 2018 · 4 comments
Labels
z-bug (Deprecated Label) z-p2 (Deprecated Label)

Comments

@richvdh
Copy link
Member

richvdh commented Oct 25, 2018

For example, if you pass an MXID which has a trailing space.

See #4032 (comment) for a stacktrace.

@f35f0ef9d0e827dae86552d3899f78fc
Copy link
Contributor

f35f0ef9d0e827dae86552d3899f78fc commented Sep 23, 2019

Reading through linked conversations, looks like parse_and_validate_server_name function could be expanded and used.

@werner291
Copy link
Contributor

werner291 commented Sep 26, 2019

image

Still occurs in recent versions.

This happened after creating a room and "@werner291:matrix.org " (notice the trailing space) to my homeserver. (Using the "invite" option on room creation.)

I'll continue chasing this tomorrow.

@werner291
Copy link
Contributor

A stack trace:

Sep 26 23:43:40 nixos synapse[18978]: synapse.http.server: [POST-144] Failed handle request via 'RoomCreateRestServlet': <XForwardedForRequest at 0x7fc8444a8410 method='POST' uri='/_matrix/client/r0/createRoom' clientproto='HTTP/1.0' site=8008>
                                      Traceback (most recent call last):
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
                                          result = result.throwExceptionIntoGenerator(g)
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
                                          return g.throw(self.type, self.value, self.tb)
                                      StopIteration: []
                                      
                                      During handling of the above exception, another exception occurred:
                                      
                                      Traceback (most recent call last):
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
                                          result = g.send(result)
                                      StopIteration: _RoutingResult(host_header=b'matrix.org ', tls_server_name=b'matrix.org ', target_host=b'matrix.org ', target_port=8448)
                                      
                                      During handling of the above exception, another exception occurred:
                                      
                                      Traceback (most recent call last):
                                        File "/nix/store/02my60ip60g2vw2rhvynz79iihvs5v1i-matrix-synapse-1.3.1/lib/python3.7/site-packages/synapse/http/matrixfederationclient.py", line 424, in _send_request
                                          response = yield request_deferred
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
                                          result = g.send(result)
                                        File "/nix/store/02my60ip60g2vw2rhvynz79iihvs5v1i-matrix-synapse-1.3.1/lib/python3.7/site-packages/synapse/http/federation/matrix_federation_agent.py", line 126, in request
                                          res.tls_server_name.decode("ascii")
                                        File "/nix/store/02my60ip60g2vw2rhvynz79iihvs5v1i-matrix-synapse-1.3.1/lib/python3.7/site-packages/synapse/crypto/context_factory.py", line 132, in get_options
                                          return SSLClientConnectionCreator(host, ssl_context, should_verify)
                                        File "/nix/store/02my60ip60g2vw2rhvynz79iihvs5v1i-matrix-synapse-1.3.1/lib/python3.7/site-packages/synapse/crypto/context_factory.py", line 167, in __init__
                                          self._verifier = ConnectionVerifier(hostname, verify_certs)
                                        File "/nix/store/02my60ip60g2vw2rhvynz79iihvs5v1i-matrix-synapse-1.3.1/lib/python3.7/site-packages/synapse/crypto/context_factory.py", line 205, in __init__
                                          self._hostnameBytes = idna.encode(hostname)
                                        File "/nix/store/4ai7zwqa04ilzk0x4jxmqzqig39ikjjs-python3.7-idna-2.8/lib/python3.7/site-packages/idna/core.py", line 358, in encode
                                          s = alabel(label)
                                        File "/nix/store/4ai7zwqa04ilzk0x4jxmqzqig39ikjjs-python3.7-idna-2.8/lib/python3.7/site-packages/idna/core.py", line 270, in alabel
                                          ulabel(label)
                                        File "/nix/store/4ai7zwqa04ilzk0x4jxmqzqig39ikjjs-python3.7-idna-2.8/lib/python3.7/site-packages/idna/core.py", line 304, in ulabel
                                          check_label(label)
                                        File "/nix/store/4ai7zwqa04ilzk0x4jxmqzqig39ikjjs-python3.7-idna-2.8/lib/python3.7/site-packages/idna/core.py", line 261, in check_label
                                          raise InvalidCodepoint('Codepoint {0} at position {1} of {2} not allowed'.format(_unot(cp_value), pos+1, repr(label)))
                                      idna.core.InvalidCodepoint: Codepoint U+0020 at position 4 of 'org ' not allowed
                                      
                                      The above exception was the direct cause of the following exception:
                                      
                                      Traceback (most recent call last):
                                        File "/nix/store/02my60ip60g2vw2rhvynz79iihvs5v1i-matrix-synapse-1.3.1/lib/python3.7/site-packages/synapse/http/server.py", line 76, in wrapped_request_handler
                                          await h(self, request)
                                        File "/nix/store/02my60ip60g2vw2rhvynz79iihvs5v1i-matrix-synapse-1.3.1/lib/python3.7/site-packages/synapse/http/server.py", line 315, in _async_render
                                          callback_return = await callback_return
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
                                          result = result.throwExceptionIntoGenerator(g)
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
                                          return g.throw(self.type, self.value, self.tb)
                                        File "/nix/store/02my60ip60g2vw2rhvynz79iihvs5v1i-matrix-synapse-1.3.1/lib/python3.7/site-packages/synapse/rest/client/v1/room.py", line 91, in on_POST
                                          requester, self.get_room_config(request)
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
                                          result = result.throwExceptionIntoGenerator(g)
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
                                          return g.throw(self.type, self.value, self.tb)
                                        File "/nix/store/02my60ip60g2vw2rhvynz79iihvs5v1i-matrix-synapse-1.3.1/lib/python3.7/site-packages/synapse/handlers/room.py", line 651, in create_room
                                          content=content,
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
                                          result = result.throwExceptionIntoGenerator(g)
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
                                          return g.throw(self.type, self.value, self.tb)
                                        File "/nix/store/02my60ip60g2vw2rhvynz79iihvs5v1i-matrix-synapse-1.3.1/lib/python3.7/site-packages/synapse/handlers/room_member.py", line 302, in update_membership
                                          require_consent=require_consent,
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
                                          result = result.throwExceptionIntoGenerator(g)
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
                                          return g.throw(self.type, self.value, self.tb)
                                        File "/nix/store/02my60ip60g2vw2rhvynz79iihvs5v1i-matrix-synapse-1.3.1/lib/python3.7/site-packages/synapse/handlers/room_member.py", line 508, in _update_membership
                                          require_consent=require_consent,
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
                                          result = result.throwExceptionIntoGenerator(g)
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
                                          return g.throw(self.type, self.value, self.tb)
                                        File "/nix/store/02my60ip60g2vw2rhvynz79iihvs5v1i-matrix-synapse-1.3.1/lib/python3.7/site-packages/synapse/handlers/room_member.py", line 196, in _local_membership_update
                                          requester, event, context, extra_users=[target], ratelimit=ratelimit
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
                                          result = result.throwExceptionIntoGenerator(g)
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
                                          return g.throw(self.type, self.value, self.tb)
                                        File "/nix/store/02my60ip60g2vw2rhvynz79iihvs5v1i-matrix-synapse-1.3.1/lib/python3.7/site-packages/synapse/util/metrics.py", line 69, in measured_func
                                          r = yield func(self, *args, **kwargs)
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
                                          result = result.throwExceptionIntoGenerator(g)
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
                                          return g.throw(self.type, self.value, self.tb)
                                        File "/nix/store/02my60ip60g2vw2rhvynz79iihvs5v1i-matrix-synapse-1.3.1/lib/python3.7/site-packages/synapse/handlers/message.py", line 705, in handle_new_client_event
                                          requester, event, context, ratelimit=ratelimit, extra_users=extra_users
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
                                          result = result.throwExceptionIntoGenerator(g)
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
                                          return g.throw(self.type, self.value, self.tb)
                                        File "/nix/store/02my60ip60g2vw2rhvynz79iihvs5v1i-matrix-synapse-1.3.1/lib/python3.7/site-packages/synapse/handlers/message.py", line 783, in persist_and_notify_client_event
                                          invitee.domain, event
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
                                          result = result.throwExceptionIntoGenerator(g)
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
                                          return g.throw(self.type, self.value, self.tb)
                                        File "/nix/store/02my60ip60g2vw2rhvynz79iihvs5v1i-matrix-synapse-1.3.1/lib/python3.7/site-packages/synapse/handlers/federation.py", line 1085, in send_invite
                                          pdu=event,
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
                                          result = result.throwExceptionIntoGenerator(g)
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
                                          return g.throw(self.type, self.value, self.tb)
                                        File "/nix/store/02my60ip60g2vw2rhvynz79iihvs5v1i-matrix-synapse-1.3.1/lib/python3.7/site-packages/synapse/federation/federation_client.py", line 742, in send_invite
                                          content = yield self._do_send_invite(destination, pdu, room_version)
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
                                          result = result.throwExceptionIntoGenerator(g)
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
                                          return g.throw(self.type, self.value, self.tb)
                                        File "/nix/store/02my60ip60g2vw2rhvynz79iihvs5v1i-matrix-synapse-1.3.1/lib/python3.7/site-packages/synapse/federation/federation_client.py", line 783, in _do_send_invite
                                          "invite_room_state": pdu.unsigned.get("invite_room_state", []),
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
                                          result = result.throwExceptionIntoGenerator(g)
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
                                          return g.throw(self.type, self.value, self.tb)
                                        File "/nix/store/02my60ip60g2vw2rhvynz79iihvs5v1i-matrix-synapse-1.3.1/lib/python3.7/site-packages/synapse/federation/transport/client.py", line 314, in send_invite_v2
                                          destination=destination, path=path, data=content, ignore_backoff=True
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
                                          result = result.throwExceptionIntoGenerator(g)
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
                                          return g.throw(self.type, self.value, self.tb)
                                        File "/nix/store/02my60ip60g2vw2rhvynz79iihvs5v1i-matrix-synapse-1.3.1/lib/python3.7/site-packages/synapse/http/matrixfederationclient.py", line 640, in put_json
                                          timeout=timeout,
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
                                          result = result.throwExceptionIntoGenerator(g)
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
                                          return g.throw(self.type, self.value, self.tb)
                                        File "/nix/store/02my60ip60g2vw2rhvynz79iihvs5v1i-matrix-synapse-1.3.1/lib/python3.7/site-packages/synapse/http/matrixfederationclient.py", line 241, in _send_request_with_optional_trailing_slash
                                          response = yield self._send_request(request, **send_request_args)
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
                                          result = result.throwExceptionIntoGenerator(g)
                                        File "/nix/store/kv604h4xyjdcvnfqxzprfr3msg9i1dvh-python3.7-Twisted-18.9.0/lib/python3.7/site-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
                                          return g.throw(self.type, self.value, self.tb)
                                        File "/nix/store/02my60ip60g2vw2rhvynz79iihvs5v1i-matrix-synapse-1.3.1/lib/python3.7/site-packages/synapse/http/matrixfederationclient.py", line 429, in _send_request
                                          raise_from(RequestSendFailed(e, can_retry=True), e)
                                        File "<string>", line 3, in raise_from
                                      synapse.api.errors.RequestSendFailed: Failed to send request: InvalidCodepoint: Codepoint U+0020 at position 4 of 'org ' not allowed

@richvdh
Copy link
Member Author

richvdh commented Oct 10, 2019

hopefully fixed by #6121

@richvdh richvdh closed this as completed Oct 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
z-bug (Deprecated Label) z-p2 (Deprecated Label)
Projects
None yet
Development

No branches or pull requests

4 participants