So, I found a website that uses AES encryption to prevent XSS and I'm wondering if this approach is inherently flawed.
It has an endpoint like execute.php?code=encryptedPayload
which de-crypts the payload and directly executes it as JavaScript inside the page like ... <script>decryptedPayload</script> ...
.
The reasoning of the developer behind this is that only the page owner can craft valid encrypted Payloads, thus noone can forge malicious payloads.
I do have a valid Cipher-text and when I change a character in the middle of the Cipher-text, a block of 16 characters in the executed JavaScript turns to garbage. So I assume it uses 128bit AES-ECB?
So basically I'm able to alter the Cipher-text and get the de-crypted result back. The goal obviously is to craft a cipher-text that de-crypts to a valid malicious JavaScript payload.
I'm pretty sure the Key used is fixed. Not sure about the IV - so far I only got one. But even if the IV is random, the payload usually is also fixed.
This seems wrong to me. Is it?
Edit: assumed CBC before but I noticed only part in the middle changes, so ECB