Skip to content
Open redirect Write-up Beginner

Weak Cryptography Leads To Open Redirect

The login redirect parameter used a Base64-encoded value containing the target URL, its length, and a Base64 copy of the URL as an integrity check. Because the check was predictable, an attacker could craft a value pointing to an external site and cause the application to redirect users there after login.

darklotus Follow

Published on medium.com

{{media:0}}

DarkLotus, on medium.com

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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 4 min read.

Context

The target is referred to throughout as target.com. The vulnerable feature is the login page at https://login.target.com/login, which accepts a redirect parameter and, after a successful login, sends the user on to the destination named in that parameter. In the normal case the destination is an internal application page such as the dashboard at https://app.target.com/dashboard.

The finding is an open redirect: the application takes user-controllable data and uses it as the target of a redirection without adequate validation, so an attacker can build a link on the authentic domain that lands the victim on an arbitrary external site. Because the link carries the real domain and a valid certificate, it lends credibility to phishing.

Setup

The only tool named in the report is waybackurls, used during reconnaissance to collect endpoints of the target. The collected URLs were then filtered with grep for those containing the redirect parameter. No accounts, roles or versions are described.

Finding it

Reconnaissance came first. Running waybackurls against the target produced many endpoints, and filtering them for the redirect parameter surfaced a URL of this shape:

HTTP
https://login.target.com/login?redirect=[redacted]%3D

The redirect value is Base64, with the trailing = URL-encoded as %3D. Decoding the URL encoding first gives:

Text
[redacted]=

Base64-decoding that value yields a three-part structure separated by pipes:

Text
https://app.target.com/dashboard|32|[redacted]=

The first part is the destination URL. The second part, 32, is the length of that URL counted from the first h of https to the last d of dashboard. The third part is the Base64 encoding of the same URL. The researcher describes the third part as a token that is nothing more than the Base64-encoded URL.

That structure is what made the parameter interesting: the destination is not signed with a key the client cannot produce. The integrity check is derived entirely from the URL itself, so anyone who can compute a length and a Base64 encoding can produce a value that passes it.

Exploitation

The backend flow the researcher inferred is:

Text
User Login -> Base64 decode redirect value -> checking the integrity by URL length & Encoded value -> If all good -> Redirect
Image for post
Image for post From the original on medium.com

The plan was therefore to build the same three-part structure for an attacker-controlled URL.

Step 1: count the length of the malicious URL

Text
https://evil.com => 16

Step 2: Base64-encode the malicious URL

Text
https://evil.com => aHR0cHM6Ly9ldmlsLmNvbQ==

Step 3: combine the parts with pipes

The malicious URL, its length and its Base64 encoding are joined with | as the separator:

Text
https://evil.com|16|aHR0cHM6Ly9ldmlsLmNvbQ==

Step 4: Base64-encode the whole payload

Text
[redacted]=

Step 5: URL-encode the =

The trailing = becomes %3D, and the result is placed in the redirect parameter of the vulnerable URL:

HTTP
https://login.target.com/login?redirect=[redacted]%3D
Image for post
Image for post From the original on medium.com

After login, the site redirected to evil.com. The report does not show the HTTP response itself, only that the redirect happened once the user had logged in.

Root cause

The redirect value is protected by an integrity check that is not a signature: the server decodes the parameter and checks the stated length and the embedded Base64 copy against the destination URL. Both values are computable by anyone, so an attacker can craft a valid-looking value for any destination. The check verifies internal consistency, not authenticity, and there is no indication that the destination is restricted to an allowlist of trusted hosts. The report does not describe the server-side code, so the exact comparison logic is not shown.

Impact

An attacker can construct a link on the genuine login.target.com domain that, after the victim logs in, redirects to an arbitrary external site. The report frames the consequence as phishing: the authentic domain and valid SSL certificate make the link credible, and users who check those features will still not notice the subsequent redirection to a different domain. The redirect occurs after login, so the victim must authenticate for the flow to complete.

Fix

The weakness it describes points to the fix: do not rely on a length and a Base64 copy as an integrity check, and validate the destination against an allowlist of trusted hosts rather than accepting any URL that is internally consistent.

Variants to test

  1. Look for redirect, return, next, url, continue and similar parameters in archived URLs, then decode any Base64-looking value and look for a self-describing structure (length, checksum, duplicate copy). A positive result is a decoded value whose parts can be recomputed for an external URL and accepted by the server.
  2. Where a length field is present, change the destination to a different host of the same length and see whether the server still redirects. A positive result is a redirect to the new host without any error.
  3. Where a duplicate Base64 copy is present, replace only the first URL and leave the copy untouched. A positive result is a redirect to the first URL, showing the copy is not actually compared.
  4. Try the same structure with the pipe replaced by other separators the decoder might accept, and with the trailing = left unencoded. A positive result is the same external redirect.
  5. Test whether the redirect fires before authentication as well as after. A positive result is a redirect to the external site without a completed login.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 10 min read.

What happened, in plain words

A security researcher was looking at a company's login page. After you log in, that page sends you onward to another page, for example your dashboard. The page you are sent to is chosen by a value in the web address itself, in a part called the redirect parameter. The company tried to protect that value so that people could not swap in their own destination. The protection turned out to be something anyone can calculate, so the researcher built a value that pointed at evil.com instead, and after logging in the browser went to evil.com.

That kind of bug is called an open redirect. It matters because the link the victim clicks starts on the real company domain, with the real padlock in the browser, and only afterwards jumps to the attacker's site. People who check the domain and the padlock will still be fooled.

This article walks through the same steps the researcher took, explaining each idea from scratch. You only need a browser and a computer to follow along; the tools mentioned are free and run in a terminal, but the concepts are what matter.

The target and the feature

The company is called target.com throughout. The feature involved is the login page at https://login.target.com/login. It takes a redirect parameter, which is the part of a web address after the ? sign that carries extra information. In the normal case, that parameter names an internal page such as the dashboard at https://app.target.com/dashboard, and after a successful login the browser is sent there.

Think of the redirect parameter as a forwarding address written on an envelope: the post office (the login page) reads it and sends you on. If anyone can write any address on the envelope, the post office will deliver you anywhere.

What an open redirect is

An open redirect happens when a website takes a value that a user can control and uses it as the destination of a redirect without checking it properly. An attacker can then build a link on the real site that sends the visitor to any external site.

Why is that dangerous? Because the link starts with the genuine domain and, if the site uses HTTPS, carries a valid certificate. Many users check the domain and the padlock, and both look right. They will not notice the second hop to a different domain. Attackers use this to make phishing pages look trustworthy.

Setup: how the researcher found the page

The only tool named in the report is waybackurls, used during reconnaissance. Reconnaissance means gathering information about the target before testing: which pages exist, which parameters they accept, and so on. It plays an important role in finding bugs.

waybackurls collects archived web addresses of a target. Running it against the target produced many endpoints. An endpoint is simply a specific address on a server that does something, like a page or a service.

The researcher then filtered those addresses with the grep command, a standard command-line tool that searches text for a pattern, keeping only the URLs that contained the redirect parameter. That is how the interesting login URL surfaced.

No accounts, roles or software versions are described in the report.

Finding it

Filtering the archived URLs for the redirect parameter produced a URL of this shape:

HTTP
https://login.target.com/login?redirect=[redacted]%3D

Line by line:

  • https://login.target.com/login is the login page.
  • ? starts the list of parameters.
  • redirect= names the parameter and begins its value.
  • The long string after it is the value itself, which looks like encoded text rather than a plain web address.

A value like that is often Base64. Base64 is a way of writing any data using only letters, digits and a couple of symbols, so it can travel safely inside a web address. It is not encryption: anyone can decode it, and it hides nothing. Think of it as a different alphabet for the same sentence.

In a web address, some characters have special meanings, so they are written in a percent-encoded form: a % followed by two characters. Here the value ends in %3D, which is the percent-encoded form of the = sign. The researcher first changed %3D back to =, which is called URL-decoding, giving:

Text
[redacted]=

Line by line: this is the same value as before, with the trailing = restored. The = at the end of Base64 text is padding, added so the length comes out right; it carries no information of its own.

Base64-decoding that value produced a three-part structure separated by pipe characters (|):

Text
https://app.target.com/dashboard|32|[redacted]=

Line by line:

  • https://app.target.com/dashboard is the destination, the internal dashboard page.
  • 32 is the length of that destination URL, counted from the first h of https to the last d of dashboard.
  • [redacted]= is the Base64 encoding of the same destination URL.

The researcher describes the third part as a token that is nothing more than the Base64-encoded URL. A token here just means a short piece of text the server can check later; it is not a secret and not a password.

Why did this structure make the parameter interesting? Because the destination is not signed with a secret key that only the server knows. The check is built entirely out of the URL itself: its length and a copy of it in Base64. Anyone who can count characters and encode text can produce a value that passes the check. A signature is like a wax seal made with a stamp only the sender owns; here there is no stamp, just a note saying "this is genuine", which anyone can write.

Exploitation

The researcher worked out that the server does something like this:

Text
User Login -> Base64 decode redirect value -> checking the integrity by URL length & Encoded value -> If all good -> Redirect

Line by line:

  • User Login: the user logs in first.
  • Base64 decode redirect value: the server takes the redirect parameter and Base64-decodes it.
  • checking the integrity by URL length & Encoded value: it checks the stated length and the embedded Base64 copy against the destination. Integrity here means "the value has not been altered", and the server is trying to confirm that.
  • If all good -> Redirect: if the checks pass, the browser is sent to the destination.
Image for post
Image for post From the original on medium.com

The image illustrates this backend flow: login, decode, check length and encoded value, then redirect.

The plan was therefore to build the same three-part structure for an attacker-controlled URL. If the server only checks that the parts agree with each other, a correctly built structure for evil.com will pass just as well as one for the dashboard.

Step 1: count the length of the malicious URL

Text
https://evil.com => 16

Line by line: https://evil.com is the attacker's site, and counting every character gives 16. The server will compare this number with the destination, so it must be exact.

Step 2: Base64-encode the malicious URL

Text
https://evil.com => aHR0cHM6Ly9ldmlsLmNvbQ==

Line by line: the same URL, written in Base64. This becomes the third part of the structure, the copy the server will compare against.

Step 3: combine the parts with pipes

The malicious URL, its length and its Base64 encoding are joined with | as the separator:

Text
https://evil.com|16|aHR0cHM6Ly9ldmlsLmNvbQ==

Line by line: destination first, then the length, then the Base64 copy, exactly the same order and separator as the legitimate value. The pipe is just a divider, like a comma between items in a list.

Step 4: Base64-encode the whole payload

Text
[redacted]=

Line by line: the whole three-part string is now Base64-encoded, because that is the form the redirect parameter expects. A payload is simply the crafted input an attacker sends.

Step 5: URL-encode the =

The trailing = becomes %3D, and the result is placed in the redirect parameter of the vulnerable URL:

HTTP
https://login.target.com/login?redirect=[redacted]%3D

Line by line:

  • https://login.target.com/login is the genuine login page.
  • ?redirect= starts the parameter.
  • The long value is the Base64 payload from step 4, with its final = written as %3D so the web address stays valid.
Image for post
Image for post From the original on medium.com

The image shows the final crafted URL with the Base64 payload in the redirect parameter, ready to be used.

After login, the site redirected to evil.com. The report does not show the HTTP response itself, only that the redirect happened once the user had logged in.

Root cause

The redirect value is protected by a check that is not a signature. The server decodes the parameter and checks the stated length and the embedded Base64 copy against the destination URL. Both values can be computed by anyone, so an attacker can craft a valid-looking value for any destination. The check confirms that the parts agree with each other, not that the destination is trustworthy, and there is no sign that the destination is restricted to a list of trusted hosts. The report does not describe the server-side code, so the exact comparison logic is not shown.

A useful comparison: a bouncer who only checks that your name badge matches the name you wrote on the form will let anyone in, because anyone can write the same name twice. A real check would compare the name against a guest list kept by the venue.

Impact

An attacker can build a link on the genuine login.target.com domain that, after the victim logs in, sends them to any external site. The report frames the consequence as phishing: the authentic domain and valid certificate make the link credible, and users who check those features will still not notice the later jump to a different domain. The redirect happens after login, so the victim has to authenticate for the flow to complete.

Fix

The weakness it describes points to the fix: do not rely on a length and a Base64 copy as an integrity check, and validate the destination against an allowlist of trusted hosts instead of accepting any URL whose parts happen to agree. An allowlist is a list of names that are allowed, like a guest list at the door; anything not on it is refused.

Variants to test

  1. Look for redirect, return, next, url, continue and similar parameters in archived URLs, then decode any Base64-looking value and look for a self-describing structure (length, checksum, duplicate copy). A positive result is a decoded value whose parts can be recomputed for an external URL and accepted by the server.
  2. Where a length field is present, change the destination to a different host of the same length and see whether the server still redirects. A positive result is a redirect to the new host without any error.
  3. Where a duplicate Base64 copy is present, replace only the first URL and leave the copy untouched. A positive result is a redirect to the first URL, showing the copy is not actually compared.
  4. Try the same structure with the pipe replaced by other separators the decoder might accept, and with the trailing = left unencoded. A positive result is the same external redirect.
  5. Test whether the redirect fires before authentication as well as after. A positive result is a redirect to the external site without a completed login.

Glossary

  • API: a way for one piece of software to ask another to do something, like a service counter where you make a request and get a response.
  • Allowlist: a list of things that are permitted; anything not on the list is refused.
  • Base64: a way of writing data using letters, digits and a few symbols so it can travel inside text such as a web address; it is encoding, not encryption, and anyone can decode it.
  • Checksum: a short value computed from data so that changes can be detected; here the length and the Base64 copy play that role.
  • Endpoint: a specific address on a server that does something, such as a page or a service.
  • grep: a command-line tool that searches text for a pattern.
  • HTTPS / SSL certificate: HTTPS is the encrypted version of the web; the certificate is the proof a site presents that it owns its domain, shown as the padlock in the browser.
  • Integrity check: a check that data has not been altered, as opposed to a check that it came from a trusted source.
  • Open redirect: a bug where a site sends users to a destination supplied by the user without proper validation, allowing links on the real domain to lead anywhere.
  • Parameter: the part of a web address after ? that carries extra information, such as redirect=....
  • Payload: the crafted input an attacker sends to trigger a bug.
  • Percent-encoding (URL-encoding): writing special characters as % plus two characters, such as %3D for =.
  • Phishing: tricking people into trusting a fake page, often by making the link look like it belongs to a real company.
  • Reconnaissance: gathering information about a target before testing it.
  • Redirect: sending the browser from one address to another.
  • Signature: a value made with a secret key that proves data came from the holder of the key; unlike a length or a Base64 copy, others cannot produce it.
  • Token: a short piece of text a server can check later; here it is just the Base64-encoded URL, not a secret.
  • waybackurls: a tool that collects web addresses archived by the Internet Archive.

More by darklotus

View all

2 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Open redirect

The lesson behind this report.

A trusted site forwards users to any address an attacker picks; rarely paid alone, often the missing link in a chain.