Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Vulnerability] Documents with blob URLs can bypass Service Worker #363

Closed
t2ym opened this issue Jul 29, 2020 · 0 comments
Closed

[Vulnerability] Documents with blob URLs can bypass Service Worker #363

t2ym opened this issue Jul 29, 2020 · 0 comments

Comments

@t2ym
Copy link
Owner

t2ym commented Jul 29, 2020

[Vulnerability] Documents with blob URLs can bypass Service Worker

Root Cause

  • Documents with blob URLs have the same origin as their creator document but bypass Service Worker
  • It seems this behavior is as designed, although it is somewhat twisted

Reproducible Code

let a = document.createElement('a');
a.setAttribute('href', 
  URL.createObjectURL(
    new Blob([`<script>console.log(location,caches);fetch("${new URL('./malicious-document.html',location).href}");</` + 'script>'], 
    { type: 'text/html' })));
anyDocument.appendChild(a);
a.click();

Fix

  • Stricter parameter checking in Element.setAttribute(), etc.
  • Attach MutationObserver to track DOM mutations for URL auditing
    • Track Shadow DOM as well as sub documents
    • Exception: <a download="filename.ext" href="blob:...">Download Link</a> is allowed
    • <img src="blob:..."> is permissive as well
  • Add configurations
    • hook.parameters.mutationObserver = new MutationObserver(callback)
    • hook.parameters.mutationObserverConfig = configForObserverObserve

Tips for Fix

  • For <a download="filename" href="blob:..."> to work properly, download attribute/property must be set BEFORE href attribute/property for blob:... URL is set
t2ym added a commit that referenced this issue Jul 29, 2020
@t2ym t2ym closed this as completed in 8081b8b Jul 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant