Medium CVSS 4.3 webkit UAF 🔧 Commit mapped

Overview

Medium
Severity
4.3
CVSS
No
Exploited ITW
Fixed
Fix Status
DescriptionProcessing maliciously crafted web content may lead to an unexpected process crash
ComponentJSC Wasm
Bug ClassUAF
Tracker299313
Fix commitd329e095fc8c (WebKit/WebKit) +10/-10
CWECWE-416 (Use-after-free)
CVSS vectorCVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:L
CISA KEVNot listed
CreditedHossein Lotfi (@hosselot) of Trend Micro Zero Day Initiative
Disclosed2025-11-03

Background

Wasm FunctionParser
The JSC component that validates/parses a WebAssembly function body against its declared signature.
TypeDefinition / FunctionSignature
The interned description of a wasm type; a function’s signature is a FunctionSignature view of a TypeDefinition.
Bare reference vs Ref<>
A C++ const T& member aliases without owning, so it dangles if the referent is freed; Ref<> holds a counted strong reference.
Object lifetime / retention
Holding a strong reference guarantees the object stays alive for the holder’s lifetime.

Root Cause Analysis

JavaScriptCore’s WebAssembly FunctionParser stored the function’s type as const TypeDefinition& m_signature — a bare C++ reference that does not retain the referenced object. The parser uses m_signature throughout function/constant-expression parsing (m_signature.as<FunctionSignature>() in parse, parseConstantExpression, parseBody, and the TailCall/TailCallIndirect/TailCallRef paths). The invariant that made the bare reference ‘safe’ was that the TypeDefinition outlives the parser, but that does not hold in all cases: the TypeDefinition can be released while the parser is still running (e.g. during recursive/streaming parsing where the owning type registry or module information drops the last other reference), leaving m_signature dangling. Any later dereference is a use-after-free.

The fix changes the member to Ref<const TypeDefinition> m_signature, so the parser holds its own strong reference for its entire lifetime, and updates every use to m_signature->template is/as<FunctionSignature>().

The restored invariant is that the parser owns a reference to the signature TypeDefinition it parses against, so the object cannot be freed underneath it. This is the same ‘retain the wasm TypeDefinition, don’t alias it’ class as the GC type-retention fixes, but here on the parser’s input signature.

Key insight
The wasm FunctionParser aliased its signature TypeDefinition by bare reference instead of retaining it, so the object could be freed mid-parse; holding a Ref<const TypeDefinition> restores lifetime safety.

Attack Path

  1. Deliver a crafted module Serve a WebAssembly module whose function signatures reference type definitions arranged so a signature’s other references are dropped during parsing.
  2. Parse the function body FunctionParser holds m_signature as a bare reference to the function’s TypeDefinition while it parses the body / constant expressions.
  3. Free the signature During parsing the TypeDefinition is released (last owning reference gone), leaving m_signature dangling.
  4. Use-after-free A subsequent m_signature.as<FunctionSignature>() (e.g. on a tail-call opcode) dereferences freed memory — crash or memory corruption in WebContent.

Impact Assessment

A use-after-free of the wasm function-signature TypeDefinition reachable while parsing a crafted module in the WebContent process. Triggering it requires arranging for the signature to be released mid-parse, and the immediate effect is a crash, though a reclaimed TypeDefinition could enable type confusion in the parser. Confined to WebContent; rated medium.

Changed Functions

FunctionChangeNotes
FunctionParser<Context>::m_signature
Source/JavaScriptCore/wasm/WasmFunctionParser.h
modified Type changed from `const TypeDefinition&` to `Ref<const TypeDefinition>` so the parser retains its signature for its whole lifetime.
FunctionParser<Context>::parse / parseConstantExpression / parseBody / tail-call handlers
Source/JavaScriptCore/wasm/WasmFunctionParser.h
modified Updated all uses to m_signature->template is/as<FunctionSignature>() to match the Ref member.

Files Changed

  • Source/JavaScriptCore/wasm/WasmFunctionParser.h

Audit Directions

  • Other bare TypeDefinition references
    grep JSC wasm/ for const TypeDefinition& / TypeDefinition* members and long-lived locals that don’t retain via Ref/RefPtr.
  • Parser-held aliases
    Audit FunctionParser and related wasm parsers/validators for other members aliasing module-owned data (ModuleInformation, signatures) across parsing.
  • Ref-vs-reference members
    Look for & members initialized from getRef()/registry lookups elsewhere that assume the referent outlives the holder.

Original Bug Report

The reporter's bug is still restricted on the tracker.