Summary
The pull_upstream tool interpolates the commit parameter directly into a git cherry-pick command with no escaping. While the policy engine's validate.git_hash rule validates commit format at the policy layer, defense-in-depth requires validation at execution time. A policy bypass or misconfigured rule would expose this injection point.
Vulnerable Code
if (commit) {
await run(`git cherry-pick ${commit}`);
appliedSummary = `Cherry-picked ${commit}`;
}
Recommendation
Validate at execution time with /^[a-f0-9]{7,40}$/ and use escapeShellArg():
if (!/^[a-f0-9]{7,40}$/.test(commit)) {
return `Blocked: invalid commit hash "${commit}"`;
}
await run(`git cherry-pick -- ${escapeShellArg(commit)}`);
Severity: HIGH
CWE: CWE-78 (OS Command Injection)
Location: src/agent/tools.ts — line 511
Summary
The
pull_upstreamtool interpolates thecommitparameter directly into agit cherry-pickcommand with no escaping. While the policy engine'svalidate.git_hashrule validates commit format at the policy layer, defense-in-depth requires validation at execution time. A policy bypass or misconfigured rule would expose this injection point.Vulnerable Code
Recommendation
Validate at execution time with
/^[a-f0-9]{7,40}$/and useescapeShellArg():Severity: HIGH
CWE: CWE-78 (OS Command Injection)
Location:
src/agent/tools.ts— line 511