URL Encoder / Decoder3 min readOct 21, 2026

How to Fix Double-Encoded URLs and Nested Redirect Parameter Corruption

Learn how URLs get double-encoded into %2520 and %252F, causing broken OAuth redirects and 400 Bad Request errors. Includes practical prevention patterns.

Direct Summary (TL;DR)

Double-encoding happens when an already percent-encoded URL is passed through another encoding step without being decoded first. The percent character '%' itself gets encoded as '%25', turning spaces (%20) into '%2520' and slashes into '%252F'. This frequently causes OAuth 'redirect_uri mismatch' and HTTP 400 Bad Request errors.

Interactive Mickytool Utility

Solve this problem now with our free URL Encoder / Decoder

Try it instantly in your browser — zero tracking, 100% client-side privacy.

Open URL Encoder / Decoder

Specification & Architecture Reference

How to Fix Double-Encoded URLs and Nested Redirect Parameter Corruption — Technical Summary
Original StringOnce Encoded (Valid)Double Encoded (Corrupted)
Space (' ')%20%2520
Slash ('/')%2F%252F
Ampersand ('&')%26%2526
Question Mark ('?')%3F%253F
Hash ('#')%23%2523

The Anatomy of the %2520 Bug

In percent-encoding, the percent character `%` itself has the hexadecimal ASCII code **`%25`**.

If a URL contains an encoded space: ```text https://example.com/user%20profile ``` And an application or reverse proxy (e.g., Nginx, AWS API Gateway, or a client HTTP interceptor) passes the string into `encodeURIComponent` a second time, the parser encodes the `%` character: ```text https://example.com/user%2520profile ``` The downstream server decodes only the outer layer, receiving the literal string `"user%20profile"` rather than `"user profile"`, which can break route handlers and query parameters.

Common In OAuth Redirect Flows Double encoding frequently occurs in OAuth 2.0 and OpenID Connect flows: ```text https://auth.example.com/authorize?redirect_uri=https%3A%2F%2Fapp.com%2Fcallback%3Fplan%3Dpro ``` If the frontend encodes the entire parameter string twice, the authorization server compares `https%253A%252F%252F...` against its registered whitelist, failing with a **`redirect_uri_mismatch`** error.

Safe Normalization Function To fix double-encoded strings defensively without throwing errors on malformed sequences:

javascript
function safeDecodeFully(uri) {
  let previous = uri;
  try {
    let current = decodeURIComponent(uri);
    // Continue decoding if nested encodings remain (capping loops at 3)
    let depth = 0;
    while (current !== previous && depth < 3) {
      previous = current;
      current = decodeURIComponent(current);
      depth++;
    }
    return current;
  } catch (e) {
    return previous; // Fall back to last safe state if malformed
  }
}

Inspect, decode, and unwrap nested redirect parameters with Mickytool's **URL Encoder / Decoder**.

Interactive Mickytool Utility

Solve this problem now with our free URL Encoder / Decoder

Execute this workflow immediately without saving data on remote servers.

Open URL Encoder / Decoder

Frequently Asked Questions

Why does Nginx cause double encoding in proxy_pass?

If you include a URI in proxy_pass (e.g. proxy_pass http://backend/;) with rewrite directives, Nginx re-encodes the URI before forwarding. Using proxy_pass without a trailing URI avoids modifying encoded characters.

Can an attacker exploit double encoding for security bypasses?

Yes. In poorly configured Web Application Firewalls (WAFs), double encoding (%252e%252e%252f for ../) can bypass path traversal inspection filters if the backend application decodes twice.

Related Engineering Guides