Skip to content

panic on Option::unwrap() in parse.rs:2367 via crafted markdown input (reachable from safe API) #1097

Closed

Description

@mariofeter

Summary

pulldown_cmark::Parser::new(s) followed by event iteration panics on crafted markdown input. The panic occurs at parse.rs:2367 inside an Option::unwrap() site in the parser state machine.

This is a reachable panic from the safe public API. Any application that renders user-provided markdown without explicit panic isolation (catch_unwind) crashes on this input.

Affected version

pulldown-cmark 0.13.3 (latest as of 2026-05-12)

Panic trace

thread '<unnamed>' panicked at pulldown-cmark-0.13.3/src/parse.rs:2367:37:
called `Option::unwrap()` on a `None` value
==ERROR: libFuzzer: deadly signal

Reproducer

Harness:

#![no_main]
use libfuzzer_sys::fuzz_target;
use pulldown_cmark::Parser;

fuzz_target!(|data: &[u8]| {
    if let Ok(s) = std::str::from_utf8(data) {
        let _: Vec<_> = Parser::new(s).collect();
    }
});

Crash input (1770 bytes) available at: https://github.com/mariofeter/secureloop-findings-public/blob/master/findings/pulldown-cmark/2026-05-007_parser_panic/repro.bin

First 64 bytes:

00000000: 323c 2d0b 7a5f 0a2d 0a2d 0a0a 2d0a 0a2d  2<-.z_.-.-..-..-
00000010: 100a 2d0a 0a2d 0a0a 2d10 0a0a 2d0a 0a2d  ..-..-..-...-..-
00000020: 0a0a 2d0a 0a0a 320a 0a2d 0a0a 2d0a 0a10  ..-...2..-..-...
00000030: 0a2d 0a60 5b31 5b5d 5b0a 3100 0000 0a1f  .-.`[1[][.1.....

Pattern: many - heading-underline tokens interleaved with [1[][ link-like sequences and newlines.

Build

RUSTFLAGS='-Cpasses=sancov-module -Cllvm-args=-sanitizer-coverage-level=3 \
-Cllvm-args=-sanitizer-coverage-inline-8bit-counters \
-Cllvm-args=-sanitizer-coverage-pc-table \
-Cllvm-args=-sanitizer-coverage-trace-compares \
-Zsanitizer=address' \
cargo +nightly build --release -Zbuild-std --target x86_64-unknown-linux-gnu
ASAN_OPTIONS=abort_on_error=0:halt_on_error=0:exitcode=0:detect_leaks=0:handle_abort=0 \
  ./target/x86_64-unknown-linux-gnu/release/parser_run_strwrap repro.bin

Severity

Medium — DoS reachable from safe code. Not memory corruption.

Discovery

Found by SecureLoop, an ML-guided fuzzing orchestrator. Time-to-crash: 3 minutes from empty corpus. This issue is filed at maintainer's request to reference PR #1096.

Activity

  1. notriddle commented on May 26, 2026

    @notriddle
    Collaborator

    Fixed by #1096

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions