Medium

smol-toml has a Denial of Service via malicious TOML document using deeply nested inline tables

  • Disclosed: 22.11.2024
  • Updated: 11.10.2026 10:22

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

js
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 software

Click a technology to see all vulnerabilities affecting it.

PlatformPackageVulnerable versionsFixed in
npm package smol-toml < 1.3.1 1.3.1

References

CVSS score 5.3/10
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
Weakness (CWE)
CWE-674
Platform
npm
Package
smol-toml
Disclosed
22.11.2024
Updated
11.10.2026 10:22

Sources and licenses

OSV / GitHub Advisory Database - GHSA-pqhp-25j4-6hq9 - CC BY 4.0

Vulnerability history: smol-toml

All published vulnerabilities of this package (npm package), newest first. Shows whether this is a one-off slip or a package that needs watching.

Total entries
4
First → latest
11.2024 10.2026
Without a fix
0
Exploited in attacks
0

Severity breakdown

  • High 1
  • Medium 3

Disclosures per year

  1. 2024: 1
  2. 2025: 0
  3. 2026: 3
  1. smol-toml has a Denial of Service via malicious TOML document using deeply nested inline tables this entry
    Medium · 5.3 ghsa-pqhp-25j4-6hq9 < 1.3.1 1.3.1

Know which vulnerabilities affect your application

With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.

Connect your application
DockRay newsletter

Application security in your inbox

Important vulnerabilities, actionable guidance and practical advice for your applications. Choose your technologies and follow what matters to your project.

  • A daily digest of new vulnerabilities, critical ones included.
  • Notifications about important updates.
  • Practical advice on application security and monitoring.

Leave empty to receive updates for every technology.

Free to subscribe. Unsubscribe with one click in any email.