fix: bound nesting depth when deserializing enclosed payloads (#3500) - #3501
Open
pjfanning wants to merge 1 commit into
Open
fix: bound nesting depth when deserializing enclosed payloads (#3500)#3501pjfanning wants to merge 1 commit into
pjfanning wants to merge 1 commit into
Conversation
…#3500) Motivation: Several of the remoting wire formats enclose a serialized payload whose enclosed message is itself a serialized payload (for example Some, Optional, Status.Failure, StatusReply, a Throwable cause, or an ActorSelectionMessage). Each level is parsed separately, so neither a protobuf parser's own nesting limit nor the size of the message bounds how deep the chain can go relative to the stack: the recursion tracks the nesting rather than the number of bytes. A sufficiently deeply nested message fails with a StackOverflowError rather than a serialization error. Modification: Add a per-thread nesting-depth counter (NestedDeserialization). A level is counted where a serializer is actually invoked: Serialization.deserializeByteArray counts one, and in WrappedPayloadSupport.deserializePayload the two branches that call a serializer directly count one each, while the branch that delegates back to Serialization leaves the counting to it. Nesting deeper than pekko.actor.serialization-max-nesting-depth (default 32) is rejected with a NotSerializableException. Ordinary nesting depths are unaffected. Result: An over-nested payload is rejected as an ordinary serialization error instead of exhausting the stack. Tests: - sbt "remote/testOnly org.apache.pekko.remote.serialization.NestedPayloadDepthSpec" - 5 passed - sbt "actor-tests/testOnly org.apache.pekko.serialization.SerializeSpec org.apache.pekko.serialization.WireManifestClassLoadingSpec" - 21 passed - sbt "actor/mimaReportBinaryIssues" "remote/mimaReportBinaryIssues" - no issues - scalafmt on the changed Scala sources References: None - robustness of nested payload deserialization
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.
cherry pick 3def397 #3500