T09 · Insecure Skill Coding Practices
- Location
ops/incremental_scan.py:242- Finding
Git Option Injection Through Unvalidated Remote Argument
- Content
View full analysis
Vulnerability Details
File Location:
ops/incremental_scan.py:82andops/incremental_scan.py:242-249
Vulnerability Type: Git argument injection
Risk Level: HighThe scanner accepts a caller-controlled Git remote and passes it directly to
git fetchin an option-sensitive position.python parser.add_argument("--remote", default="origin", help="Git remote")python result = subprocess.run( ["git", "fetch", remote, branch], cwd=repo, capture_output=True, text=True, timeout=timeout_seconds, check=False, )Technical Analysis
The use of a subprocess argument list prevents shell metacharacter expansion, but it does not prevent option injection into the invoked program. Because
remoteis placed immediately aftergit fetch, a value beginning with-can be parsed as a Git option instead of a remote name.The
branchargument is also caller-controlled. If the supplied remote is interpreted as an option, the branch value can shift into the repository operand. This allows an attacker to alter fetch transport behavior, remote selection, protocol parameters, or other Git-fetch semantics. Depending on the installed Git version, enabled protocols, repository configuration, and crafted arguments, this could cause unintended network access or command execution through dangerous transport mechanisms.Attack Path
- An attacker controls, supplies, or persuades an operator to use crafted
--remoteand--branchvalues. - The incremental scanner accepts these values without rejecting leading hyphens or validating them as configured Git remote and branch names.
git_fetch()constructsgit fetchwith the attacker-controlled remote in an option-sensitive position.- Git interprets the crafted remote as one or more command-line options rather than as a remote name.
- The controlled branch value may then be interpreted as the repository operand.
...[truncated 818 chars]
- An attacker controls, supplies, or persuades an operator to use crafted
- Remediation
View remediation
Remediation Suggestions
- Reject remote and branch values that are empty, contain control characters, or begin with
-. - Verify that the remote is an existing configured remote, for example by comparing it against the output of
git remote. - Validate the branch using an appropriate Git reference validation command such as
git check-ref-format --branch. - Use an explicit option terminator before positional arguments wherever the relevant Git command supports it.
- Prefer resolving the configured remote URL independently and applying an allowlist for permitted URL schemes and hosts.
- Disable dangerous Git transports in the scanner environment and use a restricted environment for automated fetches.
- Add regression tests covering remote and branch values beginning with
-, transport-like values, control characters, and malformed references.
- Reject remote and branch values that are empty, contain control characters, or begin with
