Skip to content

Commit dbf01f4

Browse files
CBL-Mariner-Botdurgajagadeeshjslobodzian
authored
Merge PR "[AUTO-CHERRYPICK] [High] patch pytorch for CVE-2026-0994 - branch 3.0-dev" microsoft#15851
Co-authored-by: durgajagadeesh <v-dpalli@microsoft.com> Co-authored-by: jslobodzian <joslobo@microsoft.com>
1 parent 24048bb commit dbf01f4

2 files changed

Lines changed: 89 additions & 1 deletion

File tree

SPECS/pytorch/CVE-2026-0994.patch

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
From b210265f2b4c05e396e4590feb0c38ae6ae0cca4 Mon Sep 17 00:00:00 2001
2+
From: aviralgarg05 <gargaviral99@gmail.com>
3+
Date: Fri, 9 Jan 2026 20:59:10 +0530
4+
Subject: [PATCH] Fix Any recursion depth bypass in Python
5+
json_format.ParseDict
6+
7+
This fixes a security vulnerability where nested google.protobuf.Any messages
8+
could bypass the max_recursion_depth limit, potentially leading to denial of
9+
service via stack overflow.
10+
11+
The root cause was that _ConvertAnyMessage() was calling itself recursively
12+
via methodcaller() for nested well-known types, bypassing the recursion depth
13+
tracking in ConvertMessage().
14+
15+
The fix routes well-known type parsing through ConvertMessage() to ensure
16+
proper recursion depth accounting for all message types including nested Any.
17+
18+
Fixes #25070
19+
20+
Closes #25239
21+
22+
Upstream Patch Reference:https://github.com/protocolbuffers/protobuf/commit/c4eda3e58680528147a4cc7e2b3c9044f795c9c9
23+
---
24+
.../python/google/protobuf/json_format.py | 21 ++++++++++++++++---
25+
1 file changed, 18 insertions(+), 3 deletions(-)
26+
27+
diff --git a/third_party/protobuf/python/google/protobuf/json_format.py b/third_party/protobuf/python/google/protobuf/json_format.py
28+
index 4d76d021..63f21cbb 100644
29+
--- a/third_party/protobuf/python/google/protobuf/json_format.py
30+
+++ b/third_party/protobuf/python/google/protobuf/json_format.py
31+
@@ -459,9 +459,11 @@ _INT_OR_FLOAT = six.integer_types + (float,)
32+
class _Parser(object):
33+
"""JSON format parser for protocol message."""
34+
35+
- def __init__(self, ignore_unknown_fields, descriptor_pool):
36+
+ def __init__(self, ignore_unknown_fields, descriptor_pool, max_recursion_depth=100):
37+
self.ignore_unknown_fields = ignore_unknown_fields
38+
self.descriptor_pool = descriptor_pool
39+
+ self.max_recursion_depth = max_recursion_depth
40+
+ self.recursion_depth = 0
41+
42+
def ConvertMessage(self, value, message):
43+
"""Convert a JSON object into a message.
44+
@@ -473,6 +475,17 @@ class _Parser(object):
45+
Raises:
46+
ParseError: In case of convert problems.
47+
"""
48+
+ # Increment recursion depth at message entry. The max_recursion_depth limit
49+
+ # is exclusive: a depth value equal to max_recursion_depth will trigger an
50+
+ # error. For example, with max_recursion_depth=5, nesting up to depth 4 is
51+
+ # allowed, but attempting depth 5 raises ParseError.
52+
+ self.recursion_depth += 1
53+
+ if self.recursion_depth > self.max_recursion_depth:
54+
+ raise ParseError(
55+
+ 'Message too deep. Max recursion depth is {0}'.format(
56+
+ self.max_recursion_depth
57+
+ )
58+
+ )
59+
message_descriptor = message.DESCRIPTOR
60+
full_name = message_descriptor.full_name
61+
if _IsWrapperMessage(message_descriptor):
62+
@@ -481,6 +494,7 @@ class _Parser(object):
63+
methodcaller(_WKTJSONMETHODS[full_name][1], value, message)(self)
64+
else:
65+
self._ConvertFieldValuePair(value, message)
66+
+ self.recursion_depth -= 1
67+
68+
def _ConvertFieldValuePair(self, js, message):
69+
"""Convert field value pairs into regular message.
70+
@@ -612,8 +626,9 @@ class _Parser(object):
71+
if _IsWrapperMessage(message_descriptor):
72+
self._ConvertWrapperMessage(value['value'], sub_message)
73+
elif full_name in _WKTJSONMETHODS:
74+
- methodcaller(
75+
- _WKTJSONMETHODS[full_name][1], value['value'], sub_message)(self)
76+
+ # For well-known types (including nested Any), use ConvertMessage
77+
+ # to ensure recursion depth is properly tracked
78+
+ self.ConvertMessage(value['value'], sub_message)
79+
else:
80+
del value['@type']
81+
self._ConvertFieldValuePair(value, sub_message)
82+
--
83+
2.45.4
84+

SPECS/pytorch/pytorch.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Summary: Tensors and Dynamic neural networks in Python with strong GPU acceleration.
33
Name: pytorch
44
Version: 2.2.2
5-
Release: 11%{?dist}
5+
Release: 12%{?dist}
66
License: BSD-3-Clause
77
Vendor: Microsoft Corporation
88
Distribution: Azure Linux
@@ -37,6 +37,7 @@ Patch12: CVE-2025-55560.patch
3737
Patch13: CVE-2025-46152.patch
3838
Patch14: CVE-2025-3001.patch
3939
Patch15: CVE-2026-24747.patch
40+
Patch16: CVE-2026-0994.patch
4041

4142
%description
4243
PyTorch is a Python package that provides two high-level features:
@@ -98,6 +99,9 @@ cp -arf docs %{buildroot}/%{_pkgdocdir}
9899
%{_docdir}/*
99100

100101
%changelog
102+
* Wed Feb 11 2026 Durga Jagadeesh Palli <v-dpalli@microsoft.com> - 2.2.2-12
103+
- Patch for CVE-2026-0994
104+
101105
* Wed Jan 28 2026 Azure Linux Security Servicing Account <azurelinux-security@microsoft.com> - 2.2.2-11
102106
- Patch for CVE-2026-24747
103107

0 commit comments

Comments
 (0)