Path Traversal File Path Join
A user-controlled value is passed to filepath.Join to build a path that is then opened or served (CWE-22). filepath.Join calls Clean but does NOT confine the result to a base directory, so a leading '..' or absolute segment still escapes it.
Standards mapping
- OWASP Top 10
- A01:2021 - Broken Access Control
- OWASP ASVS
- V12.3.1 (L1)
Vulnerable vs. safe
p := filepath.Join("/var/data", name)p := filepath.Join("/var/data", name)Why it matters & how to fix it
A user-controlled value is passed to filepath.Join to build a path that is then opened or served (CWE-22). filepath.Join calls Clean but does NOT confine the result to a base directory, so a leading '..' or absolute segment still escapes it. Validate the joined path stays within an intended root (filepath.Rel + reject '..'), or strip the input to filepath.Base first.
References
Rule ID integsec-go-path-traversal-filepath-join - engine: Opengrep - license: MIT - Copyright (c) IntegSec Inc.
TurboPentest runs this check automatically
Connect a GitHub repo and this check runs on every white-box pentest - AI-validated and reported with proof, from $99 per target.
Start a pentestRelated checks
- JavaScript / TypeScript - SSRF & Path TraversalPath Join With Request
- JavaScript / TypeScript - SSRF & Path TraversalPath Traversal Tainted Input
- JavaScript / TypeScript - SSRF & Path TraversalSSRF Outbound Request Tainted Input
- Python - SSRF & Path TraversalPath Traversal
- Python - SSRF & Path TraversalSSRF HTTP Request
- Java - SSRF & Path TraversalPath Traversal Tainted Input