Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix XSS on state encoding #180

Open
Fryuni opened this issue Nov 15, 2024 · 0 comments
Open

Fix XSS on state encoding #180

Fryuni opened this issue Nov 15, 2024 · 0 comments

Comments

@Fryuni
Copy link
Owner

Fryuni commented Nov 15, 2024

          _:hammer_and_wrench: Refactor suggestion_

Consider encoding the JSON state for safety.

The state is being directly interpolated into the script tag content. While the json+devalue type suggests special handling, explicitly encoding would prevent XSS.

Consider this enhancement:

-const stateScript = `<script id="it-astro-state" type="application/json+devalue">${state}</script>`;
+const stateScript = `<script id="it-astro-state" type="application/json+devalue">${encodeURIComponent(state)}</script>`;

Committable suggestion skipped: line range outside the PR's diff.

Originally posted by @coderabbitai[bot] in #179 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant