Open Redirect in Employer OAuth Flow via Backslash Validation Bypass
The client-side OAuth redirect handler on an Employer host validated the returnPath parameter with a string denylist that missed backslashes, so a value beginning with a slash and backslash caused the browser to navigate to a different origin. An attacker could craft a link on the trusted domain that sends a user to an external site, which could support phishing.
Published on medium.com
Bug Bounty
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
Employer is a web application with a client-side OAuth redirect handler. The application reads a returnPath query parameter on its OAuth redirect route and sends the browser to that path. The handler lives on the Australian host, au.employer.example.com, on the route /oauth/redirect, and the logic is shipped in the client bundle /static/oauth/main-ed5b7e9a5881f074f6af.js. The observed application version was 7729.
The application attempts to block external destinations. The application tries to enforce that by rejecting values that begin with // and values that look like an absolute URL with a scheme. The weakness described here is that this textual check does not account for backslashes, so a value beginning with /\ slips through and the browser resolves it to a different origin.
Setup
No account was needed. The redirect was reproduced in a fresh, unauthenticated browser profile, and no authenticated actions were performed. The destination was a locally hosted HTTPS test server on [redacted]:8443, configured to serve a simple HTML marker page at /probe and to log incoming requests. Because that server used a self-signed certificate, Chrome was launched with --ignore-certificate-errors for this controlled test only.
Only the Australian host was directly tested. Other regional hosts appeared in the client configuration, but their exposure was not verified.
Finding it
While reviewing the client-side OAuth redirect handling, the returnPath parameter stood out. The application attempted to block external destinations by inspecting the string rather than validating the destination after URL parsing. That gap between textual validation and browser URL parsing is where the issue sits.
Exploitation
Step 1: Understand the validation
The client-side query parser applies checks equivalent to:
returnPath.startsWith("//") ||/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\
Values matching either condition are replaced with /. Every other string is returned unchanged. So the parser rejects protocol-relative values and values that match a conventional scheme:// pattern, and passes everything else along.
Step 2: Understand the navigation sink
The redirect route takes the parsed returnPath and passes values beginning with / to a navigation function:
tV(0 === e.indexOf("/") ? e : window.location.origin);
That function calls:
tV = e => { window.location.assign(e);};
In other words, anything that starts with a forward slash is handed to window.location.assign, and anything else is replaced with the current origin. The incomplete validation and the browser's own URL parsing together produce the redirect.
Step 3: Craft the bypass
The proof-of-concept URL used during testing was:
https://au.employer.example.com/oauth/redirect?returnPath=/%5C127.0.0.1:8443/probe
After query-string decoding, the parameter begins with /\. That value does not match either rejection condition, so it reaches the navigation sink. For special URL schemes such as HTTPS, browsers treat backslashes as forward slashes in the relevant URL-parsing contexts, so the destination resolves to a different origin instead of staying on the Employer host.
Step 4: Reproduce with a local server
- Start a local HTTPS test server on
[redacted]:8443. - Configure it to serve a simple HTML marker page at
/probeand log incoming requests. - Open a fresh browser profile without signing in to Employer.
- Visit:
https://au.employer.example.com/oauth/redirect?returnPath=/%5C127.0.0.1:8443/probe
- Observe that the browser navigates to the local test origin and loads the marker page.
- Verify that the rendered DOM contains the marker text and that the local server logs a request for
/probe. - Compare with the control:
https://au.employer.example.com/oauth/redirect?returnPath=//[redacted]:8443/probe
In the recorded control test, the // variant remained on the application.
Step 5: Confirm the result
The successful test produced a marker page with the title:
example-OPEN-REDIRECT-POC-OK
Its body contained:
attacker-origin-loaded
The local server recorded requests for /probe and /favicon.ico. The dumped DOM contained the marker page rather than the application shell. The control test with the // prefix stayed on the application, which supports the conclusion that the backslash-based input bypassed the validation applied to that form.
Root cause
The validation is a string denylist. It checks the textual form of the input, rejecting // prefixes and scheme:// patterns, but it never parses the candidate URL and compares the resolved origin with the current origin. The navigation sink then trusts any value that starts with / and passes it to window.location.assign. Because browsers treat backslashes as forward slashes for special schemes such as HTTPS, a value beginning with /\ resolves to a different origin even though it does not look like one to the validator. The check and the consumer disagree about what the string means, and the browser's interpretation wins.
Impact
The demonstrated impact is external-origin navigation: a crafted link on the trusted Employer domain sends the browser to another origin. In a phishing scenario this could make a malicious destination appear more credible, because the initial link uses the legitimate Employer domain.
The following were not demonstrated: credential capture or theft, session theft or account takeover, OAuth authorization-code or access-token disclosure, and vulnerability on other regional Employer hosts. No credentials, customer data or OAuth tokens were collected, and no authenticated actions were performed. The severity depends on the program's assessment of the redirect behaviour and its practical impact.
Fix
The recommendation is to stop relying on a string denylist and instead parse the candidate URL and compare its origin with the current origin explicitly:
function getSafeReturnPath(returnPath) { try { const destination = new URL( returnPath, window.location.origin );
if (destination.origin !== window.location.origin) { return "/"; } return ( destination.pathname + destination.search + destination.hash ); } catch { return "/"; }}
Additional recommendations from the report:
- Prefer an allowlist of valid internal paths when practical.
- Reject or normalise backslashes and control characters before processing return paths.
- Apply consistent validation across relevant login, logout and OAuth return flows.
- Add regression tests for protocol-relative URLs, backslash-based inputs, encoded characters and malformed destinations.
The goal is to validate the final resolved destination, not just the original string.
Variants to test
- Encoded backslash in other positions. Try values such as
/%5C%5C127.0.0.1:8443/probeor/foo/%5C127.0.0.1:8443/probe. A positive result is the browser leaving the application origin and loading a marker page from the test server. - Mixed slash and backslash prefixes. Try
\/[redacted]:8443/probeand/%5C/[redacted]:8443/probe. A positive result is navigation to the external origin despite the value not matching the//orscheme://checks. - Other return-path parameters. Look for the same pattern in login, logout and OAuth callback routes, for example parameters named
returnUrl,redirect,nextorcontinue. A positive result is the same external navigation from a route that uses the same client-side validation. - ** A positive result is the same marker page loading from the test server on a host that was not part of the original test.
- Post-authentication behaviour. A positive result is external navigation from an authenticated session, which would raise the practical impact.
- ** A positive result is the backslash form navigating away while the
//form stays on the application, which isolates the bypass from a general redirect.
What happened, in plain words
A security researcher was looking at a website called Employer, which is a web application. A web application is a program you use through your browser, like an online shop or a job portal. Employer has an OAuth redirect feature that reads a returnPath value and sends the browser to that path. This is called an OAuth redirect, and OAuth is a common way for websites to let you sign in with an account you already have, or to let one site ask another site for permission on your behalf.
The redirect feature works by reading a value from the address bar, a parameter called returnPath. A parameter is a small piece of information attached to a web address, usually after a question mark, that tells the website what you want. For example, in https://shop.example.com/search?q=shoes, the parameter is q and its value is shoes. Here, returnPath is supposed to hold an internal page path, so the site can send you back there.
The problem is that the site tried to block dangerous values by looking at the text of the value, not by actually working out where the browser would end up. The researcher found that a value beginning with a backslash, \, slipped past the check. When the browser processed that value, it treated the backslash like a forward slash and went to a completely different website. This kind of bug is called an open redirect: a trusted site can be made to send visitors somewhere else.
The researcher proved it by running a small test server on their own computer and showing that the browser really did leave Employer and load a page from that test server. They did not steal any passwords, tokens or data, and they did not test every regional version of the site. The demonstrated impact is only that the browser can be sent to another origin. An origin is the combination of protocol, host and port that identifies where a web page comes from, for example https://au.employer.example.com.
The feature and where it lives
Employer is a web application with a client-side OAuth redirect handler. Client-side means the code runs in your browser rather than on the server. The application reads a returnPath query parameter and sends the browser to that path.
The handler lives on the Australian host, au.employer.example.com, on the route /oauth/redirect. A host is the part of a web address that names the machine serving the site, and a route is the path part that tells the site which page or action you want. The logic is shipped in the client bundle /static/oauth/main-ed5b7e9a5881f074f6af.js. A client bundle is a file of JavaScript, the programming language browsers run, that the site sends to your browser so the page can do things without asking the server every time. The observed application version was 7729.
The application attempts to block external destinations. The application tries to enforce that by rejecting values that begin with // and values that look like an absolute URL with a scheme. A scheme is the first part of a web address, like https or http, that says how to talk to the destination. The weakness described here is that this textual check does not account for backslashes, so a value beginning with /\ slips through and the browser resolves it to a different origin.
Setting up the test
No account was needed. The redirect was reproduced in a fresh, unauthenticated browser profile, and no authenticated actions were performed. A browser profile is the folder where a browser keeps your history, settings and logins; a fresh profile behaves like a brand new computer with nothing remembered. Unauthenticated means not signed in.
The destination was a locally hosted HTTPS test server on [redacted]:8443, configured to serve a simple HTML marker page at /probe and to log incoming requests. A local server is a small program running on your own computer that acts like a website. [redacted] is the address your computer uses to refer to itself, and 8443 is a port, a numbered doorway on a machine that a service listens on. HTTPS is the encrypted version of the web protocol. A marker page is a page whose only job is to be recognisable, so you can tell it loaded.
Because that server used a self-signed certificate, Chrome was launched with --ignore-certificate-errors for this controlled test only. A certificate is what proves a website is who it claims to be; a self-signed one is made by the server itself rather than a trusted authority, so browsers warn about it. The flag tells Chrome to skip that warning for this test.
Only the Australian host was directly tested. Other regional hosts appeared in the client configuration, but their exposure was not verified.
Finding it
While reviewing the client-side OAuth redirect handling, the returnPath parameter stood out. The application attempted to block external destinations by inspecting the string rather than validating the destination after URL parsing. That gap between textual validation and browser URL parsing is where the issue sits. URL parsing is the process of taking a web address and breaking it into its parts, such as scheme, host and path, so you can reason about where it really leads.
Step 1: Understand the validation
The client-side query parser applies checks equivalent to:
returnPath.startsWith("//") ||/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\
Line by line:
returnPath.startsWith("//")asks whether the value begins with two forward slashes. A value like//evil.example.comwould match, because that is how a browser writes a protocol-relative address, meaning one that borrows the current page's scheme.||means "or". If the first check is true, the whole expression is true./^[a-zA-Z][a-zA-Z\d+\-.]*:\/\is a regular expression, a pattern for matching text.^means the start of the string.[a-zA-Z]means one letter.[a-zA-Z\d+\-.]*means any number of letters, digits, plus signs, hyphens or dots.:is a literal colon.\/\is a forward slash followed by a backslash. So this part looks for something likehttps:/\at the start.
Values matching either condition are replaced with /. Every other string is returned unchanged. So the parser rejects protocol-relative values and values that match a conventional scheme:// pattern, and passes everything else along.
Step 2: Understand the navigation sink
The redirect route takes the parsed returnPath and passes values beginning with / to a navigation function:
tV(0 === e.indexOf("/") ? e : window.location.origin);
Line by line:
eis the value ofreturnPath.e.indexOf("/")finds the position of the first forward slash. If it is0, the value starts with a slash.0 === ... ? e : window.location.originis a conditional: if the value starts with a slash, use the value itself; otherwise use the current origin.tV(...)calls the navigation function with whichever value was chosen.
That function calls:
tV = e => { window.location.assign(e);};
Line by line:
tV = e => { ... }defines a function namedtVthat takes one argument,e.window.location.assign(e)tells the browser to navigate to the address ine.
In other words, anything that starts with a forward slash is handed to window.location.assign, and anything else is replaced with the current origin. The incomplete validation and the browser's own URL parsing together produce the redirect.
Step 3: Craft the bypass
The proof-of-concept URL used during testing was:
https://au.employer.example.com/oauth/redirect?returnPath=/%5C127.0.0.1:8443/probe
Line by line:
https://au.employer.example.comis the trusted Employer host./oauth/redirectis the route that handles the redirect.?returnPath=starts the parameter./%5C127.0.0.1:8443/probeis the value.%5Cis the URL encoding of a backslash, so after decoding the value begins with/\.
After query-string decoding, the parameter begins with /\. That value does not match either rejection condition, so it reaches the navigation sink. For special URL schemes such as HTTPS, browsers treat backslashes as forward slashes in the relevant URL-parsing contexts, so the destination resolves to a different origin instead of staying on the Employer host.
Step 4: Reproduce with a local server
- Start a local HTTPS test server on
[redacted]:8443. - Configure it to serve a simple HTML marker page at
/probeand log incoming requests. - Open a fresh browser profile without signing in to Employer.
- Visit:
https://au.employer.example.com/oauth/redirect?returnPath=/%5C127.0.0.1:8443/probe
- Observe that the browser navigates to the local test origin and loads the marker page.
- Verify that the rendered DOM contains the marker text and that the local server logs a request for
/probe. The DOM is the browser's in-memory model of the page, which you can inspect with developer tools. - Compare with the control:
https://au.employer.example.com/oauth/redirect?returnPath=//[redacted]:8443/probe
In the recorded control test, the // variant remained on the application. A control is a comparison case that should behave normally, so you can tell whether the unusual case really is unusual.
Step 5: Confirm the result
The successful test produced a marker page with the title:
example-OPEN-REDIRECT-POC-OK
Its body contained:
attacker-origin-loaded
The local server recorded requests for /probe and /favicon.ico. A favicon is the little icon browsers request for a tab. The dumped DOM contained the marker page rather than the application shell. The control test with the // prefix stayed on the application, which supports the conclusion that the backslash-based input bypassed the validation applied to that form.
Root cause
The validation is a string denylist. A denylist is a list of things you refuse; the opposite, an allowlist, is a list of things you permit. It checks the textual form of the input, rejecting // prefixes and scheme:// patterns, but it never parses the candidate URL and compares the resolved origin with the current origin. The navigation sink then trusts any value that starts with / and passes it to window.location.assign. Because browsers treat backslashes as forward slashes for special schemes such as HTTPS, a value beginning with /\ resolves to a different origin even though it does not look like one to the validator. The check and the consumer disagree about what the string means, and the browser's interpretation wins.
Impact
The demonstrated impact is external-origin navigation: a crafted link on the trusted Employer domain sends the browser to another origin. In a phishing scenario this could make a malicious destination appear more credible, because the initial link uses the legitimate Employer domain. Phishing is tricking someone into trusting a link or page that is not what it claims to be.
The following were not demonstrated: credential capture or theft, session theft or account takeover, OAuth authorization-code or access-token disclosure, and vulnerability on other regional Employer hosts. A session is the period you stay signed in, usually tracked by a cookie, a small piece of data the browser stores and sends back. A token is a string that proves you are allowed to do something. No credentials, customer data or OAuth tokens were collected, and no authenticated actions were performed. The severity depends on the program's assessment of the redirect behaviour and its practical impact.
Fix
The recommendation is to stop relying on a string denylist and instead parse the candidate URL and compare its origin with the current origin explicitly:
function getSafeReturnPath(returnPath) { try { const destination = new URL( returnPath, window.location.origin );
if (destination.origin !== window.location.origin) { return "/"; } return ( destination.pathname + destination.search + destination.hash ); } catch { return "/"; }}
Line by line:
function getSafeReturnPath(returnPath) {defines a function that takes the value.try {starts a block where errors are caught.const destination = new URL(returnPath, window.location.origin);builds a full URL object, using the current origin as the base if the value is relative.if (destination.origin !== window.location.origin) { return "/"; }checks whether the resolved origin differs from the current one; if so, it returns the safe root path.return destination.pathname + destination.search + destination.hash;otherwise returns the path, query and fragment parts, which stay on the same origin.} catch { return "/"; }returns the safe root if parsing fails.
Additional recommendations from the report:
- Prefer an allowlist of valid internal paths when practical.
- Reject or normalise backslashes and control characters before processing return paths.
- Apply consistent validation across relevant login, logout and OAuth return flows.
- Add regression tests for protocol-relative URLs, backslash-based inputs, encoded characters and malformed destinations. A regression test is a test that makes sure a fixed bug stays fixed.
The goal is to validate the final resolved destination, not just the original string.
Variants to test
- Encoded backslash in other positions. Try values such as
/%5C%5C127.0.0.1:8443/probeor/foo/%5C127.0.0.1:8443/probe. A positive result is the browser leaving the application origin and loading a marker page from the test server. - Mixed slash and backslash prefixes. Try
\/[redacted]:8443/probeand/%5C/[redacted]:8443/probe. A positive result is navigation to the external origin despite the value not matching the//orscheme://checks. - Other return-path parameters. Look for the same pattern in login, logout and OAuth callback routes, for example parameters named
returnUrl,redirect,nextorcontinue. A positive result is the same external navigation from a route that uses the same client-side validation. - ** A positive result is the same marker page loading from the test server on a host that was not part of the original test.
- Post-authentication behaviour. A positive result is external navigation from an authenticated session, which would raise the practical impact.
- ** A positive result is the backslash form navigating away while the
//form stays on the application, which isolates the bypass from a general redirect.
Glossary
- Web application: a program you use through your browser, served by a remote computer.
- OAuth: a standard way for websites to let you sign in or grant access using an account you already have, without sharing your password.
- Parameter: a named value attached to a web address, usually after a question mark.
- Open redirect: a bug where a trusted site can be made to send visitors to another site.
- Origin: the combination of scheme, host and port that identifies where a web page comes from.
- Client-side: code that runs in your browser rather than on the server.
- Host: the part of a web address that names the machine serving the site.
- Route: the path part of a web address that tells the site which page or action you want.
- Client bundle: a file of JavaScript sent to your browser so the page can work without asking the server every time.
- Scheme: the first part of a web address, like
https, that says how to talk to the destination. - Browser profile: the folder where a browser keeps your history, settings and logins.
- Unauthenticated: not signed in.
- Local server: a small program on your own computer that acts like a website.
- Port: a numbered doorway on a machine that a service listens on.
- HTTPS: the encrypted version of the web protocol.
- Certificate: what proves a website is who it claims to be.
- Self-signed certificate: a certificate made by the server itself rather than a trusted authority.
- URL parsing: breaking a web address into its parts so you can reason about where it really leads.
- Regular expression: a pattern for matching text.
- Protocol-relative address: an address starting with
//that borrows the current page's scheme. - DOM: the browser's in-memory model of the page.
- Control: a comparison case that should behave normally, used to check whether an unusual case really is unusual.
- Favicon: the little icon browsers request for a tab.
- Denylist: a list of things you refuse.
- Allowlist: a list of things you permit.
- Phishing: tricking someone into trusting a link or page that is not what it claims to be.
- Session: the period you stay signed in, usually tracked by a cookie.
- Cookie: a small piece of data the browser stores and sends back to a site.
- Token: a string that proves you are allowed to do something.
- Regression test: a test that makes sure a fixed bug stays fixed.