Skip to content

Make path traversal containment check case-insensitive#299

Merged
bitterpanda63 merged 1 commit into
mainfrom
fix/case-insensitive-path-traversal
Jun 1, 2026
Merged

Make path traversal containment check case-insensitive#299
bitterpanda63 merged 1 commit into
mainfrom
fix/case-insensitive-path-traversal

Conversation

@bitterpanda63
Copy link
Copy Markdown
Member

@bitterpanda63 bitterpanda63 commented Jun 1, 2026

Makes the user-input containment check in path traversal detection case-insensitive, matching the fix applied to the Node.js firewall in AikidoSec/firewall-node#1047.

Problem: On case-insensitive filesystems (macOS APFS, Windows NTFS), an attacker can submit a path like /ETC/PASSWD which resolves to /etc/passwd. The detection check filePath.contains(userInput) was case-sensitive, so /ETC/PASSWD would not be found in /etc/passwd and traversal would go undetected.

Fix: Changed filePath.contains(userInput) to filePath.toLowerCase().contains(userInput.toLowerCase()). Note that startsWithUnsafePath already lowercases both sides before comparing, so no change was needed there.

See: AikidoSec/firewall-node#1047

Summary by Aikido

Security Issues: 0 Quality Issues: 0 Resolved Issues: 0

🐛 Bugfixes

  • Made path containment check case-insensitive to fix traversal detection

More info

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@bitterpanda63 bitterpanda63 merged commit dcde26d into main Jun 1, 2026
242 checks passed
@bitterpanda63 bitterpanda63 deleted the fix/case-insensitive-path-traversal branch June 1, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants