Skip to content

fix: cap WebAuthn key_id at 1023 bytes at registration - #121

Open
alberto-crossmint wants to merge 1 commit into
mainfrom
fix/webauthn-keyid-maxlen
Open

fix: cap WebAuthn key_id at 1023 bytes at registration#121
alberto-crossmint wants to merge 1 commit into
mainfrom
fix/webauthn-keyid-maxlen

Conversation

@alberto-crossmint

Copy link
Copy Markdown
Collaborator

Summary

WebauthnSigner.key_id is typed as unbounded soroban_sdk::Bytes. Nothing in add_signer / update_signer enforced a length cap, so a caller could register a credential ID of arbitrary size. That inflates:

  • Persistent storage rent for the signer entry (size-proportional fee).
  • Signature proof payloads on every __check_auth, since SignerProof::Webauthn carries the key_id-indexed map entry.

The FIDO2/CTAP2 spec caps CredentialID at 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_signer and update_signer), surfacing InvalidPolicy for anything over 1023 bytes.

Test plan

  • New test_webauthn_oversize_key_id_rejected — 1024-byte key_idErr(InvalidPolicy).
  • New test_webauthn_max_size_key_id_accepted — exactly 1023 bytes → accepted.
  • Full suite: 128 passed, 0 failed (2 new tests; no existing test uses an oversize key_id).

Risk

Minimal. All observed WebauthnSigner uses in this repo have short key_id values (test fixtures use 18 bytes, migration tests preserve v1 values which were similarly short). If a production account somehow holds a >1023-byte key_id, __check_auth is unaffected — only future add_signer/update_signer calls are gated.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant