Skip to content
New issue

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

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

Already on GitHub? # to your account

[vulnerability] HTML/SVG responses with irregular extensions are not hooked #314

Closed
t2ym opened this issue Aug 28, 2019 · 0 comments
Closed

Comments

@t2ym
Copy link
Owner

t2ym commented Aug 28, 2019

[vulnerability] HTML/SVG responses with irregular extensions are not hooked

Root Causes

  • Only extensions are checked for HTML/SVG detection
  • Content-Type headers are ignored

Fix

diff --git a/lib/service-worker.js b/lib/service-worker.js
index 21074c79..899609bb 100644
--- a/lib/service-worker.js
+++ b/lib/service-worker.js
@@ -288,8 +288,8 @@ module.exports = function (hook, preprocess) {
                     }
                   });
                 }
-                else if (url.pathname.match(/(\/|[.]html?|[.]svg)$/)) {
-                  let isSVG = url.pathname.match(/([.]svg)$/);
+                else if (url.pathname.match(/(\/|[.]html?|[.]svg)$/) || response.headers.get('content-type').match(/^text\/html|image\/svg\+xml/)) {
+                  let isSVG = url.pathname.match(/([.]svg)$/) || response.headers.get('content-type').match(/^image\/svg\+xml/);
                   let original;
                   let decoded;
                   let contextGeneratorScripts = [];
t2ym added a commit that referenced this issue Aug 28, 2019
@t2ym t2ym closed this as completed in 35f6f26 Aug 28, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

1 participant