matrix-org/synapse

M_UNAUTHORIZED if 'Authorization' header value contains optional whitespace for federation requests (SYN-437)

Ouverte

#1 350 ouverte le 14 juil. 2015

 (5 commentaires) (0 réaction) (0 personne assignée)Python (2 196 forks)batch import
A-Spec-ComplianceO-UncommonS-TolerableT-Defectgood first issue

Métriques du dépôt

Stars
 (11 713 étoiles)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

Description

It's a little unclear from the spec, but I believe the intention is that the federation Authorization header is supposed to follow RFC7235 format. To quote:

 Authorization = credentials

  credentials = auth-scheme [ 1*SP ( token68 / [ ( "," / auth-param )
    *( OWS "," [ OWS auth-param ] ) ] ) ]

The OWS parts in there suggest that "optional whitespace" is allowed between comma-separated auth-param components.

However, while synapse is happy with

Authorization: X-Matrix origin="localhost:33515",key="ed25519:1",sig="hNMLqNd1T+JUVc53JxpRUtV8uTeAFiz/H8ewf5BffPz4Pem3EiIOq7L06B3fNHmWrW+ZVBkdG1tGEU9Fyl+lAA"

it breaks with

Authorization: X-Matrix origin="localhost:48078", key="ed25519:1", sig="24xkXS8iJE9dCdU5j0GRym4eps+vzUYvYaPosjdjU/G2etNQGVc1erInpmjJJHlJoJu1GDb8H3JzXQga47oADg"

In the latter case, the resulting error message is:

400 Bad Request
{"errcode":"M_UNAUTHORIZED","error":"Malformed Authorization header"}

(Imported from https://matrix.org/jira/browse/SYN-437)

(Reported by @leonerd)

Guide contributeur