Skip to content

Fix use-after-free in header info classes causing buffer corruption#583

Merged
haga-rak merged 1 commit into
mainfrom
fix/header-info-pooled-memory-uaf
Mar 20, 2026
Merged

Fix use-after-free in header info classes causing buffer corruption#583
haga-rak merged 1 commit into
mainfrom
fix/header-info-pooled-memory-uaf

Conversation

@haga-rak
Copy link
Copy Markdown
Owner

Summary

  • RequestHeaderInfo, HeaderFieldInfo, and ResponseHeaderInfo stored ReadOnlyMemory<char> slices pointing directly into MemoryPool<char> buffers managed by ExchangeScope. When the scope was disposed and the buffer was recycled for subsequent HTTP traffic, lazily-evaluated properties like ExchangeInfo.FullUrl would read corrupted data from the reused buffer.
  • Materialize pooled Memory<char> slices into string-backed memory via .ToString().AsMemory() at construction time in RequestHeaderInfo and HeaderFieldInfo, so the data is owned and not subject to pool recycling.
  • Eagerly evaluate header LINQ projections with .ToList() in RequestHeaderInfo and ResponseHeaderInfo to prevent deferred enumeration after the backing buffer has been returned to the pool.

RequestHeaderInfo, HeaderFieldInfo, and ResponseHeaderInfo stored
ReadOnlyMemory<char> slices pointing directly into MemoryPool<char>
buffers managed by ExchangeScope. When the scope was disposed and
the buffer recycled, lazily-evaluated properties like ExchangeInfo.FullUrl
would read corrupted data from the reused buffer.

Materialize pooled Memory<char> slices into string-backed memory at
construction time, and eagerly evaluate header LINQ projections with
ToList() to prevent deferred enumeration after buffer recycling.
@haga-rak haga-rak merged commit b262c85 into main Mar 20, 2026
3 of 4 checks passed
@haga-rak haga-rak deleted the fix/header-info-pooled-memory-uaf branch March 20, 2026 13:48
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.

1 participant