Skip to content

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.

val foldersContainingFile = folders.findByFileId(file.id).sortBy(_.name)
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?

@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?

# 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?

@lmarini
Copy link
Member

lmarini commented Jul 28, 2025

Fixed #459

@lmarini lmarini closed this Jul 28, 2025
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

4 participants