Skip to content

fix(sdk): bounds-check little-endian reads and remote byte ranges (DSPX-4591) - #1087

Open
dmihalcik-virtru wants to merge 1 commit into
mainfrom
DSPX-4591-bounds-checked-byte-readers
Open

dmihalcik-virtru wants to merge 1 commit into
mainfrom
DSPX-4591-bounds-checked-byte-readers

Conversation

@dmihalcik-virtru

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

Copy link
Copy Markdown
Member

Jira: https://virtru.atlassian.net/browse/DSPX-4591

Part of finding 6 (no file-bounds checks) of the DSPX-4591 zip conformance audit, split
out of #1079. Neither change depends on the zip reader rework in #1017, so this is based
on main.

What / why

  • readUInt16LE / readUInt32LE (lib/tdf3/src/utils/index.ts) now throw
    InvalidFileError on out-of-range, negative or non-integer offsets. Indexing a typed
    array out of range yields undefined, and bitwise operators coerce that to 0. So an
    unchecked read of a truncated or hostile buffer used to return a plausible-looking
    number instead of failing. readUInt64LE builds on readUInt32LE, so it is covered
    too.
  • fromUrl (lib/src/seekable.ts) refuses non-integer byte ranges (NaN, 1e21,
    0.5, Infinity) before building a Range header. Offsets are often derived from the
    untrusted file being read.

Tests

Checks run

…PX-4591)

- readUInt16LE/readUInt32LE throw InvalidFileError on out-of-range,
  negative or non-integer offsets instead of coercing undefined to 0
- fromUrl refuses non-integer byte ranges before building a Range header

Signed-off-by: Dave Mihalcik <dmihalcik@virtru.com>
@dmihalcik-virtru
dmihalcik-virtru requested a review from a team as a code owner October 14, 2026 20:43
@coderabbitai

coderabbitai Bot commented Oct 14, 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
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 50f492f7-2956-4470-9ba6-c440ff77539d
📥 Commits

Reviewing files that changed from the base of the PR and between ebc317a and c6ebad6.

📒 Files selected for processing: 4
  • lib/src/seekable.ts
  • lib/tdf3/src/utils/index.ts
  • lib/tests/mocha/unit/byte-readers.spec.ts
  • lib/tests/mocha/unit/seekable.spec.ts
  • 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

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

@sonarqubecloud

Copy link
Copy Markdown

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant