Conversation
The old test_creds_are_tamper_resistant could not have caught the credential HMAC coverage bug fixed in eb2e0d1 ("HMAC over entire credential"): it passed as long as one of five mutations per byte was rejected, and silently ignored accepted forgeries. Mutations in the unauthenticated region were still rejected ~99% of the time anyway, because CBC decryption garbles the credProtect byte, which then fails policy checks - indistinguishable from MAC rejection at the CTAP level. Rewrite the test to: - fail immediately if any mutated credential is accepted - flip every single bit of every byte (the old mod-128 mutation never touched the high bit), plus random nonzero XOR masks - run 32 mutations per byte instead of 5 Since a black-box client cannot distinguish MAC rejection from policy-check rejection, detection remains statistical: each mutation of an unauthenticated byte is accepted with probability ~1/128, so with 32 mutations over a 14-byte gap the miss probability is about 3%. Comments in the test document this and warn against adding pinAuth or making the credential discoverable, both of which would weaken detection. Verified by temporarily reverting the applet to the pre-eb2e0d1 HMAC length: the new test fails with a forgery accepted at byte 85, inside the formerly unauthenticated region (bytes 82-95). It passes against the fixed applet.
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.
The old test_creds_are_tamper_resistant could not have caught the credential HMAC coverage bug fixed in eb2e0d1 ("HMAC over entire credential"): it passed as long as one of five mutations per byte was rejected, and silently ignored accepted forgeries. Mutations in the unauthenticated region were still rejected ~99% of the time anyway, because CBC decryption garbles the credProtect byte, which then fails policy checks - indistinguishable from MAC rejection at the CTAP level.
Rewrite the test to:
Since a black-box client cannot distinguish MAC rejection from policy-check rejection, detection remains statistical: each mutation of an unauthenticated byte is accepted with probability ~1/128, so with 32 mutations over a 14-byte gap the miss probability is about 3%. Comments in the test document this and warn against adding pinAuth or making the credential discoverable, both of which would weaken detection.
Verified by temporarily reverting the applet to the pre-eb2e0d1 HMAC length: the new test fails with a forgery accepted at byte 85, inside the formerly unauthenticated region (bytes 82-95). It passes against the fixed applet.