<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>304181</bug_id>
          
          <creation_ts>2025-12-15 07:32:38 -0800</creation_ts>
          <short_desc>Incorrect handling of invalid UTF-8 in streaming decoder</short_desc>
          <delta_ts>2025-12-16 20:23:53 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Platform</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=233921</see_also>
    
    <see_also>https://github.com/web-platform-tests/wpt/pull/56799</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Nikita Skovoroda">chalkerx</reporter>
          <assigned_to name="Darin Adler">darin</assigned_to>
          <cc>annevk</cc>
    
    <cc>ap</cc>
    
    <cc>cdumez</cc>
    
    <cc>darin</cc>
    
    <cc>ntim</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2165907</commentid>
    <comment_count>0</comment_count>
    <who name="Nikita Skovoroda">chalkerx</who>
    <bug_when>2025-12-15 07:32:38 -0800</bug_when>
    <thetext>```js
&gt; const x = Uint8Array.of(0xf0, 0xc3, 0x80, 42)
&gt; new TextDecoder().decode(x) // valid
&apos;�À*&apos;
&gt; const d = new TextDecoder();
&gt; [d.decode(x.subarray(0, 1), { stream: true }), d.decode(x.subarray(1), { stream: true }), d.decode()].join(&apos;&apos;) // invalid
&apos;�À�&apos;
```

See https://issues.chromium.org/issues/468458744, WebKit is also affected

This is already public but has security implications

utf8 decoder is affected by the structure of underlying memory chunks
Anything checking signatures / computing hashes etc is not affected by that

Responses with the exact same bytes are decoded differently depending on network timing and chunking, and could potentially be affected by a MitM to trigger decoding to different data, without affecting TLS

See a live demo at https://tmp-demo.rray.org/utf-8</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2166110</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2025-12-15 18:51:37 -0800</bug_when>
    <thetext>&lt;rdar://problem/166583808&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2166112</commentid>
    <comment_count>2</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2025-12-15 18:55:32 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/55452</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2166115</commentid>
    <comment_count>3</comment_count>
    <who name="Nikita Skovoroda">chalkerx</who>
    <bug_when>2025-12-15 19:10:45 -0800</bug_when>
    <thetext>To clarify in addition to the title change: this does not only affect `TextDecoder`

This also affects `await res.text()` in fetch, and it also affects page/resource loads (as seen in the live demo - that&apos;s a plain html decoding differently)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2166143</commentid>
    <comment_count>4</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2025-12-15 21:36:12 -0800</bug_when>
    <thetext>Committed 304496@main (ab37a057cd38): &lt;https://commits.webkit.org/304496@main&gt;

Reviewed commits have been landed. Closing PR #55452 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2166506</commentid>
    <comment_count>5</comment_count>
    <who name="Tim Nguyen (:ntim)">ntim</who>
    <bug_when>2025-12-16 20:23:53 -0800</bug_when>
    <thetext>https://github.com/web-platform-tests/wpt/pull/56799</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>