Skip to content

fix(scanner): rebuild stale escript to prevent silent false negatives#278

Merged
hyperpolymath merged 1 commit into
mainfrom
fix/hypatia-cli-stale-escript-guard
May 18, 2026
Merged

fix(scanner): rebuild stale escript to prevent silent false negatives#278
hyperpolymath merged 1 commit into
mainfrom
fix/hypatia-cli-stale-escript-guard

Conversation

@hyperpolymath
Copy link
Copy Markdown
Owner

Soundness audit finding

hypatia-cli.sh rebuilt the escript only when it was missing, never when it was older than the rule sources ([[ ! -x "${ESCRIPT}" ]]).

Adversarial reproduction

A locally-built hypatia escript dated 2026-05-14 (3 days behind lib/rules/code_safety.ex @ 2026-05-17) was run against known-bad samples:

Sample Result
Idris2 believe_me caught (critical)
Rust .unwrap() caught (high)
curl | bash caught (high)
Elixir System.shell("echo #{user}") 0 findings (false negative)

CodeSafety.scan_content(content, "elixir") flags that sink critical when called directly, and the freshly-rebuilt escript catches all five. The detection engine and the Idris2/Lean proofs are sound — the deployment wrapper was serving a stale artifact that silently dropped the entire Elixir/Erlang/Coq/Lean/Agda/Zig/F*/Ada pattern families.

Fix

Add escript_is_stale(): rebuild when the binary is missing or older than any lib/**.ex(s) / mix.exs. HYPATIA_NO_STALE_REBUILD=1 opts out for air-gapped deploys; warns (does not silently proceed) when stale and mix is unavailable. Logic unit-tested across missing/fresh/stale/opt-out cases.

Refs hyperpolymath/standards#124

🤖 Generated with Claude Code

hypatia-cli.sh only built the escript when it was *missing*, never when
it was *older than the rule sources*. An escript built before a pattern
family was added silently emits zero findings for that whole family.

Adversarially observed: an escript predating the Elixir/Erlang/Coq/Lean/
Agda/Zig pattern sets passed a textbook `System.shell("...#{x}")`
shell-injection sink with "0 findings", while CodeSafety.scan_content/2
flags it critical when called directly. The detection engine is sound;
the deployment wrapper was using a stale artifact.

Add escript_is_stale(): rebuild when the binary is older than any
lib/**.ex(s) or mix.exs. HYPATIA_NO_STALE_REBUILD=1 opts out for
air-gapped deploys shipping a known-current binary. Warns (not silently
proceeds) when stale and mix is unavailable.

Refs hyperpolymath/standards#124

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hyperpolymath hyperpolymath enabled auto-merge (squash) May 18, 2026 19:41
@hyperpolymath hyperpolymath merged commit 65f0912 into main May 18, 2026
1 of 28 checks passed
@hyperpolymath hyperpolymath deleted the fix/hypatia-cli-stale-escript-guard branch May 18, 2026 21:00
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