TOCTOU Race Condition in RemoteImageDecoderAVFProxy
CVE: CVE-2026-112669 · Safari 27.2 · Released October 26, 2026 Impact: Processing maliciously crafted web content may lead to an unexpected Safari crash Apple's description: A race condition was addressed with improved state handling. Credit: remanone (@remanone_)
Medium. The GPU process parsed image bytes straight out of pages the content process could still write. Apple lists a crash. Corruption is possible only if the AVFoundation parser re-reads a field after checking it, and that is the condition for this becoming a sandbox-escape stage.
Safari decodes some image formats outside the sandboxed process that runs page content, in a more privileged GPU process that can reach system media frameworks such as AVFoundation. On the GPU side, RemoteImageDecoderAVFProxy is the IPC endpoint that hosts those AVFoundation-backed decoders for the content process: it accepts encoded bytes through messages like createDecoder and setData and returns frame metadata and decoded bitmaps. Bytes that cross from the less trusted process into the more trusted one should be snapshotted before anything validates or parses them. One handler in this proxy skipped that snapshot.
The angle: A content process acting against the GPU process could keep rewriting encoded image bytes while the privileged side was still parsing them, so any check the decoder made could be stale by the time it used the value.
Source/WebKit/GPUProcess/media/RemoteImageDecoderAVFProxy.cpp
Patch Details
The fix changes one expression in RemoteImageDecoderAVFProxy::setData(). This is the GPU-process handler that appends encoded image bytes from the WebContent process to an existing ImageDecoderAVFObjC instance, which it looks up by ImageDecoderIdentifier.
The non-null branch used to build the decoder's input with data.unsafeBuffer().releaseNonNull(). On an IPC::SharedBufferReference, unsafeBuffer() wraps the sender's shared-memory mapping in a SharedBuffer without copying it. The replacement, SharedBuffer::create(data.span()), copies the mapped bytes into memory the GPU process owns. That copy happens before imageDecoder->setData(...), frameCount(), and frameInfos() read anything.
The rest of the diff is cosmetic:
- The null branch,
SharedBuffer::create(), is unchanged. - The only other change is wrapping the call across three lines.
The new form matches what the sibling handler RemoteImageDecoderAVFProxy::createDecoder() in the same file already did, which was SharedBuffer::create(data.span()). The fix therefore adds no new defensive mechanism. It brings the append path in line with the ingestion policy the create path had always followed.
Background
Multi-process isolation. WebKit runs untrusted page content in a sandboxed WebContent process. Media decoding and graphics work run in a separate GPU process, which has more privileges and can reach system media frameworks. The two communicate over IPC. The GPU process has to treat every incoming message as untrusted input, because the reason the boundary exists is that WebContent may be compromised.
Shared-memory buffers over IPC.
Large byte payloads do not travel inline in a message. IPC::SharedBufferReference is the IPC type for passing them:
- The sender places the bytes in a
SharedMemoryregion. - The sender transmits a handle to that region.
- The receiver maps the region into its own address space.
The pages backing that mapping are the same physical pages the sender wrote, so the sender's view and the receiver's view are two windows onto one buffer.
Three ways to consume a SharedBufferReference.
On the receiving side there are three relevant accessors:
| Accessor | What it does |
|---|---|
span() |
Exposes the mapped bytes for reading. |
SharedBuffer::create(span) |
Copies those bytes into a new allocation the receiver owns. |
unsafeBuffer() |
Wraps the mapping itself in a SharedBuffer with no copy. |
The unsafe prefix marks that the resulting buffer aliases memory another process still has mapped.
Double-fetch (TOCTOU). A double-fetch is code reading the same memory location more than once while another party can change it between reads. The typical case is reading once to validate and again to use. Time-of-check-to-time-of-use (TOCTOU) is the general name for this class. Once a check and its use read separate copies of the "same" value, the check guarantees nothing about the value that gets used.
ImageDecoderAVFObjC.
This is WebCore's image decoder for formats AVFoundation handles, such as animated or video-backed image types. It accumulates encoded data through setData(buffer, allDataReceived) and reports frameCount(), size(), hasTrack(), and frameInfos(). The GPU-process proxy owns a map of these decoders keyed by identifier, and each IPC message is routed to one of them.
Analysis
The bug is a cross-process double-fetch: the privileged-side parser was handed a buffer aliased to memory the less-trusted sender could still write.
WebContent (sender) │ GPU process (receiver)
────────────────────────────────────────┼─────────────────────────────────
write encoded bytes into SharedMemory │
send setData(SharedBufferReference) ────┼─► map region
│ unsafeBuffer() → alias, no copy
│ decoder->setData() read #1
rewrite bytes (mapping still writable) ·┼·► (same physical pages)
│ frameCount() read #2
rewrite bytes again ····················┼·► frameInfos() read #3
│ later calls? read #N
trust boundary
The left column never loses access to the pages. Sending a SharedMemory handle does not revoke the sender's own mapping. If WebContent kept a writable view of the region it passed in, every arrow crossing the boundary in the diagram is a point where the bytes the GPU process reads can differ from the ones it read a moment earlier.
The right column shows why one message produces several reads. Before the fix, setData() passed the aliased SharedBuffer straight into ImageDecoderAVFObjC::setData(), and the decoder kept it. The handler then called frameCount() and frameInfos() synchronously in the same message, and both parse the accumulated data. Later IPC calls such as createFrameImageAtIndex possibly read it again, which is the "read #N" row.
Each of those reads goes back to the shared pages. Any length, offset, or header field that the decoder or the AVFoundation stack below it reads once and then re-reads, or relies on after a check, could change underneath it. The GPU process assumes an IPC payload is immutable once received. This handler broke that assumption by parsing memory the sender still controlled.
What the AVFoundation-backed parsing inside ImageDecoderAVFObjC does when its input shifts mid-parse is the part that determines severity, and it is inferred rather than traced. There are three plausible outcomes:
- Crash. At minimum, an unstable buffer could crash the GPU process. This matches Apple's stated impact.
- Inconsistent frame metadata. If
frameCount()andframeInfos()disagree because they read different bytes, the proxy could report state that does not describe any single input. - Memory corruption. The serious case is a parser that validates a size or offset and then re-reads it to index or copy. That would corrupt memory in the GPU process and make this bug a candidate stage in a sandbox-escape chain: a WebContent process that has already been compromised would use it to move into a process with broader framework access.
The precondition is a WebContent process acting against the GPU process. That means either an attacker who already controls the renderer, or one who can drive these IPC messages and keep a writable alias of the region they passed.
The fix closes the window at the point of ingestion. SharedBuffer::create(data.span()) copies the mapped bytes into a GPU-process-owned allocation before the decoder sees them. Every later read, whether in setData(), frameCount(), frameInfos(), or any later message, then sees one stable snapshot the sender cannot reach. Writes to the shared pages after the copy have no effect on the decoder.
In effect the fix collapses the right column of the diagram to a single fetch: one memcpy across the boundary, then any number of reads against private memory.
Zero-copy adoption of sender-writable shared memory turned every read the GPU-process decoder made into a double-fetch the content process could race.
Insight
The vulnerable line was the odd one out in its own file. createDecoder() already ingested its payload with SharedBuffer::create(data.span()), and setData(), which feeds the same decoder object over its lifetime, used unsafeBuffer(). Inconsistent ingestion between sibling IPC handlers of the same proxy is a strong audit signal. When one entry point defends against a hazard and its neighbour does not, the difference is usually a bug, not a deliberate performance trade-off.
This shape is especially likely when the undefended sibling is an "append" or "update" handler, which tends to get less review than the "create" handler that instantiates the object.
Audit directions
- Zero-copy adoption of sender-writable shared memory on the more-privileged side of an IPC boundary.
- Narrow: grep
Source/WebKit/GPUProcess,Source/WebKit/NetworkProcess, andSource/WebKit/UIProcessforunsafeBuffer()onSharedBufferReference, and forSharedBuffers built directly overSharedMemorymappings. Match tell: the resulting buffer goes to a parser, a decoder, or any component that keeps it beyond the handler, instead of being copied withSharedBuffer::create(span()). - Wider: the same aliasing appears whenever a receiver keeps a raw
span()into aSharedMemorymapping. Examples include passingSharedMemory::span()into CoreMedia, CoreGraphics, or WebGPU buffer-ingestion paths, and IPC stream-connection buffers that are parsed in place. Match tell: no copy happens between mapping the region and the first validation. -
Widest: this is the classic double-fetch class. It shows up in OS kernels (Linux
copy_from_userdouble-fetch bugs, Windows driverMETHOD_NEITHERbuffers), in Android binder/ashmem consumers, and in Xen grant-table backends. Chromium Mojo addresses it through its distinction betweenReadOnlySharedMemoryRegionand writable regions. The portable invariant: privileged code must snapshot or seal any memory the less-trusted side can still write before it reads that memory more than once. -
Sibling IPC handlers within each GPU-process proxy with inconsistent input-ingestion policy. In
RemoteImageDecoderAVFProxy,createDecodercopied andsetDatadid not. - Narrow: for each
Remote*ProxyunderSource/WebKit/GPUProcess/media, list every message that takesIPC::SharedBufferReferenceor aSharedMemory::Handle, and compare how each one turns it into a buffer. Match tell: any proxy where one handler copies and another adopts the mapping. - Wider: run the same comparison on the
*Proxyclasses inSource/WebKit/GPUProcess/graphics(RemoteGraphicsContextGL,RemoteRenderingBackend, WebGPU) and on the rest ofSource/WebKit/GPUProcess/media(RemoteSourceBuffer, the RemoteAudio paths). -
Widest: in any multi-process architecture, an append/update handler on an object created by a create handler tends to get less security review than the create path. Match tell: validation done at object creation is not repeated, or is weakened, on incremental updates.
-
Long-lived retention of aliased buffers inside
ImageDecoderAVFObjCand similar accumulators. If the decoder keeps references to the buffers it receives and reads them again during later messages such ascreateFrameImageAtIndexorclearFrameBufferCache, a race window inside one message becomes one that lasts across many messages. - Narrow: trace how
ImageDecoderAVFObjC::setData()stores theSharedBuffer, and which AVFoundation resource-loader callbacks read from it later. - Wider: audit other WebCore media components that accumulate
SharedBuffersegments across calls for the same retention of storage the sender can still change. Candidates are the MSESourceBufferPrivateappend paths,WebCoreDecompressionSession, and media resource loaders used from the GPU process. - Widest: any streaming parser that keeps references into caller-provided buffers instead of copying, such as zero-copy network stacks or
io_uringfixed buffers, has to ensure the producer cannot write to those buffers after handing them over. Match tell: a buffer is stored in a member field and read from a later callback, with no copy at the point of ingestion.