The vulnerability exists in how Astro's server islands handle encryption for component parameters (props and slots). The core issue is a cryptographic weakness in the implementation of AES-GCM encryption. The functions encryptString and decryptString did not use the 'authenticated additional data' (AAD) feature of AES-GCM. This feature is designed to bind a ciphertext to its specific context.
Without AAD, a ciphertext generated for a component's 'props' could be intercepted by an attacker and re-submitted to the server as the 'slots' for the same or another component. The decryptString function would successfully decrypt this replayed data because it only checked the encryption key, not the context in which the data was intended to be used.
This is dangerous because 'slots' in Astro can contain raw, unescaped HTML, while 'props' might contain user-controlled data that is expected to be treated as simple data. By replaying a user-controlled prop as a slot, an attacker could inject malicious HTML and execute a Cross-Site Scripting (XSS) attack.
The patch addresses this by modifying encryptString and decryptString to accept an additionalData parameter. This parameter is used to pass context, such as props:ComponentName or slots:ComponentName, into the encryption and decryption process. This ensures that a ciphertext encrypted for a specific purpose can only be decrypted for that exact same purpose, effectively preventing the replay attack.