Adding section to address JavaScript Service Workers
Would it be feasible to add a section on JS Service Workers (and the methodolgy for analysis of JS Service Workers) to the guide ? This would focus mostly on client side testing but would also cover push and pull mechanisms.
Would you like to be assigned to this issue? Check the box if you will submit a PR to add the proposed content. Please read CONTRIBUTING.md.
- [x] Assign me, please!
Do you mean JavaScript?
Correct - JavaScript service workers, sorry for the confusion.
Thank you @kingthorin.
Please comment if you are still working on this issue, as it has been inactive for 90 days. To give everyone a chance to contribute, we are releasing it to new contributors.
Hi @kingthorin , thanks for raising this.
Issue Description
The current guide does not cover JavaScript Service Workers, which are increasingly used for client-side functionality such as caching, offline access, background sync, and push notifications. This can leave a gap in understanding potential security implications and testing methodologies related to Service Workers.
Proposed Fix
I propose adding a dedicated section on JavaScript Service Workers that would cover:
- A brief overview of Service Workers and their role in modern web applications
- Security implications and common risks (e.g., cache poisoning, scope abuse, persistence)
- Client-side testing methodology for Service Workers
- Considerations for push and pull mechanisms (e.g., push notifications, background sync)
- References to relevant specifications or security research where applicable If this approach sounds good, I’d be happy to work on thanks!!
What section do you intend to add the content to?
@kingthorin I plan to add this as a new page under the Vulnerabilities section (pages/vulnerabilities/JavaScript_Service_Workers.md).
Since Service Workers introduce persistent client-side behavior and potential security risks (rather than being a single attack), I felt this fits best as a vulnerability-focused entry. It will follow the existing vulnerabilities structure and be automatically listed via the index.
If you think another section (e.g. Attacks or a different guide area) would be more appropriate, I’m happy to adjust.
That's not this project then.
Got it thanks for the clarification, @kingthorin . Appreciate your time
@prasunsrivastav123-lang You can add any content you wish to www-community. Be aware that the foundation is working on overhauling the site and the migration plan isn't exactly clear.
If you really do want to contribute to the testing guide that's great as well; just have a more detailed look and let us know what your plan is for that.
Thanks for the clarification, @kingthorin . I will take a closer look at the Testing Guide and come back with a more concrete plan if I find a good fit there
@kingthorin . I reviewed the Client-Side Testing (4.11) section. From what I can see, all expected test cases are already present, so I don’t think a new file is needed right now.
I did notice a few small gaps I could help with, like minor wording consistency, a couple of outdated references (Flash/older browsers), and places where a short modern example or clarification could improve readability. I’ll propose a very small, focused change first if that sounds reasonable.
Yup, if it isn't specific to service workers then either open an issue or if it's small then just go ahead and PR. We can always discuss further based on changes/review if necessary.
@kingthorin This would be an optional clarification rather than a required change. If you’d like, I can add a short note mentioning that Flash is end-of-life to provide context, but I’m also completely fine leaving the section as-is.
I'm happy for flash based content to be removed.
There may still be a bunch in the RIA section but if it's spread elsewhere it can be chopped IMO.
#1603 is merged, hence closing this issue cc @kingthorin
Thought you were leaving this for the service worker bit?
OK, we can reopen it to track the service worker related changes (instead of a new issue)
@kingthorin Following up on the thread: since this stays open for the service worker content, here is the plan so it can be checked before I write anything.
Where: a new page in 4.11 Client-side Testing, after the existing pages. The ID would be the next free WSTG-CLNT-xx once #1608 (DOM clobbering) takes its number.
Scope, kept narrow: only what is specific to service workers. I'm not repeating generic XSS, CORS or storage content, which other pages already cover.
Test objectives
- Identify service workers registered by the application and the scope each one controls.
- Determine whether a worker can be registered, replaced or kept alive by attacker-controlled input.
- Determine whether the worker's cache and fetch handler can serve attacker-influenced or sensitive responses.
How to test
- Enumerate:
navigator.serviceWorker.getRegistrations(), DevTools Application > Service Workers, andchrome://serviceworker-internals. Record script URL, scope and update behaviour. - Registration and scope: is the worker script URL or scope built from user input? Is a broad
Service-Worker-Allowedheader used? Can user-uploaded or user-hosted JavaScript be served from a path the worker can register from? importScriptsand dependencies: does the worker load scripts from third-party origins? That makes the third party a persistent code-execution point on the origin.- Cache handling: does
fetchserve authenticated or per-user responses fromcachesto other users or after logout? Are redirects, non-200 responses orVary-dependent content cached? - Persistence after XSS: if XSS is found, can it register or replace a worker so that access survives the fix? Check the update logic (
updateViaCache, byte-diff updates). - Messaging and push: do
messageandpushhandlers check the sender or payload? Do notification click handlers open attacker-controlled URLs? - Cleanup: does logout or account change unregister the worker and clear its caches?
References: the W3C Service Workers spec and MDN.
I'll match the layout of Browser Storage and Web Messaging. Does this scope and placement work? I'll start the PR once you confirm.
Sorry I never answered this, yes that seems like a good plan 👍