Skip to content
Fencer Intel
medium 5.3

GHSA-v3rj-xjv7-4jmq json

smol-toml: Denial of Service via TOML documents containing thousands of consecutive commented lines

published 7mo ago modified 2mo ago

cvss
5.3
version 3.1, GitHub
cisa kev
Not listed
not in CISA's catalog
epss
—
no score, EPSS covers CVEs only
public exploits
0
none known

Summary

### Summary An attacker can send a maliciously crafted TOML to cause the parser to crash, because of a stack overflow caused by thousands of consecutive commented lines.

The library uses recursion internally while parsing to skip over commented lines, which can be exploited to crash an application that is processing arbitrary TOML documents.

### Proof of concept ```js require("smol-toml").parse('# comment\n'.repeat(8000) + 'key = "value"') ```

### 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. Downstream users are supposed to properly handle errors in such situations.

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.6.1 uses a different approach for parsing comments, which no longer involves recursion.

### Workarounds Wrap all invocations of `parse` and `stringify` in a try/catch block when dealing with untrusted user input.

Patch / fix

  • npm smol-toml 1.6.1

Is GHSA-v3rj-xjv7-4jmq in your dependencies? Fencer shows which of your repositories are affected as soon as an advisory lands, and opens the fix as a pull request.

Check with Fencer

CVSS scores

assigned by version score vector
GitHub 3.1 5.3 CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L

Affected packages

ecosystem package affected fixed in
npm smol-toml
<1.6.1
1.6.1

Classification

Weakness

References

Sources

Fencer Intel keeps one entry per vulnerability: the CVE id wins, then GHSA, and records that alias each other are merged, except that two CVEs always keep separate entries. The same data is available as JSON.

The maintainers of squirrelchat/smol-toml published their own advisory on GitHub. Reviewed sources take precedence over it.