Skip to content

fix wiremessage oob in case of intmin #2076

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 2, 2025

Conversation

kobrineli
Copy link
Contributor

Couldn't attach GODRIVER task number, 'cause I get 403 forbidden trying to access the project page.

Summary

If length is in range from INT_MIN (i.e. -2147483648) to INT_MIN+3, length-4 < 0 check doesn't work as expected due to integer overflow.

Getting too small length leads to check pass and further out of bound access.

Adding an additional check for length being smaller than zero solves the issue.

@kobrineli kobrineli requested a review from a team as a code owner May 30, 2025 14:49
@kobrineli kobrineli requested a review from qingyang-hu May 30, 2025 14:49
@@ -406,7 +406,7 @@ func ReadMsgSectionDocumentSequence(src []byte) (identifier string, docs []bsonc
// sequence data.
func ReadMsgSectionRawDocumentSequence(src []byte) (identifier string, data []byte, rem []byte, ok bool) {
length, rem, ok := readi32(src)
if !ok || int(length) > len(src) || length-4 < 0 {
if !ok || int(length) > len(src) || length < 0 || length-4 < 0 {
Copy link
Member

@prestonvasquez prestonvasquez Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest checking length < 4 instead of length < 0 || length-4 < 0 .

We should also add a test for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed, seems better

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@alcaeus
Copy link
Member

alcaeus commented Jul 1, 2025

@kobrineli I'm closing this PR for the time being. If you're still interested in making the change, please open a new pull request with the suggestion applied.

@alcaeus alcaeus closed this Jul 1, 2025
@alcaeus alcaeus removed the request for review from qingyang-hu July 1, 2025 18:45
@prestonvasquez prestonvasquez reopened this Jul 1, 2025

Verified

This commit was signed with the committer’s verified signature.
prestonvasquez Preston Vasquez
@prestonvasquez prestonvasquez requested review from matthewdale and removed request for matthewdale July 1, 2025 19:05
Copy link
Collaborator

@matthewdale matthewdale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 👍

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@mongodb-drivers-pr-bot mongodb-drivers-pr-bot bot added the review-priority-low Low Priority PR for Review: within 3 business days label Jul 1, 2025
Copy link
Contributor

API Change Report

No changes found!

@prestonvasquez prestonvasquez enabled auto-merge (squash) July 2, 2025 01:33
@prestonvasquez prestonvasquez disabled auto-merge July 2, 2025 01:38
@prestonvasquez prestonvasquez enabled auto-merge (squash) July 2, 2025 01:39
@prestonvasquez prestonvasquez merged commit 87fe3bb into mongodb:master Jul 2, 2025
26 of 33 checks passed
prestonvasquez added a commit to prestonvasquez/mongo-go-driver that referenced this pull request Jul 31, 2025

Verified

This commit was signed with the committer’s verified signature.
prestonvasquez Preston Vasquez
Co-authored-by: Preston Vasquez <[email protected]>
alcaeus added a commit that referenced this pull request Aug 5, 2025

Verified

This commit was signed with the committer’s verified signature. The key has expired.
alcaeus Andreas Braun
* master: (65 commits)
  Replace all uses of 'interface{}' with 'any' in the bson package. (#2138)
  GODRIVER-3473 Short-cicruit cursor.next() on invalid timeouts (#2135)
  GODRIVER-3622 Automatically retry some test tasks. (#2147)
  Replace all uses of 'interface{}' with 'any' in the repo docs. (#2142)
  GODRIVER-3102: Perf comparison (#2134)
  GODRIVER-3587 Use raw bytes in valueReader (#2120)
  Replace all uses of 'interface{}' with 'any' in the internal/ packages. (#2140)
  Replace all uses of 'interface{}' with 'any' in the x/ packages. (#2137)
  GODRIVER-2016 Unskip all Transactions unified spec tests. (#2132)
  GODRIVER-2540 Run govulncheck in CI builds. (#2136)
  GODRIVER-3549 Update Client BulkWrite prose tests. (#2131)
  Add guidelines for contributing features to the Go Driver (#2125)
  Bump alcaeus/automatic-merge-up-action from 1.0.0 to 1.0.1 in the actions group (#2126)
  Add wrappedMsgOnly to mongo.MarshalError and mongo.MongocryptError.
  Bump testdata/specifications from `db69351` to `6689929`
  fix wiremessage oob in case of intmin (#2076)
  GODRIVER-3399: PoolClearedError should have TransientTransactionError label appended to it (#2114)
  PR feedback.
  Prevent integration tests from running when testing with -short
  Skip AWS Test if no URI (#2102)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review-priority-low Low Priority PR for Review: within 3 business days
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants