Path Traversal

Untrusted input becomes part of a filesystem (or internal URL) path without being resolved and confined to an intended root, so the operation reads, writes or includes a location the developer never meant to expose (CWE-22).

What it is

Why it matters

Impact depends on the primitive (read, write, include, delete) and the process’s privileges.

PrimitiveTypical impactExample
Arbitrary readSecrets, source, config, backups, credentialsUniFi captive portal reads controller backups holding admin creds (CVSS 10.0)
Arbitrary read via proxyMass data exposure on an internal APIStarbucks: ~100M customer records
Arbitrary writeRCE via cron, web root, hooks, preload, templatesFortiSIEM, Check Point, vCenter, SmarterMail, Splunk
Local file inclusionCode execution in the interpreterWP Ghost, WordPress core page templates, Discuz!
Key/file selectionAuth bypassJWT kid pointing at a predictable file

How it works

Normalization and canonicalization

Archive extraction

Entry names and link targets inside zip/tar/cryptex archives are attacker-controlled paths. Extracting without per-entry containment is Zip Slip.

Include mechanisms

When the sink is an interpreter’s include (PHP include/require, template resolution), traversal becomes code execution if any reachable file contains or can be made to contain code. See Local File Inclusion.

Client-side path traversal (CSPT)

User input placed in a path the browser fetches lets an attacker redirect an authenticated same-origin request to another API route. Grafana chained this with an open redirect to load attacker JS and take over accounts (CVE-2025-4123, then the incomplete-fix CVE-2025-6023). CSPT also drives destructive state-changing requests, a Cross-Site Request Forgery analogue. Grafana CVE-2025–4123: Full Read SSRF & Account Takeover Grafana CVE-2025-6023: Full Account Takeover Top 10 web hacking techniques of 2022 - PortSwigger Research Disclosed: $4.3m Paid in HackerOne LHEs, PortSwigger Top 10 Released

Where to find it

Sink / featureExamples from the notes
File download / static servingUniFi portal new File(dir + "/" + path); Grafana static handler; Flask-Admin FileAdmin
Upload destinationFilename from Content-Disposition, uploadPath/guid/name params; Flask-Reuploaded save(name=...); Check Point upgrade service
Path built from an identifierOllama manifest digest; Gogs org name via Go path.Join; JWT kid; Frappe SCORM chapter title
Backup / restore / exportSplunk PostgreSQL sidecar backupFile passed to the dump tool
Logging / syslogvCenter syslog templates splicing a header field into a file path
RPC / gRPC file operatorsColdFusion RDS FileReadOperator/FileWriteOperator; FortiSIEM gRPC SendQueryResult
Archive extractiontarfile, zipfile, shutil.unpack_archive, libarchive, docker cp, SCORM/plugin packages
Include / template resolutionPHP include, WordPress get_page_template(), WP Ghost showFile()
Server-side proxies (BFF)Input inserted into an internal API path
AI agent / MCP toolsFile-reader tools without a root; 82% of 2,614 MCP servers analysed use path-traversal-prone file ops
Mobile content providersAndroid _display_name used as a filename (Xiaomi Mi Browser)
Repo-consuming toolsBuild scripts, editors and AI coding agents reading through committed symlinks

How to review and test

Code review:

  • Trace every filesystem call (open, File, Path, readFile, include, extract*, copy, rename, unlink) back to its inputs. Include indirect inputs: archive entries, manifests, DB fields, headers, filenames from clients.
  • Is the check done on the canonical path, after symlink resolution, and compared component-wise to the canonical root? Flag startswith/indexOf on strings.
  • Is the value that is checked the value that is used? Look for re-reads, re-joins and later decoding.
  • Is every component validated (directory and filename), on every entry point (UI, API, import, RPC)?
  • Does the code follow symlinks the attacker can create (git checkouts, uploaded archives, shared containers, app groups)? Is there a TOCTOU window?
  • Are archives extracted with per-entry containment and link handling? Are stdlib filters up to date (see Zip Slip and Archive Extraction)?
  • Does any include/template loader take user input? Is there an allowlist?
  • Do patches cover sibling paths? CVE-2025-8110, CVE-2025-6023 and CVE-2026-22559 were all bypasses or variants of earlier fixes.
  • Does an AI/MCP tool enforce a root in code, not in the prompt?

Behavioral testing (what to observe, not payloads):

  • Map every parameter that names a file, directory, key, template, locale or ID used in storage. Check whether returned paths or messages reflect your input unnormalized (the blind-upload case leaked the constructed path in its response). Escalating a Blind Upload to RCE via Path Traversal into Cron and DNS-Restricted Callback Bypass
  • Use error-class differences (not found vs bad request) to tell whether input reaches an internal service and where its root is (Starbucks).
  • Consider secondary-context APIs and proxies, browser path handling and how each server layer processes path components. Top Vulnerabilities for Pentest & Bug Bounty in 2025
  • Decide whether the traversal reaches the host’s real filesystem or only an app storage layer before claiming RCE.
  • For writes, grade the primitive (overwrite vs append, name control, privileges) and pick a sink that exists on the target (no cron in containers).
  • Diff patched vs unpatched builds for n-days; vendors often fix silently (SmarterMail build 9413 shipped months before the advisory).

Real-world cases

  • Starbucks BFF proxy — no CVE — path segment into internal API exposed ~100M customer records, $4,000. Starbucks Path Traversal
  • Ollama — CVE-2024-37032 — unvalidated manifest digest gives arbitrary write, RCE as root in Docker. Probllama
  • Gogs — CVE-2025-8110 — symlink bypass of CVE-2024-55947 via PutContents, exploited in the wild. Gogs Zero-Day RCE
  • Gogs — CVE-2026-52813 — org name joined into repo root via the API, bare repo plus git hooks for RCE. Yet another RCE in Gogs
  • SmarterMail — CVE-2025-52691 — unauthenticated upload with traversal in guid, web shell in IIS root. SmarterMail Pre-Auth RCE
  • FortiSIEM — CVE-2026-106173 — unauthenticated gRPC write overwrote a cron-executed script for RCE. FortiSIEM gRPC Path Traversal
  • Check Point Management — CVE-2026-93616 — unauthenticated root write on TCP 19009, cron job, exploited ITW. One Port to Root
  • vCenter — CVE-2026-59310 — syslog header spliced into a file path, pre-auth write to RCE (CVSS 9.8). vCenter pre-auth RCE
  • Splunk Enterprise — CVE-2026-20253 — unauthenticated sidecar backupFile traversal, file write to RCE. Splunk Enterprise CVE-2026-20253
  • Adobe ColdFusion RDS — CVE-2026-48282 / 48313 — file read/write through RPC operators, fixed with resolveCanonical. ColdFusion APSB26-68
  • UniFi Network Application — CVE-2026-22557 — unauthenticated portal file read of credential backups, CVSS 10.0. Looting UniFi Controllers
  • Apple PCC darwin-init — CVE-2026-20685 — unsanitized archive entries written as root at boot, $150k. Hacking Apple's PCC
  • Docker docker cp — CVE-2026-17106 — container-to-host write via a tar race plus symlink following. CopyEscape
  • Frappe LMS — CVE-2026-39405 — SCORM title used as extraction dir, api.py overwrite for RCE. Frappe LMS RCE
  • Flask-Reuploaded — CVE-2026-27641 — name parameter traversal plus extension bypass, SSTI to RCE. Flask-Reuploaded CVE-2026-27641
  • @tinacms/graphql — CVE-2026-129861 — writes through dangling symlinks bypass assertWithinBase. @tinacms/graphql symlink path traversal
  • WordPress core — 4.7 to 7.1.1 — unauthenticated page-template LFI, conditional RCE. WordPress path traversal
  • WP Ghost — CVE-2025-26909 — unauthenticated LFI to RCE, 200k+ sites. WP Ghost LFI
  • ManageEngine ADAudit Plus — CVE-2022-28219 — traversal in /cewolf lets a planted file be deserialized, chained with blind XXE. Rapid7 Analysis: CVE-2022-28219
  • Xiaomi Mi Browser — CVE-2026-127209 — content-provider _display_name used as filename, write outside staging dir. Xiaomi Mi Browser
  • iOS containermanagerd — no CVE — symlinked App Group part yields read-write sandbox token for other containers. worse_finder
  • AWS aidlc-traceability — no CVE — LLM file-reader tool with no root; fixed with read-boundary enforcement. AI Agent File Reader
  • Flask-Admin FileAdmin — duplicate report — startswith containment check escaped via sibling directory. Flask-Admin
  • Next.js — CVE-2026-75604 and Telerik UI for ASP.NET AJAX — CVE-2026-18672 — unauthenticated traversal listed as hacker-relevant in week 44 2026. Top 5 hacker-relevant vulnerabilities (week 44 2026)
  • Cairn AI pentest agents (2026): a traversal in an upload filename wrote sitecustomize.py, which a newly spawned Python training process imported, giving a root shell. (source)

Prevention

  1. Don’t let users name paths. Map an ID to a server-side path through a lookup table, or generate filenames server-side (UUIDs). The JWT kid remediation is the canonical pattern. JWT Signature Bypass via kid Path Traversal
    const KEYS = { 'key-2024-01': '/secure/keys/2024-01.pem' };
    if (!Object.hasOwn(KEYS, kid)) throw new Error('Invalid key identifier');
    const key = fs.readFileSync(KEYS[kid]);
  2. Canonicalize, then verify containment component-wise. Resolve the root and the candidate (following symlinks) and require the candidate to be inside the root. AWS’s fix and the sibling _resolve_safe() helper do this; Path.resolve() also closes the symlink escape. AI Agent File Reader Python Secure Coding Guidelines
    ROOT = Path("/srv/app/files").resolve()
    def safe_path(user_rel: str) -> Path:
        p = (ROOT / user_rel).resolve()
        if not p.is_relative_to(ROOT):   # component-wise, not str.startswith
            raise PermissionError("outside root")
        return p
    Java equivalent, as in UniFi’s fix (toRealPath() containment) and ColdFusion’s resolveCanonical (reject empty, NUL, parent segments, absolute paths, and anything resolving outside the allowed area):
    if (userRel.isEmpty() || userRel.indexOf('\0') >= 0) throw new SecurityException("bad path");
    Path root = baseDir.toRealPath();
    Path real = root.resolve(userRel).normalize().toRealPath(); // resolves symlinks; file must exist
    if (!real.startsWith(root)) throw new SecurityException("outside root"); // Path.startsWith is per-component
  3. Kill the TOCTOU. A realpath() check followed by open() can be raced. On Linux use openat2() with RESOLVE_BENEATH or RESOLVE_NO_SYMLINKS so the kernel enforces the boundary in one step; O_NOFOLLOW covers only the last component. Imperva’s conclusion for docker cp: filesystem operations must be rooted so the kernel, not a string comparison, guarantees containment. Symlinks Are Still Scary CopyEscape
  4. Sanitize filenames with framework helpers and also enforce policy. Flask-Reuploaded’s workaround: secure_filename, then os.path.basename, then an extension allowlist, or auto-generated names only. Flask-Reuploaded
    safe = os.path.basename(secure_filename(request.form["custom_name"]))
    if not photos.extension_allowed(photos.get_extension(safe)):
        abort(400)
    photos.save(file, name=safe)
  5. Validate every component and entry point. The directory part (guid, org name, chapter title, uploadPath) needs the same treatment as the filename, on API routes as well as the UI.
  6. Allowlist includes and templates. Never pass request data to an include; see Local File Inclusion.
  7. Extract archives safely. Per-entry containment, reject or neutralize links, keep stdlib current; see Zip Slip and Archive Extraction.
  8. Contain the blast radius. Run file-handling services unprivileged (Ollama-in-Docker as root made writes critical), store uploads outside executable directories (see Unrestricted File Upload), sandbox extraction, and treat cloned repos as untrusted before pointing tools or agents at them. Python Security Vulnerabilities - Top Issues - Aikido
  9. Normalize once, at the edge that routes. Reject or canonicalize path parameters and encoded separators so the WAF, proxy and app agree (IBM Db2 Mirror fix advice: use container-normalized servlet info, reject unexpected path parameters, confine reads to an allowlisted directory with canonical-path checks). IBM Db2 Mirror for i: pre-auth RCE and the road to QSECOFR
  10. Monitor for the write. For root-write bugs, file-integrity monitoring catches exploitation better than log greps (Check Point guidance).

Tools

Sub-pages

Related: Unrestricted File Upload · Web Shells · Remote Code Execution · Local File Read via SSRF · URL Parser Differentials · Cross-Site Request Forgery · JWT Header Injection · Unsafe Python Functions · Python Security · MCP Security · Vulnerability Chaining

Sources