Skip to content

fix(sdk): DSPX-1561 verify assertion bindings under the assertions specification - #4307

Draft
dmihalcik-virtru wants to merge 1 commit into
DSPX-1561-assertion-hashfrom
DSPX-1561-binding-verification
Draft

dmihalcik-virtru wants to merge 1 commit into
DSPX-1561-assertion-hashfrom
DSPX-1561-binding-verification

Conversation

@dmihalcik-virtru

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

Copy link
Copy Markdown
Member

Proposed Changes

  • Each assertion is verified with exactly one key, chosen by its exact id: its per-ID key, else DefaultKey, else the payload key with HS256 (spec Section 6.1). A failure with that key is final. An empty or unusable selected key, including an HS256 key given as PEM text, fails with configuration-error instead of falling through.
  • The binding JWS is checked directly (crypto/rsa, crypto/hmac) rather than through jwt.Parse: compact serialization in strict base64url, no crit, a supported alg equal to the selected key's algorithm, and a signature under that key.
  • An embedded jwk or x5c must hold the selected public key (RFC 7638 thumbprint) and is refused with an HMAC key; malformed embedded keys are rejected.
  • Claims other than assertionHash and assertionSig are ignored (no exp/nbf checks).
  • Binding forms (Section 5.1): a missing method means jws; jws and JWS are accepted; STANAG 4778 binding objects and unknown methods are unsupported-binding.
  • Every failure is an ErrAssertionFailure with the exact id and a Section 9 reason.

Stacked on: #4306. Supersedes the Assertion.Verify change in #4303; this branch will be rebased once that and #4304 land.
Split out of #4301 (draft; the complete change). Cross-SDK counterparts: opentdf/java-sdk#438, opentdf/web-sdk#1141.

Compatibility: a configured default key applies to every assertion without a per-ID key, including payload-key assertions such as Java's system-metadata, so those files fail when only a default key is configured.

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 (sdk/assertion_verify_test.go).
  • xtest: test_assertion_verification.py, forced with XT_FORCE_SUPPORTS=assertion_header_key_pinning,assertion_hash_raw.

…ecification

Verify each assertion under the ZTDF assertions specification, Sections 5
to 8, with exactly one key: the per-ID key for its exact id, else the
default key, else the payload key with HS256. A failure with the selected
key is final, and an empty or unusable selected entry, including an HS256
key given as PEM text, fails with configuration-error instead of falling
through to the next source.

Check the binding's JWS directly rather than through jwt.Parse: compact
serialization in strict base64url, no crit header, an alg this SDK
supports that equals the selected key's algorithm, and a signature under
that key. A jwk or x5c header must hold the selected public key (RFC 7638
thumbprint) and is refused with an HMAC key. A jwk must be well formed for
its key type, with minimal RSA integers and exact EC coordinate lengths,
and every x5c entry must be padded base64. Claims other than assertionHash
and assertionSig are ignored. A missing binding method means jws; STANAG
4778 binding objects, unknown methods, and bindings with both forms or
neither fail with their own reasons.

Every failure is an ErrAssertionFailure carrying the exact id and a
Section 9 reason.

Signed-off-by: Dave Mihalcik <dmihalcik@virtru.com>
@coderabbitai

coderabbitai Bot commented Nov 9, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • 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 414.593783ms
Throughput 241.20 requests/second

TDF3 Benchmark Results

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 47.575394887s
Average Latency 474.837216ms
Throughput 105.10 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/l

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant