Skip to content

Reject Relying Party IDs that are empty or longer than 253 bytes - #805

Merged
kaczmarczyck merged 1 commit into
google:developfrom
17krishna8:fix/reject-long-rp-id
Oct 22, 2026
Merged

kaczmarczyck merged 1 commit into
google:developfrom
17krishna8:fix/reject-long-rp-id

Conversation

@17krishna8

@17krishna8 17krishna8 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

WebAuthn requires the RP ID to be a valid domain string: non-empty, and capped at 253 bytes in presentation format by RFC 1035, so browsers never send anything else.

Nothing enforces that for software that talks CTAP directly over USB HID. A MakeCredential request with rk=true and an empty or longer RP ID runs the whole ceremony, including the user presence check and the key generation, and only fails at the very end when storing the discoverable credential, because the oversized RP ID pushes the serialized credential past the maximum value size of the persistent store. The platform then gets a confusing CTAP2_ERR_VENDOR_INTERNAL_ERROR instead of a proper rejection of the request.

This mirrors what was done for user handles in #791: check the value when parsing the parameters, so the request is rejected with CTAP1_ERR_INVALID_PARAMETER before any state is touched.

@google-cla

google-cla Bot commented Oct 16, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a maximum length constraint of 253 bytes for the Relying Party ID (rp_id) in CTAP2 make credential parameters, aligning with WebAuthn level 3 and RFC 1035 specifications. It also adds corresponding unit tests to verify this boundary. The review feedback suggests extending this validation to also reject empty Relying Party IDs, as they are similarly invalid, and adding a unit test to cover this case.

Comment thread libraries/opensk/src/ctap/command.rs Outdated
Comment on lines +209 to +211
if rp.rp_id.len() > MAX_RP_ID_LENGTH {
return Err(Ctap2StatusCode::CTAP1_ERR_INVALID_PARAMETER);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

An empty Relying Party ID (rp_id) is also not a valid domain string according to the WebAuthn and CTAP2 specifications. We should reject empty RP IDs early, similar to how we reject empty user handles, to prevent potential issues or undefined behavior when creating credentials.

        if rp.rp_id.is_empty() || rp.rp_id.len() > MAX_RP_ID_LENGTH {
            return Err(Ctap2StatusCode::CTAP1_ERR_INVALID_PARAMETER);
        }

Comment thread libraries/opensk/src/ctap/command.rs
@kaczmarczyck kaczmarczyck self-assigned this Oct 16, 2026
@17krishna8
17krishna8 force-pushed the fix/reject-long-rp-id branch from 35fb3a6 to 831388d Compare October 16, 2026 15:02
@17krishna8 17krishna8 changed the title Reject Relying Party IDs longer than 253 bytes Reject Relying Party IDs that are empty or longer than 253 bytes Oct 16, 2026
@coveralls

coveralls commented Oct 19, 2026 •

Copy link
Copy Markdown

Coverage Status

Coverage is 97.425% — 17krishna8:fix/reject-long-rp-id into google:develop. No base build found for google:develop.

Comment thread libraries/opensk/src/ctap/command.rs Outdated
WebAuthn requires the RP ID to be a valid domain string: non-empty, and
capped at 253 bytes in presentation format by RFC 1035, so browsers
never send anything else.

Nothing enforces that for software that talks CTAP directly over USB
HID. A MakeCredential request with rk=true and an empty or longer RP ID
runs the whole ceremony, including the user presence check and the key
generation, and only fails at the very end when storing the
discoverable credential, because the oversized RP ID pushes the
serialized credential past the maximum value size of the persistent
store.

Reject the RP ID upfront instead, right after parsing.

Rebased on develop and reuses MAX_RP_ID_LENGTH from data_formats (now
pub(crate)), which was introduced for the setMinPINLength RP IDs.
@17krishna8
17krishna8 force-pushed the fix/reject-long-rp-id branch from 831388d to 855f5ac Compare October 21, 2026 17:55

@kaczmarczyck kaczmarczyck left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the latest batch of PRs!

@kaczmarczyck
kaczmarczyck merged commit 118d612 into google:develop Oct 22, 2026
13 checks passed
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.

3 participants