Project

General

Profile

Actions

Security #9185

closed
JI PA

http2: OOM as header inspection rebuilds every header block without a cap

Security #9185: http2: OOM as header inspection rebuilds every header block without a cap

Added by Jason Ish about 2 months ago. Updated 7 days ago.

Status:
Closed
Priority:
Normal
Target version:
Affected Versions:
Label:
CVE:
Git IDs:

cb19c09a583fe8c3484ae05fa44ac6aabe508c90

Severity:
HIGH
Disclosure Date:
01/07/2027

Description

Summary

http.header asks SCHttp2TxGetHeaders to clear a thread buffer and copy every decoded header block on the transaction back into one contiguous buffer. There is no byte ceiling. InspectionBufferClean then drops inspect, so the next packet that inspects the same transaction builds the buffer again from scratch. HPACK dynamic-table indexes make that copy much larger than the bytes on the wire: one 65503-byte value referenced by a one-byte index is copied once per reference. On Suricata 8.0.7 a 100000-byte header block (about 100096 bytes with framing) expands to roughly 2.1GiB and the process is OOM-killed. A small request with the same rule and the same 1GiB cap stays up and alerts. Unpack the attachment and run ./verify.sh to reproduce.

Affected Versions

Confirmed on Suricata 8.0.7 RELEASE, the image jasonish/suricata:latest resolved to at test time. HTTP/2 parsing is enabled in that image's default configuration. The packaged ruleset does not contain http.header, so the path runs only when a signature selects that buffer (or http.header.raw). Adding such a signature is ordinary policy, not a disabled safety check.

Preconditions

The sensor must be parsing HTTP/2 and must have at least one signature that inspects http.header or http.header.raw. The sender only needs to put HTTP/2 on a link the sensor sees. No Suricata account is required.

Security Impact

The worker that rebuilds the header buffer allocates until the process is killed. In this run the container limit and swap limit were both 1GiB. After the expanded request, OOMKilled was true and the exit code was 137. The same limit and the same rule survived a normal small-header exchange at about 35MiB and produced the alert, so the kill is the rebuild, not the cap being too small to start Suricata.

This shows a detection-process crash. It does not show code execution or a logic bypass. The cgroup cap kept the kill inside the container. Without an external cap the same copy is about 2.1GiB from about 100KB on the wire, and it can be larger up to the header reassembly budget.

Vulnerable Code

rust/src/http2/detect.rs (8.0.7), SCHttp2TxGetHeaders. SCHttp2TxGetHeadersRaw is the same loop without the cookie skip. clear does not free capacity, and nothing stops extend_from_slice.

tbuf.data.clear();
for frame in frames {
if let Some(blocks) = http2_header_blocks(frame) {
for block in blocks.iter() {
if !http2_header_iscookie(direction.into(), &block.name) {
tbuf.data.extend_from_slice(&block.name);
tbuf.data.extend_from_slice(b": ");
tbuf.data.extend_from_slice(http2_header_trimspaces(&block.value));
tbuf.data.extend_from_slice(b"\r\n");
}
}
}
}

src/detect-http-header.c calls that function whenever inspect is NULL (GetBuffer2ForTX). src/detect-engine-inspect-buffer.c InspectionBufferClean sets inspect back to NULL after the packet's transaction inspection. Indexed blocks share an Rc in the parser, so storing them is cheap. The detect copy does not share them.

The dynamic table starts at 4096 bytes (HTTP2DynTable::new). A header-block size update can raise it to HTTP2_MAX_TABLESIZE (65536). Header-plus-continuation reassembly stops at HTTP2_MAX_REASS (102400). That cap limits wire bytes, not the copied buffer.

Call Chain

http.header signature -> DetectAppLayerInspectEngineRegister("http_header", ALPROTO_HTTP2, ...) in src/detect-http-header.c -> GetBuffer2ForTX (src/detect-http-header.c:147) -> SCHttp2TxGetHeaders (src/detect-http-header.c:159, rust/src/http2/detect.rs:904) -> unbounded extend_from_slice (rust/src/http2/detect.rs:909). http.header.raw takes the twin path through GetData2 and SCHttp2TxGetHeadersRaw (src/detect-http-raw-header.c:227, rust/src/http2/detect.rs:938). After inspection, InspectionBufferClean (src/detect-engine-inspect-buffer.c:30) clears inspect.

Payload

One client header block, no END_STREAM until the block is complete:

  1. HPACK dynamic table size update to 65536.
  2. Static indexes for :method GET, :path /, :scheme http.
  3. One incremental-indexing literal, name x, value 65503 bytes (entry size 32 + 1 + 65503 = 65536).
  4. 34483 indexed references to dynamic index 62, each a single byte 0xBE.

The HPACK block is 100000 bytes, split into HEADERS and CONTINUATION frames of at most 16384 bytes, under the 102400-byte reassembly cap. Each copied field is 65508 bytes (x: + value + CRLF). With the pseudo-headers, the rebuilt buffer is 2258977915 bytes. The whole TCP payload, magic and framing included, is 100096 bytes.

The rule that forces the copy is:

alert http any any -> any any (msg:"HTTP header buffer inspected"; flow:to_server,established; http.header; content:"x-e2e-mark"; sid:1000001; rev:1;)

Reproduction

Image jasonish/suricata:latest (8.0.7 RELEASE). The sink is python:3.11-slim only because it is a TCP acceptor with no extra packages. The host connects to 127.0.0.1:18480, published to h2oom-app:80 on bridge br-h2oom (network suri-h2oom, 172.31.1.0/24). h2oom-suri uses host networking to sniff that bridge, with --memory 1024m and --memory-swap 1024m. -k none is required because bridge checksum offload would otherwise drop the packets. --runmode single keeps the quiet sensor near 35MiB so the 1GiB cap still has room for a normal header inspection. The unbounded copy is in that worker either way.

./verify.sh
control alerts 0->1 running=True oom_killed=False stats='34.47MiB / 1GiB'
attack warmup alerts 1->2 bomb_sent=True running=False oom_killed=True exit=137 rebuild_bytes=2258977915
control_alert=true
control_oom_killed=false
attack_warmup_alert=true
attack_oom_killed=true
attack_exit_code=137
memory_limit=1073741824
memory_swap=1073741824
VERDICT: PASS

Fix Recommendation

Stop SCHttp2TxGetHeaders and SCHttp2TxGetHeadersRaw once the copied buffer reaches a hard byte limit, and raise an app-layer event instead of growing the Vec without bound. Keep the built buffer for the transaction until the header frame set actually changes, so InspectionBufferClean does not force a full recopy on every later packet. A limit on decoded header-block count would shrink the parser side, but the crash is the detect copy of index references that already share storage.


Files


Subtasks 1 (0 open — 1 closed)

Security #9189: http2: OOM as header inspection rebuilds every header block without a cap (8.0.x backport)ClosedPhilippe AntoineActions

JI Updated by Jason Ish about 2 months ago Actions #1

  • Status changed from New to Triaged
  • Severity set to HIGH
  • Label Needs backport to 8.0 added

Possibly high as it leads to resource exhaustion.

JI Updated by Jason Ish about 2 months ago Actions #2

  • Target version changed from TBD to 9.0.0-beta1

OT Updated by OISF Ticketbot about 2 months ago Actions #3

  • Subtask #9189 added

OT Updated by OISF Ticketbot about 2 months ago Actions #4

  • Label deleted (Needs backport to 8.0)

JI Updated by Jason Ish about 1 month ago Actions #5

  • Status changed from Triaged to Assigned
  • Assignee changed from OISF Dev to Philippe Antoine

PA Updated by Philippe Antoine about 1 month ago Actions #6

  • Label Needs backport to 8.0 added

Agreeing with HIGH severity

OT Updated by OISF Ticketbot about 1 month ago Actions #7

  • Label deleted (Needs backport to 8.0)

PA Updated by Philippe Antoine about 1 month ago Actions #8

  • Status changed from Assigned to In Review

Gitlab MR

JI Updated by Jason Ish about 1 month ago Actions #9

  • GHSA set to GHSA-pq9f-8f7w-6x8g

SB Updated by Shivani Bhardwaj about 1 month ago Actions #10

  • Subject changed from http2: header inspection rebuilds every header block without a byte cap and OOM-kills Suricata to http2: OOM as header inspection rebuilds every header block without a cap

PA Updated by Philippe Antoine 25 days ago Actions #11

  • Status changed from In Review to Resolved

staged

JI Updated by Jason Ish 25 days ago Actions #12

  • Git IDs updated (diff)

PA Updated by Philippe Antoine 25 days ago Actions #13

  • Status changed from Resolved to Closed

JI Updated by Jason Ish 7 days ago Actions #14

  • Private changed from Yes to No
Actions

Also available in: PDF Atom