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][integrity.js] Hacked Service Worker caches can intrude into the application #368

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

Comments

@t2ym
Copy link
Owner

t2ym commented Jul 31, 2020

[vulnerability][integrity.js] Hacked Service Worker caches can intrude into the application

Root Cause

Service Worker is relying on caches without verifying the cached contents

Fix

  • Append integrity checking on Service Worker caches
  • Dedicated Headers for cached Response objects
    • x-cache-timestamp: Date.now()
    • x-cache-digest: sha256-Base64(SHA256(response.body))
    • x-cache-random: Base64(Random(32))
    • x-cache-integrity: content-type,x-cache-timestamp,x-cache-digest,x-cache-random;hmac-sha256-Base64(HMAC(headers.join('\n') + '\n'))
  • HMAC key
  ConnectSession.initialSecret = await HKDF.Extract(0, HKDF.concat(
    ConnectSession.initialRandom, // x-cache-random
    ConnectSession.ClientIntegrity.userAgentHash,
    ConnectSession.ClientIntegrity.browserHash,
    ConnectSession.ClientIntegrity.scriptsHash,
    ConnectSession.ClientIntegrity.htmlHash,
  ));
  ConnectSession.initialSalt = await HKDF.Expand_Label(CurrentSession.initialSecret, 'salt', '', HMAC.saltLength);
  • Wrapped methods for tranparent operations
    • Cache.prototype.put()
    • Cache.prototype.match()
  • On restarting Service Worker, ConnectSession.initialRandom is extracted from the header of the cache entry for integrity.json
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