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 profile xss #449

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open

Fix profile xss #449

wants to merge 8 commits into from

Conversation

tcnichol
Copy link
Contributor

@tcnichol tcnichol commented Apr 28, 2024

you can change the firstName and lastName to include javascript using the endpoint:

localhost:9002/api/users/662eacbe89108d20fb4cab22/updateName?firstName=bb&lastName=<script>alert('XSS')</script>

I am using an imported function. This gets rid of the javascript being called, but then the name is blank on the profile page. It may not be the right method for this, or I may be using it wrong.

@tcnichol tcnichol linked an issue Apr 28, 2024 that may be closed by this pull request
@tcnichol tcnichol marked this pull request as ready for review April 28, 2024 22:37
@tcnichol tcnichol self-assigned this Apr 28, 2024
@tcnichol tcnichol requested a review from lmarini April 28, 2024 22:37
@longshuicy
Copy link
Member

@lmarini and I looked together on other possible places related to this bug and realize that sometime it's unnecessary for the frontend template to use @html(). It should just render it as plain text instead of as html tags.

  • The only exception I can think of is Customize the "welcome" page.
  • Maybe even for the places that needs "html" tag, we can exclude <script> tag

e.g.
https://github.com/search?q=repo%3Aclowder-framework%2Fclowder+%40html&type=code&p=1

@tcnichol
Copy link
Contributor Author

tcnichol commented May 2, 2024

Replacing

@Html(profile.lastName)

with

(profile.lastName)

still calls the javascript function.

I am going to try writing an escape function that we can use.

Logger.debug("File was already in dataset.")
Logger.debug("Remove file from folders in dataset")
foldersContainingFile.foreach(folder => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason this logic is needed here?

@@ -65,7 +65,7 @@ <h1>@profile.fullName</h1>
} else {
@if(ownProfile){
<div id="prf-first-name" class="text-left inline">
<h1 id="first-name-title" class="inline" style="cursor:pointer" title="Click to edit user's first name.">@Html(profile.firstName)</h1>
<h1 id="first-name-title" class="inline" style="cursor:pointer" title="Click to edit user's first name.">@Html(escapeString("<script>alert('XSS')</script>"))</h1>
Copy link
Member

@longshuicy longshuicy May 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happen if you just remove the @html() altogether? Like we discussed, this way no html tag should be executed
Ah I just saw your comment above, then the escape function you have might solve the issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also shouldn't this be profile.firstName still? Looks like you might've pushed an temporary test to this PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last thing, there might be other places with @html tag, could you also apply the same fix to those?

@@ -51,7 +51,7 @@ services:

# main clowder application
clowder:
image: clowder/clowder:${CLOWDER_VERSION:-latest}
image: clowder:bugfix
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again this looks like a temp commit, should it revert back to the original image?

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.

profile stored XSS vulnerability
2 participants