Skip to content

fix(sdk): require 12-byte AES-GCM IVs (DSPX-4496) - #1060

Merged
dmihalcik-virtru merged 1 commit into
mainfrom
DSPX-4496-gcm-iv-length
Oct 7, 2026
Merged

dmihalcik-virtru merged 1 commit into
mainfrom
DSPX-4496-gcm-iv-length

Conversation

@dmihalcik-virtru

@dmihalcik-virtru dmihalcik-virtru commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

What

  • AesGcmCipher.encrypt rejects an IV that isn't exactly 12 bytes, throwing a ConfigurationError. This matches java-sdk#393.
  • AesGcmCipher.decrypt drops its unused iv parameter, since it always reads the IV from the buffer's own prefix. Its doc comment, which wrongly said "CBC mode", is fixed too.

Why

The reader takes each segment's IV from a fixed 12-byte prefix. An IV of any other length writes a TDF that encrypts without error but can never be read back.

How to test

cd lib && npm test. See the new tests/mocha/unit/aes-gcm-cipher-iv.spec.ts.

Risk

Low. The SDK always passes 12-byte IVs. Only an external caller that passes a malformed IV to AesGcmCipher.encrypt will now get an error, and its output was unreadable anyway.

DSPX-4496 series

Part PR Base Depends on
1 of 6 #1059 reject non-positive segment sizes main —
2 of 6 #1060 require 12-byte AES-GCM IVs main —
3 of 6 #1061 calculate encrypted segment size main —
4 of 6 #1062 default segment size 2 MiB main —
5 of 6 #1063 AesGcmEncryptor SPI DSPX-4496-encrypted-segment-size #1061
6 of 6 #1018 writer IVs from the CryptoService encryptor DSPX-4496-aes-gcm-encryptor #1063

#1059, #1060 and #1062 stand alone. #1061 ← #1063 ← #1018 is a stack.

The reader takes each segment's IV from a fixed 12-byte prefix, so an IV of
any other length writes a TDF that cannot be read back. Reject it in
AesGcmCipher.encrypt with a ConfigurationError, matching java-sdk#393.

Also drop the unused `iv` parameter from AesGcmCipher.decrypt, which always
reads the IV from the buffer, and fix its doc comment.

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

coderabbitai Bot commented Oct 6, 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 5 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
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cb8a526b-3789-4f33-8cc8-c6c0b310d105
📥 Commits

Reviewing files that changed from the base of the PR and between 55a0521 and e0fe65b.

📒 Files selected for processing (2)
  • lib/tdf3/src/ciphers/aes-gcm-cipher.ts
  • lib/tests/mocha/unit/aes-gcm-cipher-iv.spec.ts
  • Autopilot · 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

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

@sonarqubecloud

sonarqubecloud Bot commented Oct 6, 2026

Copy link
Copy Markdown

@dmihalcik-virtru
dmihalcik-virtru marked this pull request as ready for review October 6, 2026 20:10
@dmihalcik-virtru
dmihalcik-virtru requested a review from a team as a code owner October 6, 2026 20:10
@dmihalcik-virtru
dmihalcik-virtru added this pull request to the merge queue Oct 7, 2026
Merged via the queue into main with commit cf239ec Oct 7, 2026
31 checks passed
@dmihalcik-virtru
dmihalcik-virtru deleted the DSPX-4496-gcm-iv-length branch October 7, 2026 13:45
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.

2 participants