You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Security] Quadratic complexity DoS when parsing dotted keys with shared prefix (CWE-400) #479
tomlkit exhibits super-linear time complexity when parsing TOML documents with multiple dotted keys sharing a common prefix. A valid 1.3 KB document causes 8+ seconds of CPU consumption.
Affected version: 0.15.0 (latest)
Reproduction:
import tomlkit
import time
80 dotted keys with shared prefix — valid TOML, only 1,339 bytes
payload = "\n".join([f"a.b.c.key{i} = {i}" for i in range(80)])
Poetry (30M+ monthly downloads) uses tomlkit to parse pyproject.toml
A malicious pyproject.toml in a git repository could DoS CI/CD pipelines
Any application parsing untrusted TOML with tomlkit is vulnerable
Root cause: The internal table merging logic for dotted keys appears to re-traverse the table hierarchy for each new key, causing polynomial time complexity when many keys share a prefix path.
Workaround: Use tomli/tomllib for parsing untrusted TOML input.
CWE: CWE-400 (Uncontrolled Resource Consumption)
Discovered by: Frédéric Bogaerts, University of Coimbra (VAITP Research Project)
Activity
py-tomlkit: update to 0.15.1.
py-tomlkit: update to 0.15.1.