Skip to content

[Security] Fix potential XSS on /view#6034

Merged
comfyanonymous merged 1 commit intomasterfrom
fix_xss
Dec 13, 2024
Merged

[Security] Fix potential XSS on /view#6034
comfyanonymous merged 1 commit intomasterfrom
fix_xss

Conversation

@huchenlei
Copy link
Contributor

@huchenlei huchenlei commented Dec 13, 2024

This PR prevents html/htm/js/css files being served as web page for code execution.

Reproduction steps

  • Put a index.html file with random content in ComfyUI/output folder
  • Run ComfyUI
  • Type http://localhost:8188/api/view?filename=index.html&type=output&subfolder= in browser nav bar
  • Observe that the page is getting loaded. With the patch, you should observe that the html file is being downloaded instead.

Note

During testing, make sure that you disable browser cache between different testing procedures.

@huchenlei huchenlei marked this pull request as ready for review December 13, 2024 02:46
@Kosinkadink
Copy link
Member

Works as expected on my machine - downloads the .html file instead of running it.

Not sure how much effort it would be, but is the api/upload/image endpoint expected to allow non-image types to be uploaded as well, or can it be modified to not allow .html uploads? The xss here at its core is the stored/persistent kind, so getting rid of the .html being uploaded in the first place would prevent the vulnerability from being exploited by another endpoint in the future.

@Kosinkadink
Copy link
Member

For archiving purposes, here is the vulnerability this PR aims to resolve: https://nvd.nist.gov/vuln/detail/CVE-2024-10099

@comfyanonymous comfyanonymous merged commit 59d58b1 into master Dec 13, 2024
@comfyanonymous comfyanonymous deleted the fix_xss branch December 13, 2024 09:56
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