<?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>258195</bug_id>
          
          <creation_ts>2023-06-16 02:56:58 -0700</creation_ts>
          <short_desc>Service Worker: Redirect loses hash fragment</short_desc>
          <delta_ts>2023-07-07 08:33:52 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Service Workers</component>
          <version>Safari 16</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <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="Lauritz">webkit</reporter>
          <assigned_to name="youenn fablet">youennf</assigned_to>
          <cc>achristensen</cc>
    
    <cc>cdumez</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1962049</commentid>
    <comment_count>0</comment_count>
    <who name="Lauritz">webkit</who>
    <bug_when>2023-06-16 02:56:58 -0700</bug_when>
    <thetext>Hi there!

Apparently Webkit has a comparable issue to: https://bugzilla.mozilla.org/show_bug.cgi?id=1420672

Redirects which include hash fragments and that are intercepted by Service Workers lose their fragment.


## Proof of concept

register_worker.html
```html
&lt;script&gt;
if (&quot;serviceWorker&quot; in navigator) {
  navigator.serviceWorker.register(&quot;/sw.js&quot;)
}
```

sw.js
```javascript
self.addEventListener(&quot;fetch&quot;, (event) =&gt; {
  console.log(&quot;fetch event&quot;);
  event.respondWith(fetch(event.request));
});
```

/index.php
```php
&lt;?php
    header(&apos;Location: /test.html&apos;,true,301);
    exit();
```

test.html
```javascript
&lt;script&gt;alert(window.location)&lt;/script&gt;
```

### Steps to reproduce
1. Browse /index.php#test =&gt; Observe that redirect keeps fragment as expected
2. Browse /register_worker.html to Register Service worker
3. Browse /index.php#test =&gt; Observe that redirect lose fragment</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1962054</commentid>
    <comment_count>1</comment_count>
    <who name="Lauritz">webkit</who>
    <bug_when>2023-06-16 03:12:55 -0700</bug_when>
    <thetext>After filing this as non-security issue at first, I think there could be potential security implications I have not thought of at first. For instance, in the context of OAuth/OIDC (&quot;implicit flow&quot;/&quot;response_mode=fragment&quot;), where sensitive information is passed between parties using the url hash fragment. At the very least, this behavior could break an SSO login flow.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1963271</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-06-23 02:57:15 -0700</bug_when>
    <thetext>&lt;rdar://problem/111208014&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1965116</commentid>
    <comment_count>3</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2023-07-05 08:10:36 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/15565</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1965580</commentid>
    <comment_count>4</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2023-07-07 08:33:49 -0700</bug_when>
    <thetext>Committed 265845@main (e4b3080bb04a): &lt;https://commits.webkit.org/265845@main&gt;

Reviewed commits have been landed. Closing PR #15565 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>