Skip to content

harden(security-core): fix 7 audit findings — integrity fail-closed, env-strip gaps, supply-chain fail-closed - #101

Merged
thehoff merged 2 commits into
developfrom
harden/security-core-100
May 20, 2026
Merged

thehoff merged 2 commits into
developfrom
harden/security-core-100

Conversation

@thehoff

@thehoff thehoff commented May 20, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes the G1 (security core) findings from the full-codebase audit, issue #100. Codex-reviewed; the one review blocker (root-owned baseline) is fixed.

Findings fixed

Sev Fix
CRITICAL integrity.rs runtime_check() — NoBaseline now fails closed (bail!). A deleted .rtk-hook.sha256 baseline used to let a tampered hook run undetected.
IMPORTANT integrity.rs — new check_baseline_trust(): rejects a baseline that is a symlink, group/world-writable, or owned by a foreign uid. Owner == euid or == root is trusted (root = system-wide install pattern).
IMPORTANT utils.rs secure_git_command — --config-env added to forbidden flags; alias./credential./filter. added to forbidden config-key prefixes (core.* exec keys were already covered — verified).
IMPORTANT utils.rs secure_cargo_command — strips CARGO_ENCODED_RUSTFLAGS (higher-precedence sibling of RUSTFLAGS).
IMPORTANT utils.rs secure_node_command — strips NODE_PATH (module-shadowing vector).
IMPORTANT rewrite_cmd.rs — supply-chain Verdict::Unavailable now downgrades auto-allow to Ask (exit 3), fail-closed, matching Block.
NICE integrity.rs recovery text — rtk init/verify → contextcrawler.

Out of scope (tracked separately under #100)

Test plan

  • cargo test --workspace — 2293 pass, 0 fail (9 new tests: baseline symlink/world-writable/root-owned/foreign-uid, NoBaseline fail-closed, --config-env, alias/credential/filter git keys, NODE_PATH, CARGO_ENCODED_RUSTFLAGS, supply-chain Unavailable→Ask)
  • cargo build --release + clippy clean
  • Codex review — 1 IMPORTANT blocker (root-owned baseline) found and fixed; everything else verified clean

Part of the #100 audit — that issue stays open for groups G2–G8.

🤖 Generated with Claude Code

thehoff and others added 2 commits May 20, 2026 16:34
…in gate (G1 #100)

Fixes the G1 group of the Codex security audit (#100).

integrity: NoBaseline fails CLOSED
  runtime_check() now returns Err on IntegrityStatus::NoBaseline instead
  of silently continuing. A hook with a deleted .rtk-hook.sha256 baseline
  cannot be verified and deleting the baseline is itself a plausible
  tamper step. Error tells the user to re-baseline via `contextcrawler
  init -g --auto-patch`. NotInstalled/Verified paths unchanged.

integrity: baseline-trust guard
  Before trusting the baseline sidecar, verify_hook_at() now rejects a
  symlinked baseline (all platforms) and, on Unix, a baseline that is
  group/world-writable or owned by another uid (MetadataExt + geteuid).
  Scoped fix — the store is not relocated.

integrity: recovery text rebranded
  runtime_check() Tampered recovery output now emits `contextcrawler
  init` / `contextcrawler verify` instead of `rtk ...`.

secure_git_command: arg/config hardening
  --config-env (env-injection RCE flag) added to the forbidden-flag set
  in both exact and prefix forms. Exec-capable config families added to
  the forbidden config-key prefixes: alias., credential., filter.

secure_cargo_command: CARGO_ENCODED_RUSTFLAGS
  Added to FORBIDDEN_CARGO_ENV_EXACT — it is the higher-precedence
  sibling of RUSTFLAGS, so stripping only RUSTFLAGS left a hole.

secure_node_command: NODE_PATH
  Added to NODE_ENV_VARS_EXACT — prepended module-resolution dirs let a
  planted module shadow a real dependency.

supply_chain_gate: fail CLOSED on Unavailable
  rewrite_cmd::run() now downgrades the auto-allow to Ask (exit 3) on
  Verdict::Unavailable, not just Verdict::Block. A registry timeout / OSV
  outage / TOML-parse error no longer waves installs through silently.
  The gate is opt-in, so once enabled it fails closed. Block behaviour
  unchanged.

Tests added for each finding.

Addresses the G1 portion of #100.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Codex review of the G1 hardening: check_baseline_trust rejected any
baseline not owned by the running euid — which breaks the system-wide
install pattern where the baseline is root-owned and a non-root user
legitimately cannot own it. Accept owner == euid OR owner == 0; root
ownership is strictly harder for an unprivileged attacker to forge.
@thehoff
thehoff merged commit 2b0df42 into develop May 20, 2026
4 checks passed
@thehoff
thehoff deleted the harden/security-core-100 branch May 20, 2026 07:36
noogalabs pushed a commit to noogalabs/contextcrawler that referenced this pull request Jun 4, 2026
* feat(docker): add docker compose support with compact output

Add token-optimized output for docker compose commands:
- `docker compose ps`: compact service listing with status and ports
- `docker compose logs`: deduplicated log output via existing log engine
- `docker compose build`: summary with build time, services, and step count
- Unsupported compose subcommands pass through directly

Includes 11 tests (8 compose format tests + 3 for existing compact_ports).

Fixes thehoff#101

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* fix: address PR thehoff#110 review — use --format for compose ps, fix bytes/chars bugs

- Switch format_compose_ps to parse structured --format tab output
  instead of fragile human-readable table (eliminates contains("Up")
  false positives and byte/char confusion)
- Fix find('[') byte offset used with chars().skip() in build parsing
- Use .next_back() instead of .last() on DoubleEndedIterator
- Consistent error handling with .context()? in run_compose_ps
- Strengthen test assertion for compose logs
- Add tests for no-ports and long-image-path cases

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* fix: propagate exit codes on compose failures + remove Vec allocation

Address PR thehoff#110 review feedback from pszymkowiak:
- Check output.status.success() after .output() in run_compose_ps,
  run_compose_logs, and run_compose_build to prevent silent failures
  when Docker daemon is not running
- Replace .collect::<Vec<&str>>().len() with .count() in
  format_compose_build step counting to avoid unnecessary allocation

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* docs: update version references to 0.20.1 after upstream rebase

Sync documentation version strings with Cargo.toml after rebasing
on upstream master. Fixes CI validate-docs check.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* chore: drop upstream workflow file from feature branch

This workflow was pulled in during rebase on upstream master.
Not part of the docker compose feature — let upstream manage it.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* chore: restore validate-docs workflow from upstream

Workflow was unintentionally removed while resolving a push
permission issue. Restored to match upstream master.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

---------

Co-authored-by: Claude Opus 4.6 <[email protected]>
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