strstr(..) path traversal check is weak and has false positives #112
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
The code checks
strstr(disk_path, "..") != NULLto block path traversal in three places (file.c:212-213,220-221,236-237, and460-461). This is a weak check:/foo/..bar/filecontains ".." but is not traversal — this causes false positivesLocation
src/shared/file.c:212-213, 220-221, 236-237, 460-461
How to trigger
An attacker sends a crafted file path that bypasses the substring check. If successful, files can be written outside the destination directory.
Suggested Fix
Use
realpath()to canonicalize the destination path and verify it starts with the root directory. Before that, the received path should be checked character-by-character to reject any path component that is exactly ".." (not substring).Expected impact
Prevents arbitrary file write outside the destination directory.
Severity
high
Category
security
Sub-Agent
security-screener (SC-1)
This issue was automatically generated by the issue-creator agent.
Fixed in PR #148 — merged into main on 2026-07-29. See #148