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

generate popup contents without string concat. #94

Merged
merged 2 commits into from
Jul 17, 2023

Conversation

jackharrhy
Copy link
Contributor

@jackharrhy jackharrhy commented Jul 17, 2023

What I am changing

  • Previous version of popup content generation is vulnerable to XSS attacks due to crafting raw HTML from feature properties.

How I did it

  • Instead of generating the popup contents from string concatenation, generate from using document.... APIs instead
  • This method of creating content, while more verbose, should not be vulnerable to XSS due to any feature content being added as innerText

How you can test it

Insert this table into the db:

CREATE TABLE xss (name varchar primary key, geom geometry, description varchar);
INSERT INTO xss VALUES ('XSS Test', 'POINT(0 0)', '<p onclick="alert(1)">click me!</p>');

Navigate to http://localhost:8000/collections/public.xss/items/XSS%20Test

On current main: notice that clicking on the popup, and then clicking on the text, will popup with an alert:

image

On this branch, the popup will render the true contents, and is not clickable as before:

image

- previous version of popup content generation is vunerable to XSS
  attacks due to crafting raw HTML from feature properties
- this method of creating content, while more verbose, should not be
  vunlerable to XSS due to any feature content being added as innerText
@jackharrhy
Copy link
Contributor Author

fyi @krishnaglodha

@krishnaglodha
Copy link
Contributor

Ohh I see. This one makes more sense. Thanks a lot for clarification

@vincentsarago
Copy link
Member

🥳 thanks @jackharrhy
could you update https://github.com/developmentseed/tipg/blob/main/CHANGES.md?plain=1#L15 to add link to this PR and your name as co-author of this feature 🙏

@jackharrhy
Copy link
Contributor Author

done @vincentsarago

@vincentsarago vincentsarago merged commit 09926e0 into developmentseed:main Jul 17, 2023
@vincentsarago
Copy link
Member

🥳

@jackharrhy jackharrhy deleted the fix-popup-xss branch July 17, 2023 16:15
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.

3 participants