openai / openai/codex-plugin-cc

Stop review gate fails open when hook stdin is malformed JSON

Open Beginner friendly
#676 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
33.3k
Forks
2.3k
PR merge metrics
No merged PRs in 30d

Description

Description

stop-review-gate-hook.mjs parses hook stdin before entering the review-gate logic. A malformed non-empty JSON payload throws an uncaught SyntaxError, exits with status 1, and emits no decision: "block" response. When the host treats a crashed Stop hook as having supplied no block decision, the review gate can fail open.

Reproduction

With plugin 1.0.2:

printf '%s' '{not-json' | node scripts/stop-review-gate-hook.mjs

Observed result:

SyntaxError: Expected property name or '}' in JSON at position 1
    at JSON.parse
    at readHookInput (.../stop-review-gate-hook.mjs:26:15)
    at main (.../stop-review-gate-hook.mjs:143:17)

The process exits 1 without emitting hook JSON.

Root cause

readHookInput() calls JSON.parse(raw) without a catch, and main() calls readHookInput() before any fail-closed handling:

function readHookInput() {
  const raw = fs.readFileSync(0, "utf8").trim();
  if (!raw) return {};
  return JSON.parse(raw);
}

Expected behavior

Any failure to read or parse Stop-hook input should emit a valid fail-closed response, for example:

{"decision":"block","reason":"The stop review gate could not parse hook input; refusing to fail open."}

A regression test should feed malformed non-empty stdin and assert exit 0 plus a valid decision: "block" payload.

Related

  • #120 reports a separate readHookInput() failure mode (EAGAIN). The malformed-JSON case is deterministic and specifically requires fail-closed Stop-gate behavior.

Environment

  • Codex plugin: 1.0.2
  • Claude Code: 2.1.241
  • Node.js: 24.17.0
  • OS: WSL2 / Linux

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with scripts/stop-review-gate-hook.mjs and reproduce the issue using the provided printf and node command. Trace readHookInput() into main(), then add a regression test that feeds malformed non-empty stdin and verifies exit 0 with a valid decision: "block" response. Done means malformed input cannot make the Stop hook fail open.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
88/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.