Repository navigation
fix: clamp a declared value length to the bytes present (GHSA-xwvm-687g-rm36) - #652
Merged
Merged
Conversation
1.0 port of commit 6da1c81 (merged by 559a20a), for GHSA-xwvm-687g-rm36. SplitDataView.slice in packages/core clamps the end to the bytes held, the way ArrayBuffer.prototype.slice does, and returns an empty buffer when the start is at or after the end. BinaryRepresentation.readBytes reads only the bytes present when the declared value length is longer, and logs a validationLog warning. The 0.x test test/declared-length-bounds.test.js moves to test/issues/GHSA-xwvm-687g-rm36-declared-length-bounds.test.js. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review item S1 of the 1.0 port of GHSA-xwvm-687g-rm36. The SplitDataView.slice clamp alone makes the readBytes tests pass, so the readBytes tests now also expect the validationLog.warn call. Without the readBytes clamp, 5 tests fail. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Maintainer decision on the review of the 1.0 port of GHSA-xwvm-687g-rm36 (commit 6da1c81): one bullet for the warning and for the RangeError of a truncated header field (review N3). Co-Authored-By: Claude Opus 5.5 <[email protected]>
wayfarer3130
marked this pull request as ready for review
November 24, 2026 19:48
This was referenced Nov 24, 2026
|
🎉 This PR is included in version 1.0.0-beta.17 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
wayfarer3130
added a commit
that referenced
this pull request
Nov 25, 2026
…e exponent (#654) * fix(VR): format DS numbers to 16 characters instead of cutting off the exponent 1.0 port of #610 (commit aee06e4), with the round trip test of #624. denaturalizeDataset in packages/core now formats each number of a DS array with DecimalString.convertToString before denaturalizeValue, so 3.5163338899999997e-10 is written as 3.5163338900e-10 and not cut to 3.51633388999999. Both tests go in test/issues/issue531-ds-exponent.test.js (#610 fixes #531). Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(VR): format a single DS number and a Number object to 16 characters Review items S1 and N1 of the 1.0 port of #610. The 1.x port now also formats the scalar case: a VM 1 DS attribute, for example SliceThickness or SliceLocation, is a single number in a 1.x naturalized dataset, and it went through String() and was cut to 16 characters. A Number object (new Number(...)) is formatted the same way. One formatDs function serves the scalar and the list form. master (0.x) has the same scalar gap after #610. The JSDoc of denaturalizeDataset cites PS3.5 Table 6.2-1. The bundle-size ceilings move to 1.081 and 1.063 for this change. Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs: record the DS formatting in NAT-U-RT-8 and the release notes Maintainer decision Q2 of the review of the 1.0 port of #610: NAT-U-RT-8 in docs/specs/naturalized-dataset.md, with the PS3.5 Section 6.2, Table 6.2-1 reference and the test file, and one bullet in beta-1-release-notes.md. No NAT-I rule covers the DS write, so no NAT-I rule changes. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(bundle-size): raise the dcmjs.es.js ceiling to 1.064 after #652 The rebase onto 1.0-beta adds the declared length clamp of #652 to the DS formatting of this branch: dcmjs.es.js is x1.0632. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR is the 1.0 port of the 0.x fix for the security advisory GHSA-xwvm-687g-rm36 (commit
6da1c81, merged by559a20a). A declared value length can be longer than the bytes in the file. With this fix, the reader reads only the bytes that are present, and it logs a validation warning.Changes
packages/core/src/SplitDataView.js:sliceclamps the end to the bytes that the view holds, the same asArrayBuffer.prototype.slice. A start at or after the end gives an empty buffer.packages/core/src/ValueRepresentation.js:readBytesreads the bytes that are present when the declared length is longer. It logs avalidationLogwarning.beta-1-release-notes.md: one bullet for the change.RangeError. Before, the reader read bytes that were not in the file.AsyncDicomReaderneeds no change. For the same input, it throwsStream has insufficient data. The parserfromPart10Streamalso throws on this input, and its tests require that behavior.Review
An independent review found no blocker. The review covered every 1.x read path. No path allocates a buffer from a declared length that is longer than the data. The review found one gap: no test checked the warning. A new commit adds that check.
Tests
The 0.x test
test/declared-length-bounds.test.jsmoves totest/issues/ghsa-xwvm-687g-rm36-declared-length-bounds.test.js. Only the imports and a header comment change.The API must do this:
SplitDataView.sliceandReadBufferStreamreturn only the bytes that are present.readByteslogs the validation warning when the declared length is longer than the data. If the clamp inreadBytesis removed, this test fails.The user experience must have this:
🤖 Generated with Claude Code