fix(test): make the ciphertext-tamper test deterministic - #302
Merged
telivity-otaip merged 1 commit intoAug 11, 2026
Merged
Conversation
replace(/a/g,'b') on random hex ciphertext is a no-op whenever it contains no
'a' — the blob arrives untampered and the test fails claiming fail-closed is
broken. Flipping to uppercase 'A' has the same bug (hex 'A'==='a'). Change the
first hex DIGIT ('0'<->'1') instead: distinct nibble values, bytes always
change, verified across all 16 possible first digits.
modernitconsultants
force-pushed
the
fix/deterministic-tamper-test
branch
from
August 11, 2026 12:10
e90a47c to
27b4f07
Compare
telivity-otaip
approved these changes
Aug 11, 2026
telivity-otaip
left a comment
Collaborator
There was a problem hiding this comment.
Nice catch on the flaky tamper — replace(/a/g,'b') is a no-op when the hex has no a. Deterministic first-nibble flip is exactly right. Thank you, Charles — merging.
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.
`credential-encryption.spec.ts` › "fails closed when ciphertext is tampered" is probabilistically flaky: it tampers with `blob.ciphertext.replace(/a/g, 'b')`, and whenever the random ciphertext contains no `a`, the replacement is a no-op — the blob arrives untampered, decryption rightly succeeds, and the test fails claiming fail-closed is broken.
Hit tonight in our CI: `1 failed | 1411 passed` on a branch touching none of this code, with the identical tree passing minutes earlier.
Fix: flip the first character to a guaranteed-different one. Same intent, zero probability.
(The auth-tag test above it is already deterministic — `'0'.repeat(...)` can collide with an all-zero tag only with negligible probability, so left alone.)