Skip to content

fix(sdk): allow duplicate KAOs on same KAS within a split (DSPX-3379)#937

Draft
dmihalcik-virtru wants to merge 4 commits into
mainfrom
DSPX-3379-splitfix
Draft

fix(sdk): allow duplicate KAOs on same KAS within a split (DSPX-3379)#937
dmihalcik-virtru wants to merge 4 commits into
mainfrom
DSPX-3379-splitfix

Conversation

@dmihalcik-virtru
Copy link
Copy Markdown
Member

@dmihalcik-virtru dmihalcik-virtru commented May 28, 2026

Summary

  • splitLookupTableFactory no longer throws when a TDF's KAO array contains multiple entries with the same sid and KAS url. The inner value type is now KeyAccessObject[], and duplicates are appended.
  • unwrapKey registers one rewrap candidate per KAO in the list (disambiguating duplicate URLs with a #<idx> suffix), so anyPool tries each in turn — succeeding if any succeed, otherwise surfacing a normal permission failure.
  • Unit tests updated to the new array shape; throw-on-duplicate test replaced with one that asserts duplicates are preserved; added coverage for "distinct kids on the same KAS for one split."

Fixes DSPX-3379.

Test plan

  • make test — lib mocha + WTR suites pass (334 passing), including the new splitLookupTableFactory cases. (web-app failure in local run was a missing Playwright Chromium binary, unrelated to this change.)
  • Decrypt a TDF whose KAO array contains a duplicated (sid, url) pair end-to-end and confirm successful decrypt instead of the prior InvalidFileError("Repetition found …").
  • Decrypt one where all duplicates would be rejected by KAS and confirm a clean permission-denied error.

🤖 Generated with Claude Code

dmihalcik-virtru and others added 2 commits May 28, 2026 15:58
splitLookupTableFactory threw when a TDF's KAO array had two entries
with the same sid and KAS url, which is legitimate (e.g. multiple keys
on one KAS for the same split). Treat each duplicate as an independent
rewrap candidate so decrypt succeeds if any of them succeed, or surfaces
a normal permission failure otherwise.

DSPX-3379

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2f91ccd8-d953-4258-87ad-2a800e9c3a23

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch DSPX-3379-splitfix

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

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

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 updates the Web SDK to support multiple Key Access Objects (KAOs) on the same Key Access Service (KAS) and split ID, preventing decryption failures when duplicate URLs or multiple keys are present. The splitLookupTableFactory now returns arrays of KAOs, and unwrapKey handles these lists during rewrap. Feedback highlights a potential bug where mismatched sid normalization between splitIds and accessibleSplits could bypass safety checks, and suggests de-duplicating identical KAOs to avoid redundant network requests. Additionally, the newly added specification file contains empty placeholder sections that should be completed or removed.

Comment thread lib/tdf3/src/tdf.ts
Comment thread lib/tdf3/src/tdf.ts
Comment thread spec/DSPX-3379.md Outdated
Comment on lines +25 to +42
## Problem / Motivation
_Why does this work need to happen? What is the user/business pain?_

## Proposed Solution
_What will you build, at a functional level? Sketch the approach._

## Inputs / Outputs / Contracts
_Function signatures, data shapes, API contracts, CLI flags._

## Edge Cases & Constraints
_Boundary conditions, error states, performance limits, security considerations._

## Out of Scope
_What this work item explicitly does not cover._

## Acceptance Criteria
- [ ] _Clear, testable condition_
- [ ] _…_
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

The specification file contains several empty sections with placeholder template text (e.g., Problem / Motivation, Proposed Solution, Inputs / Outputs / Contracts, Edge Cases & Constraints, Out of Scope, and Acceptance Criteria). Please fill out these sections to provide the necessary context and design details for this change, or remove them if they are not applicable.

Address PR #937 review feedback:
- Normalize `sid` to '' in `accessibleSplits` so mixed undefined/'' sids
  cannot bypass the disallowed-KAS check.
- Deduplicate fully identical KAOs by (kid, wrappedKey) in
  `splitLookupTableFactory` to avoid redundant rewrap requests.
- Fill out spec/DSPX-3379.md with the implemented design.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

If these changes look good, signoff on them with:

git pull && git commit --amend --signoff && git push --force-with-lease origin

If they aren't any good, please remove them with:

git pull && git reset --hard HEAD~1 && git push --force-with-lease origin

Signed-off-by: Dave Mihalcik <dmihalcik@virtru.com>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 1, 2026

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