Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

Commit

Permalink
fixed potential xss in example scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
brainfoolong committed Dec 29, 2023
1 parent 72f0a0a commit 9cca6af
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions dist/example-js.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
let encrypted = url.searchParams.get('encrypted') ? atob(url.searchParams.get('encrypted')) : '{"ct":"hQDvpbAKTGp1mXgzSShR9g==","iv":"57fd85773d898d1f9f868c53b436e28f","s":"a2dac436512077c5"}'
let password = '123456'
let decrypted = CryptoJSAesJson.decrypt(encrypted, password)
results.innerHTML += 'Decrypted (From ' + encrypted + '):<br/>'
results.innerHTML += decrypted
results.innerHTML += 'Decrypted (From ' + encrypted.replace(/</g, '&lt;').replace(/>/g, '&gt;') + '):<br/>'
results.innerHTML += decrypted.replace(/</g, '&lt;').replace(/>/g, '&gt;')
})()
</script>
</body>
Expand Down
4 changes: 2 additions & 2 deletions dist/example-php.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
$originalValue = ["Coming from PHP - We do encrypt an array", "123", ['nested']]; // this could be any value
$password = "123456";
$encrypted = CryptoJsAes::encrypt($originalValue, $password);
echo "Encrypted:<br/><a href='example-js.html?encrypted=" . base64_encode($encrypted) . "' title='Pass to JS testpage' target='_blank'>" . $encrypted . "</a><br/><br/>\n";
echo "Encrypted:<br/><a href='example-js.html?encrypted=" . base64_encode($encrypted) . "' title='Pass to JS testpage' target='_blank'>" . htmlentities($encrypted) . "</a><br/><br/>\n";
// something like: {"ct":"g9uYq0DJypTfiyQAspfUCkf+\/tpoW4DrZrpw0Tngrv10r+\/yeJMeseBwDtJ5gTnx","iv":"c8fdc314b9d9acad7bea9a865671ea51","s":"7e61a4cd341279af"}

// decrypt
$encrypted = isset($_GET['encrypted']) ? base64_decode($_GET['encrypted']) : $encrypted;
$password = "123456";
$decrypted = CryptoJsAes::decrypt($encrypted, $password);

echo "Decrypted (From $encrypted):<br/>" . print_r($decrypted, true);
echo "Decrypted (From " . htmlentities($encrypted) . "):<br/>" . htmlentities(print_r($decrypted, true));

0 comments on commit 9cca6af

Please sign in to comment.