Built for input you don't trust
A crawler parses pages nobody vouches for. Parsec assumes whoever wrote the page has read its source and wants the program that embeds it to crash, hang or run out of memory.
Found a problem?
Please don't open a public issue. Report it privately through GitHub's vulnerability form, with the input that triggers it if you can. You'll hear back within a week, and the fix ships with an advisory crediting you, unless you'd rather not be named. SECURITY.md says what's in scope.
What an attacker controls
The input: any length up to the cap, any bytes, any nesting, any tag soup. Sometimes a selector or an XPath query too, when a program passes a user's query straight through. What they can't do is run code inside your program, because nothing in Parsec runs scripts, in any language, and that isn't planned.
What the HTML parser promises
- No memory unsafety: no out-of-bounds access, no use after free, no data race. It's safe Rust, with one
unsafeblock in the parser and its reasoning written beside it. - No crash from depth: the page decides how deep the tree is, never how deep the call stack goes.
- No panic on malformed input: every string parses to a tree, as the HTML Standard requires.
- No unbounded time when you ask for a bound: give a parse a time budget and it returns an error instead of running on.
Node handles are ids into an arena that never frees or reuses a slot, so a node you kept after removing it reads as nothing rather than as someone else's memory. The docs' assurance case goes through each weakness, what an attacker would try and the evidence for the defence.
Limits you can set
| Parser | Limits |
|---|---|
| HTML | A time budget per parse, a cap on input size, and a depth limit that flattens the tree as Chromium does. |
| JavaScript | A depth limit, 256 by default, past which it returns an error rather than overflowing the stack; a step budget; and an input cap checked before any work starts. |
| XML | Element depth, 2,048 by default; entity nesting, 16 by default and never past 64; expansion capped at 1 MiB plus 8 bytes per byte of input; and optional caps on steps and input size. |
| Selectors | Nesting inside a selector is capped at 32, and matching can be given a step limit. |
So a billion laughs, ten XML entities each referring to the last ten times, stops in milliseconds. So does a million nested (((( in a script. The docs' Limits and hostile input page has the inputs and the timings.
What keeps looking for mistakes
- Fuzzing every night, with eight targets across the HTML, CSS, JavaScript and XML parsers.
- Hostile-input tests, each added with the fix for an input found to be slow or crashing, and tests that fail if four times the input takes more than eight times as long.
- CodeQL on every pull request and every week.
- A recorded security review of the parser.
How the project itself is protected
main changes only through reviewed pull requests that pass CI on Linux, macOS and Windows. Every GitHub Action is pinned to a commit hash. Releases are tags signed by a maintainer's key, and the release workflow refuses any other. The crates rebuild byte for byte, and the packages on crates.io, PyPI and npm are published through trusted publishing with attestations, not with a token someone could leak.
What isn't covered yet
Linear time is tested for every hostile pattern found so far, not proven for every possible input. Until it is, if you parse pages from strangers, set a time budget. A depth limit keeps the tree shallow, but it doesn't bound the time on its own.