Skip to content

fix(sdk): DSPX-1561 verify assertion bindings only with the selected key - #4303

Open
dmihalcik-virtru wants to merge 1 commit into
mainfrom
DSPX-1561-configured-keys-only
Open

dmihalcik-virtru wants to merge 1 commit into
mainfrom
DSPX-1561-configured-keys-only

Conversation

@dmihalcik-virtru

@dmihalcik-virtru dmihalcik-virtru commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Proposed Changes

  • Assertion.Verify checks a binding with the key the reader selected for that assertion (its per-ID key, else DefaultKey, else the payload key with HS256, as today) and that key's algorithm only.
  • A key carried in the JWS protected header (jwk, or the leaf of x5c) is no longer added to the keys tried, and the header's alg must equal the selected key's algorithm. A binding must have exactly one signature.
  • Error types and messages are unchanged.

This is the minimal, back-portable form of the key-selection fix. The full Section 5–8 verifier (typed reasons, binding forms, strict JWS parsing, embedded-key matching) follows in #4307 and replaces this code.

Split out of #4301 (draft; the complete change). Cross-SDK counterparts: opentdf/java-sdk#434, opentdf/web-sdk#1137.

Compatibility: an assertion signed with a key the reader was not given now fails verification even when its JWS embeds that key, including when no verification keys are configured (payload-key default). Configure the signer's public key as that assertion's verification key.

Checklist

  • I have added or updated unit tests
  • I have added or updated integration tests (if appropriate)
  • I have added or updated documentation

Testing Instructions

  • cd sdk && go test ./... -race. New cases in TestVerifyUsesOnlyTheGivenKey (sdk/assertion_test.go); TestVerifyAssertionWithJWKInHeader (sdk/experimental/tdf) now expects an embedded key to be ignored.

Assertion.Verify checked a binding against the key the reader selected
(the per-ID key, else the default key, else the payload key with HS256)
and also against any key carried in the JWS protected header (jwk or the
leaf of x5c), using the header's alg. Check it with the selected key and
that key's algorithm only. A header key never adds to or replaces it, the
header's alg must equal the selected key's, and a binding must have
exactly one signature.

An assertion signed with a key the reader was not given now fails
verification even when the JWS embeds that key. Configure the signer's
public key as the assertion's verification key instead.

Signed-off-by: Dave Mihalcik <dmihalcik@virtru.com>
@dmihalcik-virtru
dmihalcik-virtru requested review from a team as code owners November 9, 2026 14:50
@coderabbitai

coderabbitai Bot commented Nov 9, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 685063ba-2a8f-463d-949a-c15dc3084770
Commits

Reviewing files that changed from the base of the PR and between 57f15c4 and 585c5d9.

Files selected for processing: 3

  • sdk/assertion.go
  • sdk/assertion_test.go
  • sdk/experimental/tdf/assertion_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor
Benchmark results, click to expand

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 228.163154ms
Throughput 438.28 requests/second

TDF3 Benchmark Results

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 27.054820877s
Average Latency 270.001171ms
Throughput 184.81 requests/second

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

⚠️ Govulncheck found vulnerabilities ⚠️

The following modules have known vulnerabilities:

  • otdfctl
  • sdk
  • service
  • tests-bdd

See the workflow run for details.

This branch has not been deployed

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

Labels

comp:sdk A software development kit, including library, for client applications and inter-service communicati size/s

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant