8000 Enforce attested_keys[0] for OID4VCI proof validation by Awambeng · Pull Request #53476 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Enforce attested_keys[0] for OID4VCI proof validation - #53476

Open
Awambeng wants to merge 2 commits into
keycloak:mainfrom
adorsys:issue-52786
Open

Awambeng wants to merge 2 commits into
keycloak:mainfrom
adorsys:issue-52786

Conversation

@Awambeng
@Awambeng Awambeng commented Oct 2, 2026
Copy link
Copy Markdown
Contributor

This PR adds support for the ETSI TS 119 472-3 requirement that the proof signing key must be the first key in attested_keys for OID4VCI JWT proofs.

Key changes:

  • Add vc.key_attestation.proof_key_index to credential configuration. When set to 0, the proof signing key must be attested_keys[0].
  • Keep the existing membership check when the option is not set, so existing configurations continue to work.
  • Validate the option when parsing the credential configuration. (Only 0 or unset is accepted).
  • Add typed getter/setter support in the credential scope model and admin REST representation.
  • Extract the key attestation validation into a separate method and improve the error message to show where the key was actually found.
  • Add unit tests for the validation logic and integration tests for configuration parsing and backwards compatibility.

Closes #52786

Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The implementation is backward compatible, correctly validated, and adequately tested.

Review effort: Balanced
Findings: None

What changed in this PR

Adds optional ETSI-compliant enforcement that JWT proof keys occupy attested_keys[0], while preserving existing membership validation by default.

Changes:

  • Adds and validates the proof-key-index credential setting.
  • Enforces positional proof-key validation with clearer errors.
  • Adds unit and integration coverage for enforcement and compatibility.
File Description
CredentialScopeModel.java Adds the typed configuration attribute.
CredentialScopeRepresentation.java Exposes typed representation accessors.
SupportedCredentialConfiguration.java Parses and validates the configured index.
JwtProofValidator.java Enforces membership or index-zero matching.
JwtProofValidatorTest.java Tests positional and backward-compatible validation.
OID4VCKeyAttestationTest.java Tests configuration parsing and integrated enforcement.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI balanced review requested due to automatic review settings October 29, 2026 08:09
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Admin create/update accepts invalid proof-key index values that can later abort issuer discovery for the entire realm, so validation must reject them with HTTP 400 before persistence.

1 open issue

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 29, 2026 11:04
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unicode-whitespace proof key index values can be persisted and trigger NumberFormatException, breaking realm issuer discovery instead of being rejected with HTTP 400.

1 open issue
1 resolved since last review

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 29, 2026 11:43
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues block the opt-in requirement for the proof-signing key to appear first in the attested keys.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@dominikschlosser dominikschlosser left a comment •
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, the index check looks correct and the default behaviour is unchanged. Fine to merge as is. Two follow-ups:

1. Bind all attested keys. ETSI TS 119 472-3 (CRED-REQ-PROC-4.6.2.1-04) requires one credential per entry in attested_keys, and OpenID4VCI 1.0 F.1 recommends the same. ETSI also allows only one JWT proof. With this option on, a wallet therefore gets a single credential instead of a batch. The attestation proof type already returns all attested keys, and the JWT proof could do the same.

2. kid as an index. The example of a JWT proof with a key attestation in OpenID4VCI 1.0 F.1 has the header "kid": "0" and no jwk. The attested keys in the example in Appendix D.1 have no kid, so "0" refers to the position in attested_keys. The EUDI reference wallet sends exactly this. Keycloak looks for an attested key whose kid is "0" and rejects the proof before the index check runs. Reading kid as the position in attested_keys when a key attestation is present would fix this.

@Awambeng
Awambeng commented Nov 4, 2026
Copy link
Copy Markdown
Contributor Auth 10BC8 or

Thanks, the index check looks correct and the default behaviour is unchanged. Fine to merge as is. Two follow-ups:

1. Bind all attested keys. ETSI TS 119 472-3 (CRED-REQ-PROC-4.6.2.1-04) requires one credential per entry in attested_keys, and OpenID4VCI 1.0 F.1 recommends the same. ETSI also allows only one JWT proof. With this option on, a wallet therefore gets a single credential instead of a batch. The attestation proof type already returns all attested keys, and the JWT proof could do the same.

2. kid as an index. The example of a JWT proof with a key attestation in OpenID4VCI 1.0 F.1 has the header "kid": "0" and no jwk. The attested keys in the example in Appendix D.1 have no kid, so "0" refers to the position in attested_keys. The EUDI reference wallet sends exactly this. Keycloak looks for an attested key whose kid is "0" and rejects the proof before the index check runs. Reading kid as the position in attested_keys when a key attestation is present would fix this.

Thanks for the review, @dominikschlosser. I'll open a follow-up ticket to address your comments.

- Add vc.key_attestation.proof_key_index to allow a credential configuration
to require the proof signing key to be attested_keys[0], as required by
ETSI TS 119 472-3 and Regulation (EU) 2026/1731.

- If the option is not set, the existing membership check is kept for
backwards compatibility.

Closes keycloak#52786

Signed-off-by: Awambeng Rodrick <awambengrodrick@gmail.com>
Signed-off-by: Awambeng Rodrick <awambengrodrick@gmail.com>
Copilot AI balanced review requested due to automatic review settings November 4, 2026 10:43
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the opt-in JWT proof key-position setting.

No open issues 🎉

Review effort: Balanced

@Awambeng
Awambeng commented Nov 4, 2026
Copy link
Copy Markdown
Contributor Author

Follow-up ticket created: #54634

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[OID4VCI] Option to require the proof signing key to be attested_keys[0] (ETSI TS 119 472-3 / EUDI profile) — JwtProofValidator only checks membership

3 participants

0