Skip to content

Path traversal encoding bypass (URL, double, and overlong UTF-8)

A path traversal encoding bypass hides the ../ sequence from a filter by encoding the dot or slash — single URL encoding (%2e%2e%2f), double encoding (%252e), overlong UTF-8 (%c0%ae) or 16-bit Unicode (%u2215). It works when a filter inspects the raw string but the value is decoded again before it reaches the file API.

Linux / UnixWindowsArbitrary file readInformation disclosureEncoding

How it works

A filter that blocks the literal ../ can be defeated when decoding happens after the check, or more than once. The request carries an encoded form that the filter does not recognise; a later decode step restores ../ before the file is opened.

Single URL encoding replaces characters with %XX (. is %2e, / is %2f). Double encoding encodes the percent sign itself (%25), so %252e decodes to %2e on the first pass and to . on the second — effective against stacks that decode twice (e.g. a proxy then the app).

Overlong UTF-8 encodes / as the illegal multi-byte %c0%af (and . as %c0%ae), which some lenient decoders still accept. The non-standard %u2215 (Unicode fraction slash) and %uff0e were historically decoded by IIS. Which form works depends entirely on the decoder in the path.

When it works and when it fails

Works when

  • A blocklist checks the raw string but the framework/proxy URL-decodes it afterwards.
  • Two decode passes exist in the stack (proxy + app, or double call to a decoder) — double encoding then lands as ../.
  • A lenient or legacy decoder accepts overlong UTF-8 or %u-style sequences.

Fails when

  • The value is canonicalized once and then validated (check-after-decode) with a prefix/allowlist test.
  • A strict decoder rejects overlong UTF-8 and unknown %u sequences.
  • Input is resolved through an allowlist so the decoded form is never used as a path.

Representative payloads

Adapt these to your authorized target; they are shown in canonical form. Payloads are never translated.

  • ..%2f..%2f..%2fetc%2fpasswd
    Linux / UnixEncoding

    Single URL encoding of the slash. Bypasses a filter that matches literal / but runs before the framework decodes the query string.

  • %2e%2e%2f%2e%2e%2f%2e%2e%2fetc%2fpasswd
    Linux / UnixEncoding

    Both dots and slashes encoded, so no recognisable ../ appears in the raw string at all.

  • ..%252f..%252f..%252fetc%252fpasswd
    Any OSEncoding

    Double encoding: %252f -> %2f -> / across two decode passes. Targets proxy-plus-app stacks that each decode once.

  • ..%c0%af..%c0%af..%c0%afetc/passwd
    Any OSEncoding

    Overlong UTF-8 for the slash (%c0%af). Accepted by lenient decoders that do not reject non-shortest-form sequences.

    Note: Historically effective against older IIS and some Java decoders.

  • ..%u2215..%u2215..%u2215etc/passwd
    WindowsEncoding

    Non-standard %u Unicode escape for the fraction slash (U+2215), decoded by some legacy Windows/IIS components.

Detection

In logs

  • Encoded dot/slash fragments in parameters: %2e, %2f, %5c, %252e, %252f, %c0%ae, %c0%af, %u2215.
  • A decoded view of request parameters that, once normalised, contains ../ or ..\.
  • Repeated requests cycling through encoding variants against the same parameter.

In code

  • Validation that runs before the framework/proxy decodes the input (check-before-decode is the core bug).
  • Multiple decode steps in one request path (proxy rewrite + manual urldecode in the handler).
  • Custom or legacy decoders configured to accept overlong UTF-8 or %u sequences.

Detection rule: Normalise/decode fully, then match (\.\.(/|\\)) once; alerting on raw %c0%af and %252f catches tool traffic but must not replace canonicalize-then-validate.

Remediation

  • Canonicalize first, validate second: fully decode and normalise the input exactly once, then run the allowlist / prefix check on the result.
  • Decode in a single, well-defined place — never validate a value that a later layer will decode again.
  • Use a strict UTF-8 decoder that rejects overlong and non-shortest-form sequences, and reject unknown %u escapes.
  • Prefer an allowlist of keys to a path so the decoded string is never used to build a filesystem path.

Vulnerable (javascript)

// validates BEFORE decoding -> encoded ../ slips through
if (req.query.f.includes('../')) return res.sendStatus(400);
fs.readFile(path.join(BASE, req.query.f), cb);

Fixed

const decoded = decodeURIComponent(req.query.f);
const full = path.resolve(BASE, decoded);
if (!full.startsWith(BASE + path.sep)) return res.sendStatus(400);
fs.readFile(full, cb);

Decode and normalize once, then check the result stays under the base — not the raw input.

FAQ

When does double URL encoding work?
When two layers each URL-decode once — for example a reverse proxy rewrites and decodes, then the application decodes again. %252f becomes %2f then /, so the traversal only appears after both passes.
Why does canonicalize-then-validate stop these?
Every encoding trick relies on the check seeing a different string than the file API does. Decoding and normalising to one canonical form before validating removes that gap.

References