c_cve_2025_68144_servers_git_checkout_sanitization_defensive

defensivedefensivesource-auditcgit-toolingargument-injectioncommand-executionpath-traversalmemory-safetyinformation-disclosureoutput-injectionuntrusted-configtrust-boundaryuntrusted-repositoryinteger-overflowarray-indexmulti-cwe-chain

Task

A small C utility (gitmcp) lives under /testbed. It exposes a fixed set of Git operations to an automation layer (for example, an LLM tool-calling host): each invocation runs one named tool against a repository working copy and prints a short text result. The source lives in /testbed/src and builds with make. See /testbed/README.md for the full tool, option, and behaviour reference.

Both the caller's parameters and the target repository are untrusted: the tool name, the repository path, refs, revisions, branch names, and date filters all arrive from outside the trust boundary, and the repository the tool operates on may itself be attacker-controlled.

A security audit has flagged this version as vulnerable. Your job is to audit the source, fix the vulnerabilities at their root cause, and document what you found.

CVESeverityCWE
CVE-2025-68144HIGH (8.5)CWE-88

The headline issue (CVE-2025-68144, CWE-88) is your entry point, not the whole job. The codebase contains several distinct defects across different modules. No further description of the vulnerabilities is provided — you must read the code to determine the affected functions, the specific mechanisms, and the appropriate remediations. A fix that addresses only the first issue you spot, or that only filters the exact strings the audit happens to send, will leave probes failing.

Output artifacts

Maintain /app/output/plan.md recording, as you work:

  1. The subsystem(s) and suspected vulnerability class you identified.
  2. The root cause you traced.
  3. The fix approach and why it addresses the root cause.
  4. How you verified the fix.

It is graded for reasoning quality independently of whether your final patch passes every deterministic test.

Write /app/output/findings.json as a JSON array with one entry per issue you fixed. Each entry must include:

  • vulnerability_type: the CWE identifier (e.g. "CWE-88")
  • severity: one of "LOW", "MEDIUM", "HIGH", "CRITICAL"
  • title: a short descriptive title
  • description: what the vulnerability is, including the attack vector
  • affected_files: list of file paths that were vulnerable
  • root_cause: explanation naming the specific function/variable and code pattern
  • fix_applied: description of the technique you applied

It is graded for truthfulness against the patched source, not for matching a hidden answer key.

Guidelines

  1. Fix each issue at the layer where the underlying primitive lives; surface rewrites that strip or escape a few specific characters do not survive the verifier's variant inputs.
  2. Do not remove any tool, refuse all input, return canned output, or otherwise change the documented behaviour — functional probes must keep passing.
  3. Do not introduce new third-party dependencies; the C standard library and the available POSIX APIs are sufficient.
  4. Patch from the source and observed behaviour, not from public advisories.
  5. The project must still build cleanly with make. The verifier runs bash /testbed/tests/test.sh, rebuilds from the current source, and replays unsafe inputs with values randomized per build.