GHSA-pqhp-25j4-6hq9: Smol toml Denial of Service Vulnerability

MODERATE
CVSS 5.3
CWE-674
Published
Advisory Summary

GHSA-pqhp-25j4-6hq9 is a MODERATE (CVSS 5.3) denial of service vulnerability (CWE-674: Uncontrolled Recursion) affecting Smol toml libraries in the npm ecosystem. The issue involves smol-toml has a denial of service via malicious toml document using deeply nested inline tables. Remediation is available by upgrading affected packages to version 1.3.1.

GHSA-pqhp-25j4-6hq9 at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-pqhp-25j4-6hq9
Severity MODERATE
CVSS v3.1 Base Score 5.3
CWE Classification CWE-674: Uncontrolled Recursion
Affected Product Smol toml
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 5.3

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability Low (A:L)

How to Fix GHSA-pqhp-25j4-6hq9

To remediate this vulnerability, upgrade all affected Smol toml dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

smol-toml fixed: 1.3.1
npm install smol-toml@1.3.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls smol-toml

How to Check if You Are Affected

To determine whether your Node.js application is affected by GHSA-pqhp-25j4-6hq9, inspect your project dependencies using npm:

npm ls smol-toml

Analyze the terminal output to locate any version of Smol toml in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.3.1), your application is affected.

Note: The npm ls smol-toml command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-674: Uncontrolled Recursion, where the product does not properly control the amount of recursion that takes place, consuming excessive resources, such as allocated memory or the program stack. In Smol toml, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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.

GHSA-pqhp-25j4-6hq9 Affected Smol toml Versions

1 component(s)
Fixed Versions:
1.3.1
Product / Package Ecosystem Affected Versions Fixed Version
smol-toml
npm
< 1.3.1
1.3.1

References

Frequently Asked Questions

What is GHSA-pqhp-25j4-6hq9?
GHSA-pqhp-25j4-6hq9 is a security vulnerability in Smol toml involving smol-toml has a Denial of Service via malicious TOML document using deeply nested inline tables under CWE-674: Uncontrolled Recursion.
Which Smol toml versions are affected?
Affected versions include releases prior to 1.3.1 across affected packages: smol-toml.
What version fixes GHSA-pqhp-25j4-6hq9?
Upgrading to 1.3.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is smol-toml affected?
Yes, smol-toml is affected in releases prior to 1.3.1. Upgrade your dependency to 1.3.1 or later.
What is the CVSS score of GHSA-pqhp-25j4-6hq9?
GHSA-pqhp-25j4-6hq9 has a CVSS v3.1 base score of 5.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L.
What CWE is associated with GHSA-pqhp-25j4-6hq9?
GHSA-pqhp-25j4-6hq9 is classified under 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 can I check npm dependencies for GHSA-pqhp-25j4-6hq9?
Run the dependency tree command: 'npm ls smol-toml'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-pqhp-25j4-6hq9",
  "modified" : "2024-11-22T20:40:49Z",
  "published" : "2024-11-22T20:40:49Z",
  "aliases" : [ ],
  "summary" : "smol-toml has a Denial of Service via malicious TOML document using deeply nested inline tables",
  "details" : "### Summary\nAn 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.\n\nThe library does not limit the maximum exploration depth while parsing or producing TOML documents, nor does it offer a way to do so.\n\n### Proof of concept\n```js\nrequire(\"smol-toml\").parse(\"e=\" + \"{e=\".repeat(9999) + \"{}\" + \"}\".repeat(9999))\n```\n\n### Impact\nApplications 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.\n\nDue to the design of most JavaScript runtimes, the uncontrolled recursion does not lead to excessive memory usage and the execution is quickly aborted.\n\nAs a reminder, it is **strongly** advised when working with untrusted user input to expect errors to occur and to appropriately catch them.\n\n### Patches\nVersion 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.\n\n**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.\n\n### Workarounds\nWrap all invocations of `parse` and `stringify` in a try/catch block.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "smol-toml"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.3.1"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.3.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/squirrelchat/smol-toml/security/advisories/GHSA-pqhp-25j4-6hq9"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/squirrelchat/smol-toml/commit/405108ba090f0fc78f99aa2f0d6721e499b0ff27"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/squirrelchat/smol-toml"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-674" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-11-22T20:40:49Z",
    "nvd_published_at" : null
  }
}