Valid Object keys and Ensure that serializable classes are unserialized with 'C'#305
Open
souvlakias wants to merge 4 commits intosteelbrain:mainfrom
Open
Valid Object keys and Ensure that serializable classes are unserialized with 'C'#305souvlakias wants to merge 4 commits intosteelbrain:mainfrom
souvlakias wants to merge 4 commits intosteelbrain:mainfrom
Conversation
steelbrain
requested changes
Jul 21, 2025
Owner
steelbrain
left a comment
There was a problem hiding this comment.
Thank you very much!
I appreciate your contribution. Would you be interested in writing some tests to prevent regression and crediting yourself in CHANGELOG.md? (under the version "Upcoming" for now)
Author
|
Hey, I put in some tests and updated the changelog. Let me know if anything needs tweaking. (You should be able to edit the branch if you want to make any changes) |
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.
Motivation
This library was used in a
Web Exploitationchallenge for the ECSC 2025 qualifiers of Team Greece and Team Cyprus. Two bugs were found:Otype and manual setting of key-value pairs, allowing pollution of the__proto__attribute.toStringthat could be triggered by requesting the unserialization of an object with a class instance as a key, which would invoketoStringautomatically.Why these matter
unserializedmethod they implemented. A user should not be allowed to set the__proto__attribute during unserialization, as it can lead to unexpected behavior or security issues.What this changes
numberorstring, and not equal to__proto__.O:notserializable-class.Thoughts
serialize.ts,Mapobjects are currently converted into plain key-value objects. This causes data loss becauseMapsupports dynamic, non-string keys, but the serialization process coerces them into static string keys.Mapserialization is indeed required, it would be better to implement a custom serialization and unserialization method that preserves key types. For example, by reconstructing theMapusing.set()during unserialization.