GHSA-pqhp-25j4-6hq9
smol-toml has a Denial of Service via malicious TOML document using deeply nested inline tables
- Severity
- 5.3 / 10
- Medium · CVSS 3.1
- Exploit chance (EPSS)
- —
- No score published
- Known exploited
- No
- Not in CISA's catalog
- Weakness
- CWE-674 Uncontrolled Recursion
- Fix
1.3.1- Upgrade smol-toml to this version or later
Description
Summary
An attacker can send a maliciously crafted TOML to cause the parser to crash because of a stack overflow caused by a deeply nested inline structure. A similar problem occurs when attempting to stringify deeply nested objects.
The library does not limit the maximum exploration depth while parsing or producing TOML documents, nor does it offer a way to do so.
Proof of concept
require("smol-toml").parse("e=" + "{e=".repeat(9999) + "{}" + "}".repeat(9999))
Impact
Applications which parse arbitrary TOML documents may suffer availability issues if they receive malicious input. If uncaught, the crash may cause the application itself to crash. The impact is deemed minor, as the function is already likely to throw errors on invalid input and therefore to properly handle errors.
Due to the design of most JavaScript runtimes, the uncontrolled recursion does not lead to excessive memory usage and the execution is quickly aborted.
As a reminder, it is strongly advised when working with untrusted user input to expect errors to occur and to appropriately catch them.
Patches
Version 1.3.1 offers a mechanism to limit the exploration depth before halting with a TomlError when parsing, with a default cap of 1000. A same mechanism has been implemented for stringifying objects.
Please note that the parser will still throw an error upon such cases. It is, however, a now-controlled and documented behavior of the library.
Workarounds
Wrap all invocations of parse and stringify in a try/catch block.
Affected versions
npm
| Package | Vulnerable | Fixed in |
|---|---|---|
| smol-toml | < 1.3.1 |
1.3.1 |
How to fix
Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.
smol-toml npm → 1.3.1
- npm
npm install smol-toml@1.3.1- yarn
yarn add smol-toml@1.3.1- pnpm
pnpm add smol-toml@1.3.1
Severity breakdown
CVSS 3.1 5.3
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
- Attack vector
- Network
- Attack complexity
- Low
- Privileges required
- None
- User interaction
- None
- Scope
- Unchanged
- Confidentiality
- None
- Integrity
- None
- Availability
- Low
Weakness
CWE-674: Uncontrolled Recursion
The product does not properly control the amount of recursion that takes place, consuming excessive resources, such as allocated memory or the program stack.
How to prevent it
- Implementation: Ensure that an end condition will be reached under all logic conditions. The end condition may include checking against the depth of recursion and exiting with an error if the recursion goes too deep. The complexity of the end condition contributes to the effectiveness of this action.
- Implementation: Increase the stack size.
References
Packages
Other links
Timeline
- Published
Related advisories
| Advisory | Severity | Why it's related |
|---|---|---|
| GHSA-r4xh-jqrq-34v2 smol-toml: Quadratic-time parse() from parseKey rescanning to end of document on each key line | Medium | Also affects smol-toml |
| GHSA-7w5x-hrqm-74c2 smol-toml: Denial of Service via malformed TOML documents | High | Also affects smol-toml |
| GHSA-v3rj-xjv7-4jmq smol-toml: Denial of Service via TOML documents containing thousands of consecutive commented lines | Medium | Also affects smol-toml |
| GHSA-hqq3-7jhf-c5jx Forge: Denial of service in TLS record processing via call stack exhaustion | High | Same weakness, CWE-674 |
| GHSA-wwpr-jff3-395c Crass: A large number of adjacent CSS comments can trigger a SystemStackError | Medium | Same weakness, CWE-674 |
| GHSA-6jxj-px6v-747w Crass: Deeply nested CSS blocks and functions can trigger a SystemStackError or excessive memory usage | Medium | Same weakness, CWE-674 |
| GHSA-vvm8-gf78-28g4 Go JOSE: Panics in JSON parsing | Medium | Same weakness, CWE-674 |
| EEF-CVE-2026-65628 Infinite recursion (CPU denial-of-service) in JOSE.JWK.shared_secret/2 on mismatched key types | Not rated yet | Same weakness, CWE-674 |
MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.
Check your repos with MergeHarbor