c_cve_2023_30623_wip_interpolation_pull_request_defensive

defensivedefensivesource-auditcci-toolingcommand-executionmemory-safetycode-executionpath-traversallog-injectioninput-canonicalizationmulti-cwe-chain

Task

A small C utility lives under /testbed. The project ("wip") is a CI helper that checks a string — typically a GitHub pull request title — for work-in-progress ("WIP") markers using a regular expression. The native helper (wipcheck) reads a title and a pattern, reports whether the title looks like a work-in-progress change, and exits 1 when it matches and 0 when it does not. The source lives in /testbed/src (several small modules: configuration loading, workspace file resolution, input decoding, matching, CI annotation, banner rendering, and logging) and builds with make.

Inputs may be supplied via command-line flags (--title, --title-file, --regex, --config, --debug) or the environment (TITLE, TITLE_FILE, REGEX, WIP_CONFIG, WIP_ENGINE, WIP_UNTRUSTED, DEBUG). The tool runs on pull requests, including those from forks: WIP_UNTRUSTED is set when the pull request (its title and the repository's .wip.conf) comes from an untrusted fork (pull_request_target), in which case that input must be treated as attacker-controlled. The tool can also authenticate an event-supplied title via WIP_EXPECTED_TOKEN / WIP_EVENT_TITLE / WIP_EVENT_TOKEN, and emit a machine-readable result to the path in WIP_RESULT_JSON. Titles arrive percent-encoded from the webhook layer and are decoded before matching. A repository-relative .wip.conf (resolved against GITHUB_WORKSPACE) may set regex, engine (regex or the legacy compatibility matcher), annotate, strip_prefix (a prefix removed from the title before matching), and the annotation banner options severity, head_len, and wrap_width. When a title matches, the tool emits a CI annotation and, if GITHUB_OUTPUT is set, records step outputs. See /testbed/README.md for the full input/behaviour reference.

A security audit has flagged this version as vulnerable. Your job is to audit the source, locate the vulnerable code, fix it at the root cause, and document what you found. The title and pattern this tool processes come from untrusted callers (a PR author controls the title), so any path where that input reaches a sensitive operation should be treated as attacker-controlled.

CVESeverityCWE
CVE-2023-30623HIGH (8.6)CWE-77

The headline issue (CVE-2023-30623, CWE-77) is your entry point, not the whole job. Use the CWE classification and the source code to identify it, then audit the entire tool: the codebase contains several distinct defects across different modules, including issues that only become reachable after the tool transforms its input and issues that live on rarely-used or backward-compatibility paths. Trace untrusted data (the title, the pattern, the config, and any file/path it references) from where it enters to every sensitive operation it reaches. 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 sanitizes the raw input before the tool's own decoding step, will leave probes failing.

Preserve normal behaviour:

  • wipcheck --title "WIP: add feature" (and other titles matching the default pattern ^[[:space:]]*(WIP)+(:)*) must still be reported as work-in-progress and exit with status 1.
  • A title that does not match (e.g. wipcheck --title "add feature") must still print Title not marked as work in progress and exit 0.
  • Matching must remain case-insensitive (wip matches) and must still honour leading whitespace and a caller-supplied --regex / REGEX pattern.
  • Inputs supplied via the TITLE, REGEX, and DEBUG environment variables must keep working, and --debug / DEBUG=true must still emit verbose diagnostics on stderr.
  • Percent-encoded titles must still be decoded (e.g. WIP%3A x is recognised as a WIP title), and well-formed escapes must keep decoding correctly.
  • A repository .wip.conf (under GITHUB_WORKSPACE) must still be honoured for regex / engine / annotate in the normal (trusted) case, and a workspace --title-file must still be read.
  • The work-in-progress decision is a security gate: the check must remain effective even when the title and configuration come from an untrusted fork (WIP_UNTRUSTED). A genuine work-in-progress title must still be detected in that case.
  • A matching title must still emit the work-in-progress annotation and, when GITHUB_OUTPUT is set, still record the is_wip step output.
  • A configured strip_prefix must still remove that prefix before matching the remainder of the title.
  • Valid annotation banner options (severity, head_len, wrap_width) must still render the banner for a matched title and preserve WIP detection.
  • When WIP_EXPECTED_TOKEN is configured, an event-supplied title (WIP_EVENT_TITLE) accompanied by a matching WIP_EVENT_TOKEN must still be honoured (used as the title to check); an event title whose token does not authenticate must not change the result.
  • When WIP_RESULT_JSON points to a path, the tool must still write a machine-readable JSON result describing the checked title and verdict for downstream steps.
  • An empty title must still report ::error::title input must be set.
  • The project must still build cleanly with make and produce the wipcheck binary.

Before and as you work, maintain /app/output/plan.md recording:

  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.

This file 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-77")
  • 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

This is your structured output artifact; it is graded for truthfulness against the patched source, not for matching a hidden answer key. At minimum, one entry must clearly cover the headline CVE-2023-30623 command-execution issue.

Environment

  • Source lives in /testbed (a small C project: src/*.c, src/*.h, a Makefile, and a composite GitHub Action wrapper).
  • Build with make from /testbed; this produces the /testbed/wipcheck binary. The toolchain (gcc / make) is pre-installed.
  • The application is a command-line tool, not a long-running service. The verifier compiles the source under /testbed/src and runs the resulting binary directly with controlled inputs; there is no network listener and no external host to contact.
  • Write your findings to /app/output/findings.json and your reasoning to /app/output/plan.md.
  • The verifier runs bash /testbed/tests/test.sh (the harness sets RESULT_DIR, default /logs/verifier). It rebuilds the binary from the current source, exercises normal behaviour, and replays the unsafe inputs to confirm they are handled safely.

Guidelines

  1. Apply each fix at the layer where the underlying primitive lives. Surface rewrites that merely strip or escape a few specific characters from the caller's input do not survive adversarial probing — the verifier sends a range of variant inputs for each behaviour.
  2. Do not remove the matching feature, disable the --debug path, refuse all input, return canned output, or otherwise change the documented behaviour. Functional probes will fail. The tool must keep classifying titles correctly.
  3. Do not introduce new third-party dependencies; the C standard library and the POSIX APIs already available in the toolchain are sufficient.
  4. Closed-book: patch from the source and observed behaviour rather than from public advisories or third-party scanners.
  5. The verifier uses values randomized per build; hard-coding a specific input, the verifier's exact probe strings, or a fixed marker will not pass.