matrix-org / matrix-org/matrix-spec

Federation request signing is easily broken by proxies

Open
#561 4 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

wart
Dominant language
HTML
Stars
330
Forks
150
Avg merge
2h 21m
Merged PRs (30d)
3

Description

I recently came across this issue with synapse: https://github.com/matrix-org/synapse/issues/3294#issuecomment-462199951

It basically comes down to how reverse-proxies in front of synapse handle things. So far, I checked the spec which doesn't really specify whenever or things have to be url-encoded or not, but all example url-encode strings.

So far one could make assumptions on this, but HTTP explicitly states that URL encoded URLs, should be decoded before using them and make no difference.

Characters other
than those in the "reserved" set are equivalent to their
percent-encoded octets: the normal form is to not encode them (see
Sections 2.1 and 2.2 of [RFC3986]).

For example, the following three URIs are equivalent:

 http://example.com:80/~smith/home.html
 http://EXAMPLE.com/%7Esmith/home.html
 http://EXAMPLE.com:/%7esmith/home.html

https://tools.ietf.org/html/rfc7230#section-2.7.3

When we use HTTP as a standard, we should make sure we don't contradict it. Therefore we should fix the examples and implementations in this perspective.

For some cases, where things might contain special characters, that interfere with the HTTP standard like / we might want to explicitly disallow them in the spec. Because if we don't do this, it'll cause harm to the protocol in the long term perspective (as it already does with various WAF solutions in front of Synapse, when they canonicalize URLs).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the linked Synapse issue and RFC 7230 section 2.7.3, then compare the specification's URL-encoding examples with its implementations. Done means the examples and implementations consistently define handling of encoded URLs and special characters so reverse proxies cannot change the signed request meaning.

Written by the indexing model from the issue text.

Assessment

Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.