fix: cap WebAuthn key_id at 1023 bytes at registration - #121
Open
alberto-crossmint wants to merge 1 commit into
Open
fix: cap WebAuthn key_id at 1023 bytes at registration#121alberto-crossmint wants to merge 1 commit into
alberto-crossmint wants to merge 1 commit into
Conversation
WebauthnSigner.key_id is declared as unbounded `Bytes`, so an arbitrary caller could register a signer whose credential ID is megabytes long. Persistent storage rent scales with entry size, signature proof payloads grow accordingly, and real-world WebAuthn CredentialIDs fit comfortably under the FIDO2/CTAP2 cap of 1023 bytes — typically ≤ 128 bytes. Reject add_signer / update_signer when the Webauthn key_id exceeds 1023 bytes, using the existing InvalidPolicy error code.
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
WebauthnSigner.key_idis typed as unboundedsoroban_sdk::Bytes. Nothing inadd_signer/update_signerenforced a length cap, so a caller could register a credential ID of arbitrary size. That inflates:__check_auth, sinceSignerProof::Webauthncarries thekey_id-indexed map entry.The FIDO2/CTAP2 spec caps
CredentialIDat 1023 bytes, and real-world authenticators produce IDs well under that (typically ≤ 128). There is no legitimate reason to exceed the cap.This PR adds a single bounds check at signer registration (
add_signerandupdate_signer), surfacingInvalidPolicyfor anything over 1023 bytes.Test plan
test_webauthn_oversize_key_id_rejected— 1024-bytekey_id→Err(InvalidPolicy).test_webauthn_max_size_key_id_accepted— exactly 1023 bytes → accepted.Risk
Minimal. All observed
WebauthnSigneruses in this repo have shortkey_idvalues (test fixtures use 18 bytes, migration tests preserve v1 values which were similarly short). If a production account somehow holds a >1023-bytekey_id,__check_authis unaffected — only futureadd_signer/update_signercalls are gated.