fix: fastbufferreader string deserialization int overflow#4052
Open
NoelStephensUnity wants to merge 16 commits into
Open
fix: fastbufferreader string deserialization int overflow#4052NoelStephensUnity wants to merge 16 commits into
NoelStephensUnity wants to merge 16 commits into
Conversation
This fixes an edge case scenario with string reading where if user code has caused the character count to have been already read prior to attempting to read a string value (safely or unsafely) and then reading the string can result in the signed integer size to roll over to a negative value and thus causing the reader to attempt to read into restricted memory outside of the application domain which results in the editor crashing. The fix catches this scenario and throws an overflow exception prior to attempting to read into negative memory space relative to the application domain.
michalChrobot
approved these changes
Jun 30, 2026
michalChrobot
left a comment
Member
There was a problem hiding this comment.
Thanks for the investigation on this!
RikuTheFuffs
approved these changes
Jun 30, 2026
RikuTheFuffs
left a comment
Contributor
There was a problem hiding this comment.
Added a couple nitpick comments that might help with readability/maintenance, feel free to ignore them.
Apart from that LGTM!
EmandM
reviewed
Jun 30, 2026
…Reader.cs Co-authored-by: Emma <emma.mcmillan@unity3d.com>
EmandM
approved these changes
Jun 30, 2026
…w' of https://github.com/Unity-Technologies/com.unity.netcode.gameobjects into fix/fastbufferreader-string-deserialization-int-overflow
…lization-int-overflow
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.
Purpose of this PR
This PR resolves an edge case scenario that can cause the Unity editor to crash.
The issue requires a portion of the character count of a serialized string to have been read prior to attempting to safely or unsafely read the string. When using 2 byte character values, this can result in the length exceeding the maximum integer size resulting in a negative size being read which, in turn, causes the FastBufferReader to attempt to read into restricted memory (most likely outside of the application domain) that results in a hard editor crash.
Jira ticket
UUM-145752
Changelog
Documentation
Testing & QA (How your changes can be verified during release Playtest)
Functional Testing
Manual testing :
Manual testing doneAutomated tests:
Covered by existing automated testsCovered by new automated testsDoes the change require QA team to:
Review automated tests?Execute manual tests?Provide feedback about the PR?If any boxes above are checked the QA team will be automatically added as a PR reviewer.
Backports
No back port is required.