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

Add html_escape so that code cannot be ran based on URL params #668

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

TylerJDev
Copy link

@TylerJDev TylerJDev commented Feb 20, 2025

Issue

This PR is part of #669. The change attempts to ensure that the parameter value is properly escaped to prevent potential security vulnerabilities, such as XSS.

If the escaped_value contains the following value or similar then it could lead to XSS:

"-alert(window.location.href)-" - The console.log would be ran, as the quotes would evaluate to NaN, leaving the JavaScript within to be ran (i.e. paramsInputComponent({name: 'text', value: ""-alert(window.location.href)-""}).

Example in Lookbook demo

Solution

The easiest workaround seemed to be parsing the string and removing instances of quotes. This can be done utilizing html_escape, which removes special characters including quotes for more assurance. This shouldn't have any ill affects to how Lookbook processes params currently, as it'll only convert special characters to their HTML entity (e.g. " to "), while retaining the actual value in the rendered UI.

Copy link

netlify bot commented Feb 20, 2025

Deploy Preview for lookbook-docs canceled.

Name Link
🔨 Latest commit 7fce1ee
🔍 Latest deploy log https://app.netlify.com/sites/lookbook-docs/deploys/67b7943b8a580e0008ea38b4

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

Successfully merging this pull request may close these issues.

1 participant