CVE-2026-133428: Quadratic time and memory multi-host URL validation
Validating an untrusted URL with a long scheme and many hosts into a multi-host URL field (e.g. PostgresDsn) takes quadratic time and memory: an input of about a hundred kilobytes takes around a gigabyte of memory to validate.
The parsemultihosturl() function (in pydantic-core/src/validators/url.rs) parses each host separately, prepending the whole URL prefix (including the scheme) to every one of them. As the scheme can be arbitrarily long, and is parsed and stored once per host, both time and memory grow quadratically with the input size. Allowed schemes (e.g. postgres for PostgresDsn) are only checked after parsing, so they don't prevent the issue.
The issue was fixed in commit b4028f9d87e34750e53be0ba011d70f3c0fcc94e.
Impact: denial of service through validation of untrusted input. Affected are applications validating untrusted strings into multi-host URL fields (PostgresDsn, MongoDsn, NatsDsn, or custom types built on MultiHostUrl).
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 b4028f9d87e34750e53be0ba011d70f3c0fcc94e
Event History
Frequently Asked Questions
Which applications are exposed to this denial-of-service condition?
Applications are affected if they validate untrusted strings using multi-host URL fields, including PostgresDsn, MongoDsn, NatsDsn, or custom types built on MultiHostUrl. The impact is denial of service during validation rather than compromise of confidentiality or integrity.
What does an attacker need to send to trigger the issue?
An attacker needs to supply an untrusted multi-host URL with an arbitrarily long scheme and many hosts. No authentication or user interaction is required according to the supplied severity vector.
Do restricted allowed schemes prevent exploitation?
No. Allowed schemes such as postgres are checked only after parsing, so validation can already consume excessive time and memory before the scheme restriction is enforced.
What can be done if the fix cannot be deployed immediately?
Avoid validating untrusted input through affected multi-host URL fields, or enforce limits on input length, scheme length, and host count before the value reaches the multi-host URL validator.