Check the path the system finally uses#
The check in the code and the path the system opens are often different strings. Between them sit URL decoding, Unicode normalization, joins with a base directory and, for URLs, the parser of the HTTP client. A check that runs before any of those steps can pass a string that becomes .. afterwards.
Three behaviors catch most reviewers and authors out. os.path.normpath removes .. segments lexically and does not resolve symbolic links. Joining an absolute path onto a base discards the base. And a resolved path needs an explicit containment test:
>>> import os.path
>>> from pathlib import Path
>>> os.path.normpath("/srv/media/" + "../etc/passwd")
'/srv/etc/passwd'
>>> base = Path("/srv/media")
>>> (base / "/etc/passwd").resolve()
PosixPath('/etc/passwd')
>>> (base / "../etc/passwd").resolve().is_relative_to(base)
False
Path.resolve follows symbolic links, and is_relative_to then checks the result against the base. OWASP's guidance starts earlier: "Prefer working without user input when using file system calls", and "Use indexes rather than actual portions of file names". OWASP Path Traversal A path that no longer contains user text needs no traversal check at all.
A proxy where newlines reopened the hole#
In October 2026, a Home Assistant pull request added a media source for INDI Allsky camera servers. A proxy view decodes a base64 path from the request and fetches it from the device, after checking that the path is not absolute, has no .. part and starts with an allowed media prefix. On 23 October, Copilot's review said: "Control characters can bypass the proxy’s traversal checks, so path validation needs correction before approval." Its inline item was titled "Reject control characters before canonical path traversal checks". Review
The claim holds up when you follow the path past the check. A path segment of . newline . is not .., so ".." in PurePath(path).parts passes it. The HTTP client then parses the URL, and URL parsers drop ASCII tab and newline characters before resolving dot segments. WHATWG URL Standard Both yarl 1.25.1, which aiohttp uses, and Node's URL turn https://h/indi/images/.\n./api/admin into https://h/indi/api/admin. The request would leave the media prefix for another route on the device.
The merged code rejects \t, \r and \n in the canonical path, and Copilot's next review listed the item as resolved. Later review The test file is what settles it: it sends images/../secret, percent-encoded and doubly encoded dot segments, the three control-character variants, /etc/passwd and an out-of-prefix api/admin, and expects HTTP 400 for each. Merged diff The pull request merged on 7 November 2026. A future refactor of the validation has to keep those assertions passing.
Remove the input from the path#
A vLLM pull request from July 2025 shows the other remedy. The shared-storage KV connector named cache folders after its inputs, and the change added multimodal hashes to that name. Gemini Code Assist's review summary reported "a critical security vulnerability and a related correctness issue in the new cache key generation logic." Its inline comment, now resolved and hidden on the page, named path traversal as the first issue: the change concatenated the joined multimodal hashes, mm_str, directly into the folder name. Pull request
The merged version hashes the multimodal string together with the token bytes and uses the hex digest as the folder name, with a code comment: "Add mm_hashes to the bytes being hashed to avoid path traversal and to create a canonical key." Merged diff A maintainer asked, "Thanks for fixing, can you add a unit test to verify?", and the author added one. Maintainer's request That test checks that different image inputs produce different folders. Containment here comes from the digest itself: an MD5 hex digest contains only 0-9a-f, so no input can produce a separator or a dot segment. No traversal test is needed when the path holds no input text.
Decide from where the path ends up#
| What builds the path | Evidence to check | Response |
|---|---|---|
| A digest, an index or a fixed mapping | The name holds no input characters | Dismiss, naming the construction |
| Input joined to a base, then resolved and checked | resolve() or realpath before the containment check | Test with ../ and an absolute path; dismiss if both are refused |
| Input checked, then decoded or parsed again | Any decoding, URL parsing or normalization after the check | Change: check the final form, and add a test per encoding |
Input checked only with normpath or string prefixes | Symbolic links and .. under the base | Change to resolve and contain, then test |
| Input from operator configuration only | Who can write that configuration | Dismiss with the trust boundary, or defer hardening to an issue |
Where the test passes on the existing code, the comment was wrong, and the test stays as the record. Where a reviewer could not have seen the HTTP client or the parser downstream, the guide to reviewer context explains how to judge what it missed.