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

Uncaught InvalidCodepoint exception in POST /register #470

Open
DMRobertson opened this issue Nov 18, 2021 · 0 comments
Open

Uncaught InvalidCodepoint exception in POST /register #470

DMRobertson opened this issue Nov 18, 2021 · 0 comments
Labels

Comments

@DMRobertson
Copy link
Contributor

DMRobertson commented Nov 18, 2021

https://sentry.matrix.org/sentry/sydent/issues/235984/events/eb7b2ee8efc645fd816bb38641c7e3a6/

StopIteration: _RoutingResult(host_header=b'https://chat.dev.glamster.io:443', tls_server_name=b'https://chat.dev.glamster.io', target_host=b'https://chat.dev.glamster.io', target_port=443)
  File "twisted/internet/defer.py", line 1661, in _inlineCallbacks
    result = current_context.run(gen.send, result)

InvalidCodepoint: Codepoint U+003A at position 6 of 'https://chat' not allowed
  File "sydent/http/servlets/__init__.py", line 184, in render
    result = await f(self, request)
  File "sydent/http/servlets/registerservlet.py", line 78, in render_POST
    1024 * 5,
  File "sydent/http/httpclient.py", line 60, in get_json
    uri.encode("utf8"),
  File "twisted/internet/defer.py", line 1661, in _inlineCallbacks
    result = current_context.run(gen.send, result)
  File "sydent/http/matrixfederationagent.py", line 164, in request
    routing.tls_server_name.decode("ascii")
  File "sydent/http/federation_tls_options.py", line 112, in get_options
    return ClientTLSOptions(host, self._options._makeContext())
  File "sydent/http/federation_tls_options.py", line 78, in __init__
    self._hostnameBytes = _idnaBytes(hostname)
  File "sydent/http/federation_tls_options.py", line 60, in _idnaBytes
    return idna.encode(text)
  File "idna/core.py", line 371, in encode
    s = alabel(label)
  File "idna/core.py", line 272, in alabel
    ulabel(label_bytes)
  File "idna/core.py", line 312, in ulabel
    check_label(label_bytes)
  File "idna/core.py", line 263, in check_label
    raise InvalidCodepoint('Codepoint {} at position {} of {} not allowed'.format(_unot(cp_value), pos+1, repr(label)))

idna.encode(text) might raise.

Encountered when someone tried to register with their host set to 'https://chat.dev.HOSTNAME.TLD. There shouldn't be a protocol; idna complained when it saw the colon.

Suggest catching idna.IDNAError in the call to get_options in matrixfederationagent.py, and doing something so that we return 400 BAD REQUEST.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant