Bypass of redirect_uri validation with /../ in GitHub
The GitHub OAuth redirect_uri validation could be bypassed using path traversal sequences, and the get-token endpoint lacked redirect_uri validation, allowing an attacker to redirect users to an arbitrary domain. This could enable theft of OAuth tokens or other sensitive data.
Published on homakov.blogspot.hk
The original lives on homakov.blogspot.hk
We do not hold its text, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
What the report shows
The report is a short list of five issues found in GitHub's OAuth and Gist functionality, published under the title "How I hacked Github again". The author is Egor Homakov. The report does not name a bounty amount, a severity rating, a CVSS score or a fix, and it does not walk through reproduction steps for most of the items. What it does give is the specification text that each bug contradicts.

Bug 1: bypass of redirect_uri validation with /../
The first issue is a path traversal in the OAuth redirect_uri check. The report quotes GitHub's documented rule:
If provided, the redirect URL’s host and port must exactly match the callback URL. The redirect URL’s path must reference a subdirectory of the callback URL
The report does not describe how the subdirectory requirement was enforced. The report does not include the exact payload used, the application it was tested against, or the server response.
Bug 2: lack of redirect_uri validation on the get-token endpoint
The second issue is that the token exchange endpoint did not validate redirect_uri. The report quotes the parameter documentation:
redirect_uri|string| The URL in your app where users will be sent after authorization. See details below about redirect urls. |

In the OAuth authorisation code flow, the client sends the same redirect_uri back to the token endpoint that was used in the authorisation request, and the server is supposed to confirm the two match. If the token endpoint accepts an authorisation code together with an arbitrary redirect_uri, the binding between the code and the client's registered callback is weakened. The report states the lack of validation but does not show a request or a captured token.
Bugs 3 to 5: Gist issues
The remaining three items are listed by title only:
- Injecting cross domain image in a gist.
- Gist reveals github_token in cookies.
- Auto approval of 'scope' for Gist client.
No payloads, endpoints or responses accompany these. The third is listed by title only.
Outcome
The report ends with a section headed "Bounty" and an image, but gives no figure or programme detail in the text.

Root cause
Both are failures to enforce a binding that the OAuth specification requires.
Impact
The report does not demonstrate a token theft or analyse impact. The Gist items are listed without impact analysis.
How this kind of bug works
OAuth separates two checks. The authorisation endpoint decides whether the redirect_uri in the request is acceptable for the client, and the token endpoint confirms that the redirect_uri presented with the code matches the one used earlier. The first check protects against codes going to the wrong place; the second protects against a stolen code being redeemed by someone who supplies their own callback.
Both checks fail in predictable ways. Path comparison done on raw strings mishandles .., encoded dot segments, duplicate slashes, trailing slashes, case differences in the path, and host confusion through userinfo, subdomains or trailing dots. Token endpoint checks fail when the parameter is optional, when an omitted value is accepted, or when the comparison is skipped for confidential clients. The defence is to parse the URI, normalise it, and compare scheme, host, port and path exactly, and to store the redirect_uri with the code and require an exact match at exchange time.
How to test for it
- Register or find an OAuth client with a known callback path, for example a path under
/callback/. - At the authorisation endpoint, send a
redirect_urithat stays on the same host but escapes the registered directory using dot segments, then try encoded variants, doubled slashes and a trailing slash. - Watch whether the server redirects to the modified location with a
codeparameter, or rejects the request. - Take a valid code and call the token endpoint twice: once with the original
redirect_uri, once with a different one, once with the parameter omitted, and once with it empty. A successful exchange in any of the altered cases is a positive result. - Confirm the code is single use and short lived so that a success is not an artefact of replay.
Common false positives: the server redirecting to an error page on the same host, a client-side router accepting the path but the backend rejecting the code, or a test account whose client is configured to allow any callback. Always verify that a token is actually issued.
How it is fixed
Parse and normalise the redirect_uri before comparison, reject any path containing dot segments after decoding, and compare the full normalised URI against the registered value rather than a prefix. Bind the redirect_uri to the authorisation code server side and require an exact match at the token endpoint, treating a missing parameter as a mismatch unless the client registered exactly one callback. Require explicit consent for every scope and avoid wildcard subdomain matching in callback registration.
Hunting notes
OAuth implementations are a reliable source of this bug class because the specification is detailed and implementations cut corners. Look at mobile and CLI clients, which often register loopback or custom-scheme callbacks, and at older applications that predate stricter guidance. Recon signals include multiple redirect endpoints, a redirect_uri parameter echoed in error pages, and clients whose registered callback is a deep path. To make a report land, show the full flow: the crafted authorisation request, the redirect carrying the code, and the token response, with the victim account and the attacker account clearly separated. A demonstrated token theft is far stronger than a rejected or ambiguous redirect.
What happened, in plain words
This report is a short list of five problems found in GitHub's login and Gist features, published under the title "How I hacked Github again" by Egor Homakov. The report does not give a bounty amount, a severity rating, a CVSS score or a fix, and for most items it does not walk through the steps to reproduce them. What it does give is the official rule that each bug breaks.

To follow the first two bugs you need to know what OAuth is. OAuth is a way for one website (an "application") to ask another website (here, GitHub) to confirm who you are, without giving the application your password. You click "authorise", GitHub sends you back to the application with a short-lived code, and the application swaps that code for an access token. A token is like a temporary key: whoever holds it can act as you. The redirect_uri is the address GitHub sends you back to after you approve. If an attacker can make that address point at their own site, the code or token lands in their hands.
Bug 1: bypass of redirect_uri validation with /../
The first issue is a path traversal in the OAuth redirect_uri check. The report quotes GitHub's documented rule:
If provided, the redirect URL’s host and port must exactly match the callback URL. The redirect URL’s path must reference a subdirectory of the callback URL
In plain terms: the address you are sent back to must be on the same site (same host and port) and must sit inside the folder the application registered. The report does not say how the check was implemented. In a file path, .. means "go up one folder". The report does not include the exact payload used, the application it was tested against, or the server response.
Bug 2: lack of redirect_uri validation on the get-token endpoint
The second issue is that the endpoint that swaps the code for a token did not check redirect_uri. The report quotes the parameter documentation:
redirect_uri|string| The URL in your app where users will be sent after authorization. See details below about redirect urls. |

In the normal flow, the application sends the same redirect_uri back to the token endpoint that it used in the first request, and the server is supposed to confirm the two match. If the token endpoint accepts a code together with any redirect_uri, the link between the code and the application's registered address is weakened. The report states the lack of validation but does not show a request or a captured token.
Bugs 3 to 5: Gist issues
The remaining three items are listed by title only:
- Injecting cross domain image in a gist.
- Gist reveals github_token in cookies.
- Auto approval of 'scope' for Gist client.
No payloads, endpoints or responses accompany these. A cookie is a small piece of data a website stores in your browser and sends back with each request; if a cookie contains a token, anyone who can read it can act as you. The third is listed by title only.
Outcome
The report ends with a section headed "Bounty" and an image, but gives no figure or programme detail in the text.

In general, how this kind of bug works
OAuth separates two checks. The authorisation endpoint decides whether the redirect_uri in the request is acceptable for the application, and the token endpoint confirms that the redirect_uri presented with the code matches the one used earlier. The first check stops codes going to the wrong place; the second stops a stolen code being redeemed by someone who supplies their own callback.
Both checks fail in predictable ways. Path comparison done on raw text mishandles .., encoded dot segments, duplicate slashes, trailing slashes, case differences in the path, and host confusion through userinfo, subdomains or trailing dots. Token endpoint checks fail when the parameter is optional, when an omitted value is accepted, or when the comparison is skipped for confidential clients. The defence is to parse the URI, normalise it, and compare scheme, host, port and path exactly, and to store the redirect_uri with the code and require an exact match at exchange time.
How to test for it
- Register or find an OAuth client with a known callback path, for example a path under
/callback/. - At the authorisation endpoint, send a
redirect_urithat stays on the same host but escapes the registered directory using dot segments, then try encoded variants, doubled slashes and a trailing slash. - Watch whether the server redirects to the modified location with a
codeparameter, or rejects the request. - Take a valid code and call the token endpoint twice: once with the original
redirect_uri, once with a different one, once with the parameter omitted, and once with it empty. A successful exchange in any of the altered cases is a positive result. - Confirm the code is single use and short lived so that a success is not an artefact of replay.
Common false positives: the server redirecting to an error page on the same host, a client-side router accepting the path but the backend rejecting the code, or a test account whose client is configured to allow any callback. Always verify that a token is actually issued.
How it is fixed
Parse and normalise the redirect_uri before comparison, reject any path containing dot segments after decoding, and compare the full normalised URI against the registered value rather than a prefix. Bind the redirect_uri to the authorisation code server side and require an exact match at the token endpoint, treating a missing parameter as a mismatch unless the client registered exactly one callback. Require explicit consent for every scope and avoid wildcard subdomain matching in callback registration.
Hunting notes
OAuth implementations are a reliable source of this bug class because the specification is detailed and implementations cut corners. Look at mobile and CLI clients, which often register loopback or custom-scheme callbacks, and at older applications that predate stricter guidance. Recon signals include multiple redirect endpoints, a redirect_uri parameter echoed in error pages, and clients whose registered callback is a deep path. To make a report land, show the full flow: the crafted authorisation request, the redirect carrying the code, and the token response, with the victim account and the attacker account clearly separated. A demonstrated token theft is far stronger than a rejected or ambiguous redirect.
Glossary
- OAuth: a standard that lets an application get limited access to your account on another site without your password.
- redirect_uri: the address the authorisation server sends you back to after you approve an application.
- Access token: a temporary key that lets its holder act as the user who authorised it.
- Authorisation code: a short-lived code sent back to the application, which it swaps for an access token.
- Token endpoint: the server address where an application exchanges an authorisation code for an access token.
- Path traversal: using
..segments in a path to climb out of an intended folder. - Cookie: a small piece of data a website stores in your browser and sends back with each request.
- Scope: the list of permissions an application asks for.
- Host and port: the site name and the numbered channel used to reach it; together they identify where a request goes.
- Normalise: to clean up a value (for example, resolving
..and duplicate slashes) so that comparisons are reliable. - Subdirectory: a folder inside another folder.
- Gist: GitHub's feature for sharing short pieces of text or code.
- CVSS: a standard scoring system for the severity of a security flaw.