public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Benjamin A. Beasley <code@musicinmybrain.net>
To: git-commits@fedoraproject.org
Subject: [rpms/python-pydantic-core] f45: Backport fix for CVE-2026-133424
Date: Sat, 21 Nov 2026 07:54:05 GMT [thread overview]
Message-ID: <179524764566.1.7372809682245310840.rpms-python-pydantic-core-38c2bbf201b0@fedoraproject.org> (raw)
A new commit has been pushed.
Repo : rpms/python-pydantic-core
Branch : f45
Commit : 38c2bbf201b0f0ccaddd690cecaefeb0783d77bf
Author : Benjamin A. Beasley <code@musicinmybrain.net>
Date : 2026-11-21T07:33:56+00:00
Stats : +123/-0 in 2 file(s)
URL : https://src.fedoraproject.org/rpms/python-pydantic-core/c/38c2bbf201b0f0ccaddd690cecaefeb0783d77bf?branch=f45
Log:
Backport fix for CVE-2026-133424
---
diff --git a/0001-Ignore-extra-data-matching-a-field-name-in-TypedDict.patch b/0001-Ignore-extra-data-matching-a-field-name-in-TypedDict.patch
new file mode 100644
index 0000000..4ffb762
--- /dev/null
+++ b/0001-Ignore-extra-data-matching-a-field-name-in-TypedDict.patch
@@ -0,0 +1,115 @@
+From 1212304b5a64185f4870d67a75304b0a9e081f87 Mon Sep 17 00:00:00 2001
+From: Victorien <65306057+Viicos@users.noreply.github.com>
+Date: Thu, 29 Oct 2026 11:27:34 +0100
+Subject: [PATCH] Ignore extra data matching a field name in `TypedDict` and
+ dataclasses with `extra=allow` (#14090)
+
+This is the actual fix in pydantic-core; there are also testing changes
+for Pydantic.
+---
+ src/validators/dataclass.rs | 11 ++++++++++-
+ src/validators/typed_dict.rs | 10 ++++++++++
+ tests/validators/test_dataclasses.py | 9 ++++-----
+ 3 files changed, 24 insertions(+), 6 deletions(-)
+
+diff --git a/src/validators/dataclass.rs b/src/validators/dataclass.rs
+index d3c208c71..677c6c519 100644
+--- a/src/validators/dataclass.rs
++++ b/src/validators/dataclass.rs
+@@ -301,6 +301,8 @@ impl Validator for DataclassArgsValidator {
+ if let Some(kwargs) = args.kwargs()
+ && kwargs.len() != used_keys.len()
+ {
++ // Built lazily, only if an extra key needs to be checked against it
++ let mut field_names: Option<AHashSet<&str>> = None;
+ for result in kwargs.iter() {
+ let (raw_key, value) = result?;
+ match raw_key
+@@ -309,7 +311,8 @@ impl Validator for DataclassArgsValidator {
+ .map(ValidationMatch::into_inner)
+ {
+ Ok(either_str) => {
+- if !used_keys.contains(either_str.as_cow()?.as_ref()) {
++ let cow = either_str.as_cow()?;
++ if !used_keys.contains(cow.as_ref()) {
+ // Unknown / extra field
+ match extra_behavior {
+ ExtraBehavior::Forbid => {
+@@ -320,6 +323,12 @@ impl Validator for DataclassArgsValidator {
+ ));
+ }
+ ExtraBehavior::Ignore => {}
++ // An extra key matching a field name (e.g. when validating by alias) is
++ // ignored, as it would otherwise override the field.
++ ExtraBehavior::Allow
++ if field_names
++ .get_or_insert_with(|| self.fields.iter().map(|field| &*field.name).collect())
++ .contains(cow.as_ref()) => {}
+ ExtraBehavior::Allow => {
+ if let Some(ref validator) = self.extras_validator {
+ match validator.validate(py, value.borrow_input(), state) {
+diff --git a/src/validators/typed_dict.rs b/src/validators/typed_dict.rs
+index c0299907b..2a151ee45 100644
+--- a/src/validators/typed_dict.rs
++++ b/src/validators/typed_dict.rs
+@@ -289,6 +289,7 @@ impl Validator for TypedDictValidator {
+ extra_behavior: ExtraBehavior,
+ partial_last_key: Option<LocItem>,
+ allow_partial: PartialMode,
++ fields: &'a [TypedDictField],
+ }
+
+ impl<'py, Key, Value> ConsumeIterator<ValResult<(Key, Value)>> for ValidateExtras<'_, '_, 'py>
+@@ -298,6 +299,8 @@ impl Validator for TypedDictValidator {
+ {
+ type Output = ValResult<()>;
+ fn consume_iterator(self, iterator: impl Iterator<Item = ValResult<(Key, Value)>>) -> ValResult<()> {
++ // Built lazily, only if an extra key needs to be checked against it
++ let mut field_names: Option<AHashSet<&str>> = None;
+ for item_result in iterator {
+ let (raw_key, value) = item_result?;
+ let either_str = match raw_key
+@@ -333,6 +336,12 @@ impl Validator for TypedDictValidator {
+ ));
+ }
+ ExtraBehavior::Ignore => {}
++ // An extra key matching a field name (e.g. when validating by alias) is ignored,
++ // as it would otherwise override the field in the output dict.
++ ExtraBehavior::Allow
++ if field_names
++ .get_or_insert_with(|| self.fields.iter().map(|field| &*field.name).collect())
++ .contains(cow.as_ref()) => {}
+ ExtraBehavior::Allow => {
+ let py_key = either_str.as_py_string(self.py, self.state.cache_str());
+ if let Some(validator) = self.extras_validator {
+@@ -375,6 +384,7 @@ impl Validator for TypedDictValidator {
+ extra_behavior,
+ partial_last_key,
+ allow_partial,
++ fields: &self.fields,
+ })??;
+ }
+
+diff --git a/tests/validators/test_dataclasses.py b/tests/validators/test_dataclasses.py
+index 5f8e82273..f7486b8fc 100644
+--- a/tests/validators/test_dataclasses.py
++++ b/tests/validators/test_dataclasses.py
+@@ -1683,11 +1683,10 @@ def test_dataclass_args_init(input_value, extra_behavior, expected):
+ 'input_value,extra_behavior,expected',
+ [
+ *init_test_cases,
+- # special case - allow override of default, even when init=False, if extra='allow'
+- # TODO: we haven't really decided if this should be allowed or not
+- # currently, it's disallowed in Pydantic to have a model with extra='allow'
+- # and a field with init=False, so this case isn't really possible at the moment
+- ({'a': 'hello', 'b': 'bye'}, 'allow', {'a': 'hello', 'b': 'bye'}),
++ # special case - extra data can't override fields, even when init=False, if extra='allow'
++ # (currently, it's disallowed in Pydantic to have a model with extra='allow'
++ # and a field with init=False, so this case isn't really possible at the moment)
++ ({'a': 'hello', 'b': 'bye'}, 'allow', {'a': 'hello', 'b': 'HELLO'}),
+ ],
+ )
+ def test_dataclass_args_init_with_default(input_value, extra_behavior, expected):
+--
+2.56.1
+
diff --git a/python-pydantic-core.spec b/python-pydantic-core.spec
index ad6d263..bd0d45d 100644
--- a/python-pydantic-core.spec
+++ b/python-pydantic-core.spec
@@ -36,6 +36,14 @@ Patch: 0001-Fix-test-assertion-to-account-for-change-in-rust-uuid.patch
# Source-code change from “update to PyO3 0.29,” a small adjustment to a test
# expectation: https://github.com/pydantic/pydantic/pull/13301
Patch: pydantic_core-2.46.4-pyo3-0.29.patch
+# Ignore extra data matching a field name in TypedDict and dataclasses with
+# extra=allow (#14090)
+# https://github.com/pydantic/pydantic/commit/34491f5328f168f14e3769cd5f0f83c0af0f4778
+# Fixes https://www.cve.org/CVERecord?id=CVE-2026-133424:
+# https://bugzilla.redhat.com/show_bug.cgi?id=2578015
+# Cherry-picked to v2.13.5. This is the actual fix in pydantic-core; an
+# accompanying Pydantic patch adds relevant tests.
+Patch: 0001-Ignore-extra-data-matching-a-field-name-in-TypedDict.patch
# Compatibility with pytest 9.1
# The patch is manually adjusted from the upstream
reply other threads:[~2026-11-21 7:54 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179524764566.1.7372809682245310840.rpms-python-pydantic-core-38c2bbf201b0@fedoraproject.org \
--to=code@musicinmybrain.net \
--cc=git-commits@fedoraproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox