Project

General

Profile

Actions

Security #8642

open
JI PA

detect/file_data: heap buffer overflow in SWF decompression depth handling

Security #8642: detect/file_data: heap buffer overflow in SWF decompression depth handling

Added by Jason Ish 14 days ago. Updated about 9 hours ago.

Status:
Resolved
Priority:
Normal
Target version:
Affected Versions:
Label:
CVE:
Git IDs:
Severity:
LOW
Disclosure Date:

Description

Summary

Suricata's HTTP SWF decompression path can trigger a heap buffer overflow when
swf-decompression.decompress-depth is configured to a uint32_t value that
wraps after the internal SWF header adjustment. An ASAN-enabled build aborts in
FileSwfDecompression() with a 4 GiB zero-fill write.

Affected code

Confirmed on Suricata 9.0.0-dev, commit 0eda09f302 from 2026-06-03, built
with ASAN.

Relevant files:

  • src/util-file-decompression.c
  • src/detect-file-data.c

The vulnerable path is reached from HTTP to-client file_data inspection when
SWF decompression is enabled:

  • FiledataGetDataCallback() calls FileSwfDecompression() for HTTP1
    to-client file data if htp_state->cfg->swf_decompression_enabled is true
    and the file data starts with a compressed SWF signature.
  • FileSwfDecompression() computes decompressed_data_len from the configured
    decompress_depth, then unconditionally adds 8 bytes for the generated FWS
    header.

Root cause

In FileSwfDecompression():

uint32_t decompressed_data_len =
    (decompress_depth == 0) ? decompressed_swf_len : decompress_depth;
decompressed_data_len += 8;

SCInspectionBufferCheckAndExpand(out_buffer, decompressed_data_len);
...
out_buffer->len = decompressed_data_len;
...
memset(out_buffer->buf + 8, 0, decompressed_data_len - 8);

With decompress-depth=4294967295, decompressed_data_len += 8 wraps to 7.
The inspection buffer is only expanded to the default 4096-byte allocation, but
the later memset(out_buffer->buf + 8, 0, decompressed_data_len - 8) underflows
the length argument to 4294967295 and writes zeros past the heap allocation.

Reproducer

The full reproducer will be provided in a suricata-verify test submitted
separately. That test includes a pcap with a single HTTP transaction returning a
small zlib-compressed CWS SWF file, plus a file_data rule that reaches the
HTTP file-data inspection path.

After the suricata-verify test is submitted, run from a Suricata ASAN build
using the pcap from that test:

ASAN_OPTIONS=abort_on_error=1:detect_leaks=0 \
src/suricata \
  -c suricata.yaml \
  -S <suricata-verify-test>/test.rules \
  -r <suricata-verify-test>/input.pcap \
  -l /tmp/suri-swf-depth-wrap \
  --runmode single \
  -k none \
  --set app-layer.protocols.http.libhtp.default-config.swf-decompression.enabled=yes \
  --set app-layer.protocols.http.libhtp.default-config.swf-decompression.decompress-depth=4294967295

Observed result

Suricata aborts with ASAN:

ERROR: AddressSanitizer: heap-buffer-overflow
WRITE of size 4294967295
    #1 FileSwfDecompression src/util-file-decompression.c:149
    #2 FiledataGetDataCallback src/detect-file-data.c:456

0 bytes after 4096-byte region allocated by:
    #2 SCInspectionBufferCheckAndExpand src/detect-engine-inspect-buffer.c:227
    #3 FileSwfDecompression src/util-file-decompression.c:132

Expected result

Suricata should not perform an out-of-bounds write or abort when processing the
traffic under this configuration.

Impact

This is config-dependent. A packet alone is not sufficient; the vulnerable path
requires:

  • HTTP SWF decompression enabled.
  • A rule or other detection path that inspects HTTP to-client file_data.
  • A wrapping swf-decompression.decompress-depth value.

The demonstrated impact is denial of service / memory safety violation. No
credible RCE path was identified from this primitive: the overwrite is a huge
zero-fill, the byte value is fixed, and the size is controlled by configuration
rather than packet contents.

Validation

  • With decompress-depth=4294967295, the ASAN build aborts with exit 134.
  • With normal SWF decompression depth, the same pcap and rule complete cleanly
    and emit one file_data alert, confirming reachability of the SWF
    decompression path.
  • A suricata-verify regression test has been prepared
    and will be submitted separately.

Found by GPT 5.5 using Codex.


Subtasks 2 (2 open0 closed)

Security #8643: detect/file_data: heap buffer overflow in SWF decompression depth handling (8.0.x backport)In ReviewPhilippe AntoineActions
Security #8644: detect/file_data: heap buffer overflow in SWF decompression depth handling (7.0.x backport)AssignedPhilippe AntoineActions

Related issues 1 (1 open0 closed)

Related to Suricata - Task #6179: tracking: flash decompression deprecation and removalAssignedVictor JulienActions

JI Updated by Jason Ish 14 days ago Actions #1

  • Description updated (diff)

JI Updated by Jason Ish 14 days ago Actions #2

  • File deleted (gen_swf_cws_http.py)

JI Updated by Jason Ish 14 days ago Actions #3

  • File deleted (filedata-swf.rules)

JI Updated by Jason Ish 14 days ago Actions #4

  • File deleted (repro-swf-depth-wrap.sh)

JI Updated by Jason Ish 14 days ago Actions #5

  • File deleted (repro-swf-depth-wrap.out)

JI Updated by Jason Ish 14 days ago Actions #6

  • Description updated (diff)

JI Updated by Jason Ish 14 days ago Actions #7

  • Description updated (diff)
  • Status changed from New to Triaged
  • Target version changed from TBD to 9.0.0-beta1
  • Label Needs backport to 7.0, Needs backport to 8.0 added

OT Updated by OISF Ticketbot 14 days ago Actions #8

  • Subtask #8643 added

OT Updated by OISF Ticketbot 14 days ago Actions #9

  • Label deleted (Needs backport to 8.0)

OT Updated by OISF Ticketbot 14 days ago Actions #10

  • Subtask #8644 added

OT Updated by OISF Ticketbot 14 days ago Actions #11

  • Label deleted (Needs backport to 7.0)

JI Updated by Jason Ish 14 days ago Actions #12

SV test submitted to GL.

JI Updated by Jason Ish 14 days ago Actions #13

  • Severity set to LOW

JI Updated by Jason Ish 8 days ago Actions #14

  • Related to Task #6179: tracking: flash decompression deprecation and removal added

PA Updated by Philippe Antoine 6 days ago Actions #15

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

PA Updated by Philippe Antoine 6 days ago Actions #16

  • Status changed from Assigned to In Review

Gitlab MR

JI Updated by Jason Ish about 19 hours ago Actions #18

  • Private changed from Yes to No

JI Updated by Jason Ish about 19 hours ago Actions #19

  • GHSA set to GHSA-p33j-r48q-3jcf

PA Updated by Philippe Antoine about 9 hours ago Actions #20

  • Status changed from In Review to Resolved
Actions

Also available in: PDF Atom