Security & Safety Hardening (GitHub Issue #149)
Comprehensive response to the TheDecipherist adversarial security review comparing lean-ctx vs RTK across 16 safety-critical scenarios. The review was conducted against v3.2.5 — many findings were already fixed in 3.3.x, and v3.3.9 addresses the remaining gaps.
Already Fixed (confirmed with adversarial tests since v3.3.x)
git diffcode content:compress_diff_keep_hunks()preserves all+/-changed lines, only trims context to max 3 lines per hunkdfroot filesystem: Verbatim passthrough — no compression applied todfoutputpytestxfail/xpass: Summary explicitly includesxfailed,xpassed,skipped, andwarningscountersgit statusDETACHED HEAD: Passes through verbatim including "HEAD detached at" warninglsshows.env: No file filtering — all files including.envare shownpip listall packages: Full package list preserved — no truncationgit stashverbatim: Passes git stash output through unchangedrufffile:line:col: Preserves all location references in linter outputfindfull paths: Preserves complete absolute pathswcvia pipe: Correctly reads stdin (piped input)- Log
CRITICAL/FATALseverity:log_dedupandsafety_needlesexplicitly recognize and preserve CRITICAL, FATAL, ALERT, EMERGENCY severity levels
Fixed in v3.3.9
git showdiff content (CRITICAL):compress_show()now preserves full diff content usingcompress_diff_keep_hunks()instead of reducing tohash message +N/-M. Code review viagit showis now safe.docker pshealth status (CRITICAL): Added fallback detection for(unhealthy),(healthy),(health: starting), andExited(N)annotations that survive even when column-based parsing misaligns.git logdefault cap (HIGH): Increased from 50 to 100 entries (was ~20 in v3.2.5). With explicit-n/--max-count, no limit is applied. Truncation message clearly indicates omitted count.
New Adversarial Tests
adversarial_git_show_preserves_diff_content— verifies code changes survivegit showadversarial_git_show_preserves_security_change— verifies security-relevant removals (e.g. CSRF) are visibleadversarial_docker_ps_unhealthy_narrow_columns— verifies health status survives tight column layoutsadversarial_docker_ps_exited_containers— verifies crashed containers are shownadversarial_git_log_100_plus_commits— verifies 100-entry cap and truncation messageadversarial_git_log_explicit_limit_unlimited— verifies-nbypasses default capadversarial_safeguard_ratio_prevents_over_compression— verifies safety net prevents >85% compressionadversarial_shell_hook_preserves_errors_in_truncation— verifies CRITICAL/ERROR lines survive shell hook truncation
Dependency Security
- rustls-webpki: Confirmed already on patched version 0.103.13 (GHSA-82j2-j2ch-gfr8, DoS via panic on malformed CRL BIT STRING)
Upgrade
lean-ctx update # recommended (auto-downloads + refreshes shell hooks)
cargo install lean-ctx # or
npm update -g lean-ctx-bin # or
brew upgrade lean-ctxNote: After upgrading via cargo/npm/brew, run
lean-ctx setupto refresh shell aliases.lean-ctx updatedoes this automatically.
Full Changelog: v3.3.9...v3.3.9