{"id":"RUSTSEC-2026-0366","summary":"Stack overflow when parsing deeply nested input in pest_grammars","details":"## Impact\n\nIn affected versions, parsing deeply nested input with `pest_grammars::json::JsonParser` can exhaust the native stack and abort the hosting process. Applications that accept attacker-controlled JSON without suitable resource limits may therefore be vulnerable to denial of service.\n\nThe reported reproduction demonstrates this behavior with deeply nested JSON arrays. The nesting required to trigger an overflow depends on the platform, available stack space, and build configuration; there is no portable safe nesting threshold.\n\n## Patches\n\nUpgrade to `pest_grammars` 2.9.3 or later.\n\nVersion 2.9.3 requires the updated `pest` runtime and includes regression tests for deeply nested JSON with the optional call budget disabled. Supported std builds automatically check available native stack headroom at parser checkpoints and return a handled stack limit reached error when insufficient space is detected. This protection operates independently of `pest::set_call_limit()`. See the [2.9.3 dependencies](https://github.com/pest-parser/pest/blob/v2.9.3/grammars/Cargo.toml#L16-L18) and [deep-nesting regression tests](https://github.com/pest-parser/pest/blob/v2.9.3/grammars/src/lib.rs#L94-L215).\n\nThese checks are best-effort. They do not provide universal stack-overflow protection, apply when stack bounds cannot be determined, or provide native-stack protection in no_std builds.\n\n## Workarounds and defense in depth\n\nApplications unable to upgrade should reject excessive nesting before invoking the affected parser or configure a suitably conservative `pest::set_call_limit()` budget. A call budget is not a portable stack-depth guarantee.\n\nEven after upgrading, applications parsing untrusted input should enforce workload-appropriate input, work, memory, and concurrency limits. Stack checks and call budgets do not enforce elapsed-time deadlines. Where a hard deadline or cancellation is required, use supervised parsing as described in the [security policy: Parsing Untrusted Input](https://github.com/pest-parser/pest/security/policy#parsing-untrusted-input).","aliases":["GHSA-7632-4q2x-hvjw"],"modified":"2026-10-16T23:30:02.385972501Z","published":"2026-10-16T12:00:00Z","database_specific":{"license":"CC0-1.0"},"references":[{"type":"PACKAGE","url":"https://crates.io/crates/pest_grammars"},{"type":"ADVISORY","url":"https://rustsec.org/advisories/RUSTSEC-2026-0366.html"},{"type":"WEB","url":"https://github.com/pest-parser/pest/pull/1212"}],"affected":[{"package":{"name":"pest_grammars","ecosystem":"crates.io","purl":"pkg:cargo/pest_grammars"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0.0.0-0"},{"fixed":"2.9.3"}]}],"ecosystem_specific":{"affects":{"os":[],"functions":["pest_grammars::json::JsonParser::parse"],"arch":[]},"affected_functions":null},"database_specific":{"informational":null,"source":"https://github.com/rustsec/advisory-db/blob/osv/crates/RUSTSEC-2026-0366.json","categories":["denial-of-service"],"cvss":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:L"}}],"schema_version":"1.9.0","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:L"}]}