Prerequisites
I tried to reproduce the issue when...
Description
The scriptlets set-cookie-reload and trusted-set-cookie-reload (registered in
src/js/resources/cookie.js) set a cookie on the client side and then call
window.location.reload().
There is an existing early-exit check (line 122):
if ( cookieBefore === value && options.reload ) { return; }
However, this only prevents a reload if the cookie already had the correct value before
being set. If the server discards or overwrites the cookie after the reload, this condition
will not match on the next scriptlet run – triggering yet another reload, resulting in an
infinite loop.
A specific URL where the issue occurs.
The issue is not tied to a single URL. It can occur on **any website** where:
- a filter rule using `set-cookie-reload` or `trusted-set-cookie-reload` is active, **and**
- the server discards or overwrites the cookie set by the scriptlet on each request.
Example filter rule that triggers the issue:
example.com##+js(set-cookie-reload, consent, accepted)
Steps to Reproduce
- Find or create a page whose server removes/overwrites a specific cookie on every request.
- Add a uBlock Origin filter rule using
set-cookie-reload targeting that cookie:
example.com##+js(set-cookie-reload, consent, accepted)
- Open the page in the browser.
- Observe the browser entering an infinite reload loop:
- Scriptlet sets the cookie client-side →
done = true → window.location.reload() is called
- Server discards the cookie during the request
- Page reloads → cookie is missing → early-exit check (line 122) does not trigger
- Scriptlet sets the cookie again → another reload → …
Expected behavior
The number of reloads should be limited (e.g. 2–3 attempts). If the cookie still does not
hold the expected value after those attempts (because the server keeps discarding it), no
further reload should be triggered.
Troubleshooting information
- **Affected file:** `src/js/resources/cookie.js` – function `setCookieFn`
- **Affected scriptlets:** `set-cookie-reload` (line 239), `trusted-set-cookie-reload` (line 333)
- **Severity:** High – the browser gets stuck in an infinite reload loop, making the page
completely unusable
- **uBlock Origin version:** uBlock-master, as of April 2026
- **Affected browsers:** All (Chromium, Firefox)
Prerequisites
I tried to reproduce the issue when...
Description
The scriptlets
set-cookie-reloadandtrusted-set-cookie-reload(registered insrc/js/resources/cookie.js) set a cookie on the client side and then callwindow.location.reload().There is an existing early-exit check (line 122):
However, this only prevents a reload if the cookie already had the correct value before
being set. If the server discards or overwrites the cookie after the reload, this condition
will not match on the next scriptlet run – triggering yet another reload, resulting in an
infinite loop.
A specific URL where the issue occurs.
Steps to Reproduce
set-cookie-reloadtargeting that cookie:done = true→window.location.reload()is calledExpected behavior
The number of reloads should be limited (e.g. 2–3 attempts). If the cookie still does not
hold the expected value after those attempts (because the server keeps discarding it), no
further reload should be triggered.
Troubleshooting information