fix: fail closed on invalid score evidence - #139
Open
darcszn wants to merge 1 commit into
Open
Conversation
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.
Summary
This PR closes a failure mode in the destination-risk review path: invalid, missing, or out-of-range risk evidence could be treated as a valid low-risk score instead of a degraded/unknown state. This was a security-sensitive issue because the extension is designed to fail closed when evidence is unavailable or untrusted.
The fix enforces a strict contract for risk scores and ensures that any malformed or unavailable oracle result is never presented as “safe.” In practice, this prevents the UI and signing review flow from silently converting degraded evidence into a low-risk destination.
Root cause
The risk tiering logic and legacy score flow were still allowing sentinel and invalid numeric values to pass as legitimate results:
-1NaN0..100Those values were either being passed through as scores or normalized into low-risk buckets, which undermined the fail-closed model. The result was that a missing or malformed oracle response could look like a safe destination rather than an unknown or unavailable assessment.
What was changed
1) Strict score validation and fail-closed tier policy
0and100are accepted as scored results.This change was applied in the shared tiering logic and in the review outcome path so the behavior is consistent across the extension.
2) Review path no longer interprets invalid evidence as low risk
3) Protection status degrades correctly when health checks are unavailable
4) Regression coverage for the real issue
Why this matters
This is a safety boundary. A destination should never be presented as low risk when the evidence is malformed, unavailable, stale, or otherwise untrusted. The extension is intended to review security-sensitive transactions conservatively, so failing closed is the correct behavior when risk evidence cannot be trusted.
Validation
This change was verified with the project’s required checks:
npx vitest run --reporter=basicnpm run lintnpm run buildAll passed.
closes #125