[2] GPU-process `<model>` texture upload OOB read/write from unvalidated IPC layout
A compromised renderer can write its own bytes past a GPU-process cube face
High, but gated on a compromised renderer. The payoff is out-of-bounds reads and writes of attacker-supplied bytes inside the more privileged GPU process. What remains unproven is placement: where a cube-face overrun lands, and whether over-read texels ever flow back.
WebKit runs <model> 3D rendering in a separate, more privileged GPU process, which must treat everything the sandboxed web-content process sends as hostile. Texture data arrives as a WKBridgeImageAsset, which bundles a shared-memory pixel buffer with width, height, texture type and pixel format. An optional per-mip layout of byte offsets and row/image strides can accompany it. makeMTLTextureFromImageAsset, the Swift routine that turns that asset into a Metal texture, is expected to keep every copy inside both the shared-memory mapping it reads from and the texture allocation it writes into.
The angle: an attacker who already owns a web-content process can steer makeMTLTextureFromImageAsset into reading past its shared-memory mapping and writing attacker bytes past a texture face in the GPU process, or simply crash that process at will.
Compromised WCP can send invalid texture data. Validate data from IPC is sufficient for the texture size.
Source/WebKit/GPUProcess/graphics/Model/USDModel.swift
LayoutTests/sar3/http/tests/model/model-update-texture-invalid-layout.html
Patch Details
The patch makes five changes to makeMTLTextureFromImageAsset. First, it rejects .typeCube assets whose width differs from their height before the descriptor is built. Second, the nested uploadSlice now returns Bool and gains two guard blocks ahead of mtlTexture.replace(...). The destination guard requires the mip level to exist and the mipWidth × mipHeight region to fit the destination mip extent derived from mtlTexture.width/height. The source guard computes the window [bytesOffset, bytesOffset + (mipHeight-1)*bytesPerRow + mipWidth*bytesPerPixel) with overflow-reporting arithmetic and requires a non-negative offset, bytesPerRow >= rowBytes, and windowEnd <= textureBytes.count. Third, bytesPerImage is pinned to 0, since each call uploads one 2D slice. Fourth, the per-face offset dataOffset + face * byteCountPerImage is computed with multipliedReportingOverflow/addingReportingOverflow. Any rejection logs, zeroes mipLevelsInData and returns, and the computed-layout loop now honors a false from uploadSlice. Fifth, in the WKBridgeReceiver environment-map path (the handler behind RemoteMesh::SetEnvironmentMap), a nil texture now logs and returns instead of calling fatalError.
Before: After:
IPC layout {dataOffset, rowStride, ...} IPC layout {dataOffset, rowStride, ...}
└─► offset = dataOffset + face*img └─► overflow-checked offset
(trapping * and +) └─► dest guard: mip exists,
└─► replace(region w x h, w,h <= dest mip extent
withBytes: base+offset) └─► src guard: offset >= 0,
├─ src read past mapping stride >= rowBytes,
└─ dst cube face is w x w, end <= bytes.count
region h > w overruns └─► replace(..., bytesPerImage: 0)
Untrusted cross-process layout descriptors forwarded to an unchecked bulk-copy API without validating them against both the source buffer's length and the destination object's extent.
Background
Where this lives.
WebKit splits the engine across four process roles. WebContent runs page code in a tight sandbox. The GPU process handles graphics, media and model rendering on WebContent's behalf with broader driver and system access. The Networking process handles loads, and the UI process hosts the app. WebKit's threat model assumes WebContent may be fully compromised, so every GPU-process IPC handler validates its inputs, usually with MESSAGE_CHECK, which terminates the misbehaving sender instead of acting on bad data.
Shared memory.
Large payloads such as pixel data travel as a SharedMemory handle that the GPU process maps read-only. Reads through that mapping are safe only within its mapped length, here textureBytes.count.
<model> texture messages.
RemoteGPU::CreateModelBacking registers a RemoteMesh receiver. RemoteMesh::UpdateTexture and RemoteMesh::SetEnvironmentMap deliver an UpdateTextureDescriptor carrying an image asset (handle, width, height, texture type, pixel format, mip count, array length) and an optional per-mip layout vector of dataOffset, byteCountPerRow and byteCountPerImage. Both end up in makeMTLTextureFromImageAsset.
Metal upload APIs.
MTLTexture.replace(region:mipmapLevel:slice:withBytes:bytesPerRow:bytesPerImage:) copies region.height rows of region.width * bytesPerPixel bytes from withBytes, stepping by bytesPerRow, into one slice and mip of a texture; bytesPerImage matters only for 3D regions. textureCubeDescriptor(pixelFormat:size:mipmapped:) creates a cube texture with six square faces of edge size.
Swift arithmetic.
Swift's + and * trap on signed overflow. addingReportingOverflow and multipliedReportingOverflow return the wrapped value plus an overflow flag, which lets code reject input instead of trapping.
Analysis
Before the fix, the function treated two pieces of WebContent-controlled data as trusted geometry for an unchecked Metal copy: the layout triples, and the asset's width/height/textureType. Neither was ever related to the size of the shared-memory mapping or to the extent of the destination texture. The bug therefore has three faces: an OOB read on the source side, an OOB write on the destination side, and integer-overflow traps that act as a DoS.
On the source side, uploadSlice passed baseAddress.advanced(by: bytesOffset) and bytesPerRow straight from IPC. Metal reads mipHeight rows of mipWidth * bytesPerPixel bytes stepping by bytesPerRow, so an arbitrary or negative dataOffset, a huge row stride, or a stride narrower than the row moves the copy outside the mapping. The patch's own comment states that replace(region:) does not bounds-check in release builds. On the arithmetic side, face * byteCountPerImage and the subsequent add used trapping operators, so chosen values crash the GPU process deterministically, as did the fatalError in the environment-map path.
The destination side is the subtle one. For cube assets, textureCubeDescriptor(... size: imageAsset.width ...) allocates square width × width faces, but uploadSlice derived mipHeight from imageAsset.height. A cube asset taller than it is wide yields a region taller than the face, so Metal writes past the face's backing storage while every source-side bound is satisfied. No source-only check can catch this. The fix closes it twice, with the up-front square-cube rejection and the general destination-extent guard.
The regression test plays a compromised WebContent process through the IPC testing API, sending RemoteMesh::UpdateTexture and RemoteMesh::SetEnvironmentMap messages:
- A 2D asset whose
dataOffsetalone lands 1 GB past a 4 KB mapping, which is a pure source-side over-read. - Oversized and undersized row strides, plus negative offsets, which exercise the remaining source-window conditions.
Int64-overflowing image strides, which exercise the formerly trapping per-face offset arithmetic.- A non-square cube asset whose source window fits, but whose 8×4096 region overruns an 8×8 destination face. This is the destination-only case.
Reachability requires a compromised WebContent process sending RemoteMesh IPC in builds with ENABLE(GPU_PROCESS_MODEL). The overflow traps and the old fatalError give a reliable GPU-process DoS. The source-side read is a relative OOB read of GPU-process memory, anchored at the mapping's base and bounded by dataOffset, byteCountPerRow and the region size. The bytes land in a texture rather than in a buffer WebContent can read directly, so it would act as an info leak only if texture contents could flow back through rendered model output. The destination-side write overruns a cube face by an amount sized by the height - width mismatch, with contents taken from the attacker's own asset. Contents are therefore controlled, while placement is open: for .shared storage, the exact write geometry depends on the texture's memory layout, and the overrun may first spill into adjacent faces of the same cube before leaving the allocation. That makes it a heap-overflow-class candidate whose adjacency targets are not established. None of this escapes the GPU process's own sandbox; it is a renderer-to-GPU-process step.
Before the fix, this vulnerability weakened the WebContent-to-GPU-process isolation boundary. The GPU process is supposed to treat every IPC field as hostile, and shared-memory handles are supposed to bound every read it performs on WebContent's behalf. Both assumptions failed here: IPC-supplied offsets and strides directed reads outside the mapping, and asset dimensions directed writes outside the destination allocation.
Insight. The bug has two independent sides, and the test deliberately covers both. The textbook "validate offset plus length against the handle" fix would have left the non-square-cube overflow open, because the upload region came from one field (imageAsset.height) while the destination extent came from another (the descriptor's single size). Separately, Swift's trapping arithmetic and fatalError convert memory-safety bugs into availability bugs at IPC boundaries. Overflow-reporting arithmetic plus a soft reject, as used here, is the right shape. The same function still contains fatalError calls on out-of-range width/height and on an unknown bytesPerPixel, and whether those values are pre-validated at IPC decode is worth checking.
Audit directions
- Copy API driven by attacker-supplied geometry where the destination extent comes from different fields than the copy region. The region passed to a bulk copy must be checked against the destination object itself, not just the source buffer. Narrow: audit every
replace(region:andcopyFromBuffer/copy(from:call inSource/WebKit/GPUProcess(WebGPU and<model>Swift and Objective-C++ paths) and check whether the region dimensions come from the same variables used to build theMTLTextureDescriptor. Wider: the same split-truth shape appears withCGBitmapContextcreation versusmemcpyrow loops,IOSurfacewidth/height versus row-stride copies, andvImage_Buffersetups fed from IPC descriptors. Widest: any graphics API that trusts the caller for both allocation size and upload region (VulkanvkCmdCopyBufferToImage, D3D12UpdateSubresources,glTexSubImage2Din Chromium's command buffer or ANGLE). Match tell: allocation sized from field A, copy region sized from field B, with no comparison between A and B. - Strided reads of shared memory described by the untrusted side. Check every GPU-process IPC receiver that dereferences a
SharedMemorymapping at an IPC-supplied offset and stride. The invariant isoffset + (rows-1)*stride + rowBytes <= mapping size, computed with overflow checking, andstride >= rowBytes. Narrow: grepSource/WebKit/GPUProcessforbaseAddress.advanced(by:,span().subspan(anddata() +onSharedMemorymappings, and confirm each offset is validated before use. Wider: media sample buffers,RemoteImageBufferpixel transfers, and WebGPUwriteTexture/writeBufferall accept caller-described layouts. Widest: Chromium GPU command bufferTexSubImagevalidation and Android BinderParcelblobs. Match tell: a strided or offset read where only the first byte, or onlyoffset < size, is validated. - Abort-on-bad-input idioms in privileged-process code. A compromised sender can turn any trapping rejection into a GPU-process crash. Narrow: grep
Source/WebKit/GPUProcess/graphics/Model/*.swiftforfatalError(,precondition(, force-unwraps (!) and trapping+/*on values derived fromWKBridge*IPC structs, starting with the remaining dimension and pixel-formatfatalErrors inmakeMTLTextureFromImageAsset. Wider: C++RELEASE_ASSERT, crash-on-overflowCheckedArithmetic, and.value()onstd::optionalin IPC handlers, where WebKit's convention isMESSAGE_CHECKto terminate the sender rather than the receiver. Widest: Rustunwrap()/panic!in IPC daemons and Gopanicin RPC handlers. Match tell: a trap whose trigger condition is fully computable from fields the untrusted peer controls. In code review, afatalErroror force-unwrap inside a function whose arguments arrived over IPC is a stop-and-ask line.