fix(scanner): rebuild stale escript to prevent silent false negatives#278
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Soundness audit finding
hypatia-cli.shrebuilt the escript only when it was missing, never when it was older than the rule sources ([[ ! -x "${ESCRIPT}" ]]).Adversarial reproduction
A locally-built
hypatiaescript dated 2026-05-14 (3 days behindlib/rules/code_safety.ex@ 2026-05-17) was run against known-bad samples:believe_me.unwrap()curl | bashSystem.shell("echo #{user}")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 anylib/**.ex(s)/mix.exs.HYPATIA_NO_STALE_REBUILD=1opts out for air-gapped deploys; warns (does not silently proceed) when stale andmixis unavailable. Logic unit-tested across missing/fresh/stale/opt-out cases.Refs hyperpolymath/standards#124
🤖 Generated with Claude Code