CVE-2026-133422: Quadratic time unique_items list validation in Pydantic V1
Validating an untrusted list into a field constrained with uniqueitems=True with Pydantic V1 takes quadratic time: an input of a few hundred kilobytes takes seconds to validate.
The ConstrainedList.uniqueitemsvalidator validator (in pydantic/types.py) checks each item against all the following ones. For a list with no duplicates (the common, valid case), this results in a quadratic number of comparisons.
The issue was fixed in commit 6ec75e57f277a820ec583e601167f25fe8dc7c87. Users relying on the pydantic.v1 namespace in Pydantic V2 should upgrade to 2.14.2 or later.
Impact: denial of service through validation of untrusted input. Affected are applications validating untrusted lists into fields constrained with uniqueitems=True (using conlist() or Field()).
The fix only applies to lists of builtin scalar types (int, float, str, bytes, bool and None), for which duplicates can be detected in linear time. Lists of other types (e.g. models or dictionaries) are still checked in quadratic time, as their items aren't guaranteed to be hashable: bound their size using the maxitems constraint.
Pydantic V2 models are not affected.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Patch 6ec75e57f277a820ec583e601167f25fe8dc7c87 - Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 2.14.2 - Configuration
Bound list size using the max_items constraint, since these item types are still checked in quadratic time.
Pydantic V1 list fields containing models or dictionaries max_items
Event History
Frequently Asked Questions
Which applications are exposed to this denial-of-service condition?
Applications are affected when they validate untrusted lists using Pydantic V1 fields configured with unique_items=True, whether configured through conlist() or Field(). Pydantic V2 models are not affected, but use of the pydantic.v1 namespace in Pydantic V2 is within scope.
What does an attacker need to send to trigger the issue?
An attacker needs to submit a sufficiently large list with no duplicate items to an input path that performs affected validation. The no-duplicate case causes each item to be compared with following items, producing quadratic work; a few hundred kilobytes can take seconds to validate.
Are all unique_items lists fixed by upgrading?
No. The fix provides linear-time duplicate detection only for builtin scalar item types: int, float, str, bytes, bool, and None. Lists containing other types, such as models or dictionaries, can still be validated in quadratic time because their items may not be hashable.
What mitigation is available if affected validation cannot be changed immediately?
For unique-item lists containing non-scalar types, apply a max_items constraint to bound list size. This limits the amount of quadratic validation work for models, dictionaries, and other potentially unhashable item types.
What upgrade is identified for users of the Pydantic V1 compatibility namespace?
Users relying on the pydantic.v1 namespace in Pydantic V2 should upgrade to version 2.14.2 or later.