Path traversal in GetVersion::get_current_commit() via unsanitized $branch parameter #4
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
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?
Problem
get_current_commit()interpolates the$branchparameter directly into asprintf()call that constructs a filesystem path:sprintf('../.git/refs/heads/%s', $branch). The method ispublic staticwith no sanitization, so any caller can pass arbitrary strings including path-traversal sequences.Location
src/GetVersion.php, lines 10–11Risk
All three controllers today call this with the hardcoded string
"master", so there is no immediate user-controlled input path. However, the unguarded public static signature is a latent vulnerability — one refactor away from exploitation. If user input were ever passed as$branch, an attacker could supply../../config/packages/securityto read arbitrary files accessible to the web process, leaking secrets, configuration, or source code.Suggested fix direction
Restrict allowed branch names to an alphanumeric allowlist (e.g.,
preg_match('/^[a-zA-Z0-9_\-]+$/', $branch)) before use in the path, or make the branch value a compile-time constant rather than a parameter.Severity
moderate
Found by
Automated audit by Claude Code