fix: add bounds check before memcpy in 10d_blocked.h#2
Closed
orbisai0security wants to merge 2 commits into
Closed
fix: add bounds check before memcpy in 10d_blocked.h#2orbisai0security wants to merge 2 commits into
orbisai0security wants to merge 2 commits into
Conversation
Automated security fix generated by OrbisAI Security
The blocked ndarray macros copy stride and shape data from ndarray structures into fixed-size stack-allocated arrays using memcpy with sizeof(destination) as the size
|
Thank you for submitting a pull request. 🙌 We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the main project repository. We kindly request that you submit this pull request against the respective directory of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the contributing guide which provides guidelines and instructions for submitting contributions. Thank you again, and we look forward to receiving your contribution! 😃 Best, |
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
Fix high severity security issue in
base/count-falsy/include/stdlib/ndarray/base/count-falsy/macros/10d_blocked.h.Vulnerability
V-001base/count-falsy/include/stdlib/ndarray/base/count-falsy/macros/10d_blocked.h:113Description: The blocked ndarray macros copy stride and shape data from ndarray structures into fixed-size stack-allocated arrays using memcpy with sizeof(destination) as the size. There is no runtime assertion that the ndarray's ndims matches the expected dimensionality of the macro. If an ndarray with fewer dimensions is passed, uninitialized stack memory in the remaining positions of sx1 will be used as stride values in subsequent loop iterations, leading to wild pointer arithmetic. If an ndarray with more dimensions is passed, only the first N strides are copied but the macro may still iterate based on the ndarray's actual shape metadata, causing out-of-bounds access patterns.
Evidence
Exploitation scenario: An attacker who can construct an ndarray with ndims != expected (e.g., ndims=12 passed to 10d_blocked macro) causes the macro to operate with partial or uninitialized stride data.
Scanner confirmation: multi_agent_ai rule
V-001flagged this pattern.Production code: This file is in the production codebase, not test-only code.
Threat Model Context
This is a Node.js library - vulnerabilities affect downstream consumers who use this package.
Changes
base/count-falsy/include/stdlib/ndarray/base/count-falsy/macros/10d_blocked.hVerification
Security Invariant
Regression test
This test guards against regressions — it's useful independent of the code change above.
Automated security fix by OrbisAI Security