Skip to content

Fix Any recursion depth bypass in Python json_format.ParseDict (#25239)#25587

Merged
zhangskz merged 1 commit into29.xfrom
cp-29-python-json-recursion
Jan 29, 2026
Merged

Fix Any recursion depth bypass in Python json_format.ParseDict (#25239)#25587
zhangskz merged 1 commit into29.xfrom
cp-29-python-json-recursion

Conversation

@zhangskz
Copy link
Member

This fixes a security vulnerability where nested google.protobuf.Any messages could bypass the max_recursion_depth limit, potentially leading to denial of service via stack overflow.

The root cause was that _ConvertAnyMessage() was calling itself recursively via methodcaller() for nested well-known types, bypassing the recursion depth tracking in ConvertMessage().

The fix routes well-known type parsing through ConvertMessage() to ensure proper recursion depth accounting for all message types including nested Any.

Fixes #25070

Closes #25239

COPYBARA_INTEGRATE_REVIEW=#25239 from aviralgarg05:fix-any-recursion-depth-bypass 3cbbcbe PiperOrigin-RevId: 862740421

This fixes a security vulnerability where nested google.protobuf.Any messages could bypass the max_recursion_depth limit, potentially leading to denial of service via stack overflow.

The root cause was that _ConvertAnyMessage() was calling itself recursively via methodcaller() for nested well-known types, bypassing the recursion depth tracking in ConvertMessage().

The fix routes well-known type parsing through ConvertMessage() to ensure proper recursion depth accounting for all message types including nested Any.

Fixes #25070

Closes #25239

COPYBARA_INTEGRATE_REVIEW=#25239 from aviralgarg05:fix-any-recursion-depth-bypass 3cbbcbe
PiperOrigin-RevId: 862740421
@zhangskz zhangskz requested a review from a team as a code owner January 29, 2026 19:10
@zhangskz zhangskz requested review from haberman and removed request for a team January 29, 2026 19:11
@zhangskz zhangskz requested a review from a team as a code owner January 29, 2026 20:35
@zhangskz zhangskz force-pushed the cp-29-python-json-recursion branch from 81dc896 to 5236e63 Compare January 29, 2026 21:08
@zhangskz zhangskz merged commit 5ebddcb into 29.x Jan 29, 2026
369 of 375 checks passed
@zhangskz zhangskz deleted the cp-29-python-json-recursion branch January 29, 2026 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants