repositories

daemon-sec-cheatsheet

The cheatsheet vault for operators: AD, enumeration, exploitation, priv-esc, web, DFIR

clonegit clone https://git.daemon-sec.xyz/daemon-sec-cheatsheet.git
client-side-path-traversal.mdMarkdown120 lines10.9 KiBsource raw download

title: "Client Side Path Traversal" section: "Web Pentesting" sectionSlug: "pentesting-web" sourcePath: "src/pentesting-web/client-side-path-traversal.md" sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/pentesting-web/client-side-path-traversal.md" sha: "188de82beb54e70956b2952367a0af91d26758b8" isIndex: false modified: true license: "CC-BY-NC-4.0"#

Client Side Path Traversal#

Basic Information#

A client-side path traversal (CSPT), also called on-site request forgery (OSRF), occurs when attacker-controlled data is inserted into a URL path used by client-side code. By injecting dot segments such as ../, an attacker can make the victim's browser send an authenticated request to a different path on the same origin. The request may carry cookies, JavaScript-added authorization headers, or a client certificate, depending on how the application constructs it.[5][7]

Typical sources (data you control) include route parameters, stored values, and UI-controlled path fragments:[7][8]

Typical sinks (where the traversal lands) include request builders and navigation or resource-loading APIs:[7][8]

Common impacts & chains#

Example findings#

CSPT-assisted web cache poisoning/deception#

CSPT can be chained with extension-based CDN caching to exfiltrate sensitive JSON leaked by authenticated API calls:[1][2]

Quick recipe:

  1. Find SPA code building API URLs from path parameters while sending auth headers.
  2. Identify sensitive endpoints and test static suffixes (.css, .js, .jpg, .json) to see if the CDN flips to Cache-Control: public/max-age and X-Cache: Hit while returning JSON.
  3. Lure the victim to a URL that injects traversal into the SPA parameter so the authenticated fetch hits the cacheable path variant (for example, ../../../v1/token.css).
  4. Read back the same URL anonymously to obtain the cached secret (token → ATO).

See details and mitigations in the Cache Deception page: Cache Poisoning and Cache Deception.

Hunting workflow & tooling#

Passive discovery with intercepting proxies#

Instrumenting SPA sinks manually#

Dropping a short snippet in DevTools helps surface hidden traversals while you interact with the UI:

(() => {
  const origFetch = window.fetch;
  window.fetch = async function (input, init) {
    if (typeof input === "string" && /\.\.\//.test(input)) {
      console.log("[CSPT candidate]", input, init?.method || "GET");
      debugger;
    }
    return origFetch.apply(this, arguments);
  };
})();

Lab & payload rehearsal#

Recent case studies (2025)#

Payload cookbook#

Goal Payload pattern Notes
Hit sibling API under same origin ?doc=../../v1/admin/users Works when routers simply concatenate /${doc}. Add .json if CDN only caches static-looking assets.
Force SPA to follow open redirect ?next=..%2f..%2f..%2flogin/callback/%3FreturnUrl=https://attacker.tld/x Combine with trusted redirectors listed in target’s codebase. Chain with Open Redirect.
Abuse extension-based CDN cache ?file=../../v1/token.css CDN may treat .css as static and cache secrets returned as JSON.
CSRF via verb change ?action=../../payments/approve/.json&_method=POST Some routers accept _method overrides; pair with traversal to re-target destructive endpoints.

References#