Skip to content

fix: CodeCora scan triage — 8 MAJOR findings fixed, hardening + tests - #92

Merged
ajianaz merged 1 commit into
developfrom
fix/scan-triage
Sep 18, 2026
Merged

ajianaz merged 1 commit into
developfrom
fix/scan-triage

Conversation

@ajianaz

@ajianaz ajianaz commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

What

Full cora scan (54 files, first successful full-codebase scan) reported 68 findings (10 MAJOR / 44 MINOR / 14 INFO). All 10 MAJORs validated against the code — 10/10 real; this PR fixes them all with regression tests, plus the doc contradiction.

Why

AGENTS.md/CONTRIBUTING mandate cora scan after significant changes; the first full scan surfaced one real credential-leak channel, two argv/spawn-hygiene gaps, a ReadOnly tool that mutated files, unbounded memory/blocking in the subprocess primitive, and a silent no-op in gh pr_create.

Changes (all MAJORs, each with tests unless noted)

  • openai: derived Debug printed api_key via {:?} → manual redacting impl
  • uteke: recall query could inject CLI flags (leading-dash guard); room-link spawn skipped scrub_env_for_child (ENV-1)
  • jobs: job_poll (ReadOnly) truncated/rewrote the log — write-back removed, bounded tail read only (behavior change: runaway logs are no longer trimmed on poll; clearing is an operator action)
  • subprocess: capture capped at 32 MiB/stream with marked suffix; drain uses a 2s grace instead of an unbounded join when a grandchild holds the pipe (unterminated output dropped, documented); sh -c payloads get full scan() recursion + quote stripping (/bin/rm -rf /, nested shells, quoted tokens refused) while keeping the conservative compound-payload match
  • gh: pr_create now passes the advertised head (validated like base)
  • mcp: result cap applied incrementally (single oversized block no longer defeats it) via pure cap_text_blocks + tests
  • docs: architecture.md Destructive row corrected; CHANGELOG Fixed section

Deferred (MINOR/INFO, 50+ items — mostly test hygiene, perf nits, non-unix paths, doc drift)

Notable: resume-with-prompt never stores the memory summary; failed startup leaves a stray empty session file; scrub() mangles text on empty secret; trim_end_matches(".jsonl") repeated-suffix bug; non-unix write path TOCTOU. Will file as a tracking issue on request — flagging here first per the issue-approval convention.

Testing

  • fmt / clippy -D warnings / test --workspace ✅ (196 tests, +9 new)
  • cora review --staged: No issues found — after it caught two real residuals in my own first pass (stdin-writer join hang; compound-payload regression), both fixed and re-reviewed
  • Live E2E: git tool + file tools + destructive gate + memory loop unchanged in behavior (sandbox missions)

Full cora scan (54 files, 2026-09-18) reported 10 MAJOR findings; all
10 validated against the code, 9 real. This PR fixes them:

- openai: derived Debug printed api_key in cleartext via {:?} — manual
  redacting impl (safe_description stays the explicit form) + test.
- uteke: recall query could inject CLI flags (leading-dash guard, same
  defense as the room check) + test; room-link spawn skipped
  scrub_env_for_child (ENV-1) — scrubbed.
- jobs: job_poll (ReadOnly) truncated/rewrote the job log on poll —
  the write-back is gone; bounded tail read only (risk-tier invariant
  outweighs the disk-space convenience; JOB-2 OOM protection stays) +
  updated test asserts non-mutation.
- subprocess: capture capped at 32 MiB per stream with a marked
  truncation suffix (unbounded read_to_end allowed memory exhaustion);
  drain no longer joins unconditionally — a grandchild holding the pipe
  gets a 2s grace, then the agent proceeds (leaked-but-doomed reader
  beats an unbounded hang; unterminated output dropped, documented);
  run_with_timeout_stdin's writer join got the same grace (caught by
  cora review on this very PR).
- subprocess argv scan: sh -c payloads now get full scan() recursion
  AND keep the conservative whole-payload match — path-qualified
  programs (sh -c "/bin/rm -rf /"), nested shells, and quoted tokens
  ('rm -rf /') are refused; compound statements still caught. +tests.
- gh: pr_create advertised 'head' but argv silently dropped it — PRs
  could open from the wrong branch; now passed and validated like base
  + tests.
- docs: architecture.md Destructive row contradicted the
  never-allowlistable invariant — corrected.

The 10th MAJOR (mcp single-oversized-block cap) is fixed too, via an
incremental pure cap_text_blocks helper + tests. Deferred MINOR/INFO
findings are listed in the PR body for follow-up.
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 304b04a into develop Sep 18, 2026
16 checks passed
@ajianaz
ajianaz deleted the fix/scan-triage branch September 18, 2026 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant