5 ms·
While the TLS-based version was removed from Chrome [0], you can implement a less efficient (and slightly less secure) version in js. I created an example [1].
by kevlened 3y ago
While the TLS-based version was removed from Chrome [0], you can implement a less efficient (and slightly less secure) version in js. I created an example [1].
The gist is:
1. Client creates a key pair in js
2. Client sends pub key on initial auth
3. Server validates auth and attaches pub key to cookie
4. Client signs each request payload with a timestamp
5. Server validates signature and timestamp
The security issue is in step 1. WebCrypto can generate non-extractable private keys and store them in indexeddb. However, this assumes no malicious code flips the “extractable” flag before the pair is generated. So this strategy is trust-on-first-use.
[0] - https://chromestatus.com/feature/5097603234529280 https://chromestatus.com/feature/5097603234529280
[1] - https://github.com/kevlened/prevent-exfiltration/blob/main/index.mjs https://github.com/kevlened/prevent-exfiltration/blob/main/i...