PYDANTIC · GHSA-955g-x97g-8mcp · Package
FIX → 2.14.0
Pydantic's multi-host URL validation parses the whole URL prefix once per host, so a long scheme with many hosts makes time and memory grow quadratically. An attacker who can submit a roughly 100 KB string to a PostgresDsn, MongoDsn or NatsDsn field can exhaust a server's memory and stall it, a denial of service.
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 strings into multi-host URL fields such as PostgresDsn, MongoDsn, NatsDsn, or custom types built on MultiHostUrl are exposed. Code that only validates trusted configuration, or never uses multi-host URL types, is not affected in practice.
Not affected if no-multihost-url-fields, trusted-input-only
Who cares fastapi, pydantic, python, web-api
pip show pydantic or python -c "import pydantic; print(pydantic.VERSION)".PostgresDsn, MongoDsn, NatsDsn or custom types built on MultiHostUrl that validate untrusted input.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 parse_multihost_url() 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 (L644-L649):
let extra_urls: Vec<Url> = hosts
.iter()
.map(|host| {
let reconstructed_url = format!("{prefix}{host}");
parse_url(&reconstructed_url, input, strict)
})
.collect::<ValResult<_>>()?;
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.
Upgrade to 2.14.0
pydantic 2.14.0 or later (fixed in 2.14.0; affected from 2.0.0 up to but not including 2.14.0).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 https://github.com/pydantic/pydantic/commit/b4028f9d87e34750e53be0ba011d70f3c0fcc94e.
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).