Skip to content

harden(sip-parser): extract_uri must not panic on '>' before '<' (#114) - #118

Closed
ryanmurf wants to merge 1 commit into
masterfrom
hardening/proto-parser-panics
Closed

harden(sip-parser): extract_uri must not panic on '>' before '<' (#114)#118
ryanmurf wants to merge 1 commit into
masterfrom
hardening/proto-parser-panics

Conversation

@ryanmurf

@ryanmurf ryanmurf commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Fixes #114. Rebased onto master; the Content-Length char-boundary panic originally bundled here (#112) was fixed independently by #113/#108 and dropped. This PR is now just the distinct extract_uri bug.

Finding

extract_uri computed start=find('<'), end=find('>'), then header_value[start+1..end]. A SIP header value with '>' before the URI '<' — legal in a quoted display-name, e.g. "a>b" sip:carol@host — makes end < start, a reversed byte range that panics. Reachable from the request path (dialog creation, registrar, ACL) on attacker-controlled From/To/Contact headers; called inline from SipStack::run so the panic aborts the SIP receive loop (remote unauthenticated DoS).

Fix

Search for '>' only in the tail after '<' (also more correct: matches the bracket that closes the URI).

Tests + RED control

Three regression tests. With the fix reverted, the two panic-guards FAIL RED (panic at parser/mod.rs:867), the well-formed guard passes. With the fix: asterisk-sip lib green, full cargo test --workspace --exclude pjsip-shim green, clippy -D warnings clean. Toolchain 1.97.0.

Generated with Claude Code

`extract_uri` computed `start = find('<')`, `end = find('>')` and sliced
`header_value[start+1..end]`. A SIP header whose value contains a '>' before
the URI's '<' — legal in a quoted display-name, e.g. `"a>b" <sip:carol@host>`
— makes `end < start`, a reversed byte range that panics. Reachable from the
request-handling path (dialog creation, registrar, ACL) on attacker-controlled
From/To/Contact headers; the panic aborts the SIP receive loop (DoS).

Search for '>' only in the tail after '<' (also more correct: it matches the
bracket that closes the URI, not an earlier one in the display-name).

Regression tests added; both panic-guards fail RED (panic at the slice) with
the fix reverted, while the well-formed guard passes in both states.

Fixes #114. (The Content-Length char-boundary panic originally bundled here,
#112, was fixed independently on master by #113/#108 — dropped from this PR.)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XH6jhrG4ZCL8xfCktK4Zms
@ryanmurf
ryanmurf force-pushed the hardening/proto-parser-panics branch from c639870 to 85c5b9d Compare July 17, 2026 00:49
@ryanmurf ryanmurf changed the title harden(sip-parser): reject malformed input instead of panicking (#112, #114) harden(sip-parser): extract_uri must not panic on '>' before '<' (#114) Jul 17, 2026
@ryanmurf ryanmurf closed this Jul 17, 2026
@ryanmurf ryanmurf reopened this Jul 17, 2026
@ryanmurf

Copy link
Copy Markdown
Owner Author

Superseded by #120 (fix #109), which landed the same extract_uri reversed-range fix on master (via a start < end guard). My change is now redundant. Closing; the finding is tracked/fixed under #109/#120.

@ryanmurf ryanmurf closed this Jul 17, 2026
@ryanmurf
ryanmurf deleted the hardening/proto-parser-panics branch July 17, 2026 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DoS: extract_uri panics on a From/To/Contact header with '>' before '<' (reversed byte range)

1 participant