Skip to content

BUG: Deeply-nested MIME BODYSTRUCTURE recursion can stack-overflow #1170

@andrinoff

Description

@andrinoff

Describe the bug

fetcher/fetcher.go walks the BODYSTRUCTURE tree recursively (checkPart and friends). A maliciously-crafted message with deeply nested multipart/related (a thousand levels) blows the goroutine stack. Go's default 1MB goroutine stack starts to be a real limit at ~10k-100k frames depending on locals.

Expected behavior

Either:

  • limit recursion depth to ~64 (RFC 2046 doesn't specify but anything deeper is pathological)
  • convert the walk to an explicit work queue.

Why it's hard

The walk is sprinkled across multiple sites in fetcher; the right fix is a shared walkPart iterator that all call sites use. That refactor is the work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingchore

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions