w3c / webcrypto

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

crypto.subtle.importKey should be readonly #337

Open xxoo opened 1 year ago

xxoo commented 1 year ago

Cause anyone can easily steal your key by doing this

const importKey = crypto.subtle.importKey.bind(crypto.subtle);
crypto.subtle.importKey = (...args) => {
  console.log('your key is stolen:', args);
  return importKey(...args);
};
crypto.subtle.importKey('raw', new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]), 'AES-CBC', false, ['encrypt', 'decrypt']);