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

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

Open
matrixbot opened this issue Jul 14, 2015 · 5 comments
Labels
A-Spec-Compliance places where synapse does not conform to the spec good first issue Good for newcomers O-Uncommon Most users are unlikely to come across this or unexpected workflow S-Tolerable Minor significance, cosmetic issues, low or no impact to users. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues.

Comments

@matrixbot
Copy link
Member

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)

@matrixbot
Copy link
Member Author

Jira watchers: @leonerd

@matrixbot matrixbot changed the title M_UNAUTHORIZED if 'Authorization' header value contains optional whitespace (SYN-437) M_UNAUTHORIZED if 'Authorization' header value contains optional whitespace (https://github.com/matrix-org/synapse/issues/1350) Nov 7, 2016
@matrixbot matrixbot changed the title M_UNAUTHORIZED if 'Authorization' header value contains optional whitespace (https://github.com/matrix-org/synapse/issues/1350) M_UNAUTHORIZED if 'Authorization' header value contains optional whitespace (SYN-437) Nov 7, 2016
@richvdh richvdh changed the title M_UNAUTHORIZED if 'Authorization' header value contains optional whitespace (SYN-437) M_UNAUTHORIZED if 'Authorization' header value contains optional whitespace for federation requests (SYN-437) Aug 2, 2021
@reivilibre reivilibre added S-Major Major functionality / product severely impaired, no satisfactory workaround. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues. labels Aug 3, 2021
@DMRobertson DMRobertson added A-Spec-Compliance places where synapse does not conform to the spec S-Tolerable Minor significance, cosmetic issues, low or no impact to users. O-Uncommon Most users are unlikely to come across this or unexpected workflow and removed S-Major Major functionality / product severely impaired, no satisfactory workaround. labels Sep 6, 2022
@DMRobertson
Copy link
Contributor

The relevant function is

def _parse_auth_header(header_bytes: bytes) -> Tuple[str, str, str, Optional[str]]:

We'd accept a PR which

  • adds test cases which demonstrate the failure here
  • changes _parse_auth_header to fix those test cases.

@DMRobertson DMRobertson added the good first issue Good for newcomers label Sep 6, 2022
@devender15
Copy link

@DMRobertson Hello, I want to work on this issue. Please assign this issue to me.

@DMRobertson
Copy link
Contributor

@DMRobertson Hello, I want to work on this issue. Please assign this issue to me.

We don't assign issues outside of the core team, but we will gladly review a PR.

@haxshith
Copy link

iam a newbie to this.I am very enthusiastic to learn please help me out

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Spec-Compliance places where synapse does not conform to the spec good first issue Good for newcomers O-Uncommon Most users are unlikely to come across this or unexpected workflow 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

No branches or pull requests

5 participants