w3c / webcrypto

The W3C Web Cryptography API
https://w3c.github.io/webcrypto/
Other
265 stars 53 forks source link

Crypto needs defensive deep-copy constructor #220

Open Pr0methean opened 5 years ago

Pr0methean commented 5 years ago

According to https://developer.mozilla.org/en-US/docs/Web/API/Window/crypto:

"Although the Window.crypto property iteself is read-only, all of its methods (and the methods of its child object, SubtleCrypto) are not read-only, and therefore vulnerable to attack by polyfill."

If the Crypto class had a copying constructor that also replaced the SubtleCrypto with a defensive deep copy, it would be possible to prevent this attack by using a defensive copy of the Crypto object that was made before any untrusted polyfills were loaded.

quixote911 commented 5 years ago

Sounds like a good idea. Whats the minimal way to demonstrate such a polyfill attack on SubtleCrypto?