Potential fix for code scanning alert no. 1: Prototype-polluting assignment #127
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.
Potential fix for https://github.com/SundaeSwap-finance/sundae-sdk/security/code-scanning/1
To fix prototype pollution, avoid assigning to object keys that come directly from untrusted input (here,
policy_idandasset_name) unless those keys are sanitized or rejected if they are dangerous. There are several ways to fix this:Mapobject instead of a plain object forasset_mapand its nested values.Mapis not vulnerable to prototype pollution, since its keys live outside normal object/property semantics.__proto__,constructor, andprototypein bothpolicy_idandasset_namebefore assignment.The best fix is to replace both
asset_mapand its nested{}objects with ES6Mapobjects, adapting all relevant assignments and lookups to use.get(),.set(), etc., instead of bracket notation. This change will require updating the construction and the usages for both levels of nesting (the outer map forpolicy_idand the inner map forasset_name). When constructing the datum, if the downstream code expects plain objects, you may need to convert theMaps back to objects via spreading orObject.fromEntriesbefore serialization.All changes should be made inside the method
buildConditionDatuminpackages/core/src/DatumBuilders/DatumBuilder.NftCheck.class.ts.Suggested fixes powered by Copilot Autofix. Review carefully before merging.