PYDANTIC · GHSA-3r8g-cqwr-jr29 · Package
FIX → 2.14.2
When extra data is allowed, passing both an alias and the field name for a TypedDict or dataclass field lets the unvalidated name-keyed value overwrite the validated one. The validated output then no longer matches its declared type.
first public Oct 29, 2026 · 1 source
Could this affect your app?
Free first check from your website. Connect your repo for the full answer.
Applications that validate untrusted input into TypedDict or dataclass types with aliased fields while extra data is allowed (extra='allow' or extra_items). Pydantic BaseModel classes are not affected, since extra data is stored separately from fields.
Not affected if basemodel-only, extra-forbidden, no-aliased-fields
Who cares dataclasses, pydantic, python, typeddict
pip show pydantic and check whether the version is below 2.14.2.extra='allow' or extra_items used with TypedDict or dataclass types that have aliased fields.Upgrade to 2.14.2
pydantic to .When extra data is allowed, providing both the alias and the name of an aliased TypedDict or dataclass field makes the unvalidated value (provided under the name) overwrite the validated one (provided under the alias), resulting in validated data not matching the declared type.
Extra items are stored in the same dictionary as the fields (the returned dictionary for TypedDict, the instance __dict__ for dataclasses). As only the alias is marked as used, the field name is treated as an extra item, and its unvalidated value overrides the validated one (pydantic-core/src/validators/typed_dict.rs):
// First pass, for each field:
used_keys.insert(lookup_path.first_key()); // only the alias `b` is marked as used
// ...
output_dict.set_item(&field.name, value)?; // the validated value is stored under `a`
// Second pass, for each input key:
if .used_keys.(cow.()) {
;
}
ExtraBehavior::Allow => {
.output_dict.(py_key, value.(.py)?)?;
}
Check it with your coding agent
It reads this page and tells you if your code is affected.
Are you affected?
Ask from here. InfraStack checks the affected versions against your stack and answers in your inbox.
InfraStack checks the affected versions against your stack and answers in Slack, with the evidence and the fix.
2.14.2Dataclasses have the same logic, in pydantic-core/src/validators/dataclass.rs.
The issue was fixed in commit https://github.com/pydantic/pydantic/commit/34491f5328f168f14e3769cd5f0f83c0af0f4778.
Validation bypass: data returned by validation doesn't match the declared type. Affected are applications validating untrusted data into TypedDict or dataclass types with aliased fields and extra data allowed (with extra='allow', or with the extra_items argument for TypedDict), using Pydantic V2 (up to and including 2.14.1).
Pydantic models (BaseModel) are not affected, as extra data is stored separately from fields.