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: prevent CSS injection in profile banner filename filter #9731

Merged
merged 2 commits into from
Nov 26, 2021

Conversation

TkzcM
Copy link
Contributor

@TkzcM TkzcM commented Nov 25, 2021

Description

This PR fix a CSS injection in profile banner filename filter.
The old filter can be bypassed with the payload below:

Content-Disposition: form-data; name="banner"

/static"); background-image: url(**Image Link Here**); display: (/wallpapers/2021_795.png

Any CSS without double quote could be injected by using the payload.

An injected example: https://gitcoin.co/tkzcm

Refers/Fixes
Testing

The new filter should be fine while the banners are only from the wallpapers folder.

Copy link
Contributor

@nutrina nutrina left a comment

Choose a reason for hiding this comment

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

This is a nice catch.
But there are still bad things slipping through, for example this:

Content-Disposition: form-data; name="banner"\r\n\r\n/static/wallpapers/"); background-image: url(**Image Link Here**); display: (/wallpapers/2021_365.png\r\n- ...

I wold propose changing that if condition to following:

if filename[0:19] != '/static/wallpapers/' or filename[19:] not in load_files_in_directory('wallpapers'):

@TkzcM
Copy link
Contributor Author

TkzcM commented Nov 26, 2021

Sorry about the insecure fix. It should be fine now.

@TkzcM TkzcM requested a review from nutrina November 26, 2021 11:08
Copy link
Contributor

@nutrina nutrina left a comment

Choose a reason for hiding this comment

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

Looks good to me ;)

@thelostone-mc thelostone-mc merged commit 876baf9 into gitcoinco:master Nov 26, 2021
@TkzcM TkzcM deleted the fix-banner-check branch November 26, 2021 13:09
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