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
Added ability to whitelist particular functions #122 #123
Merged
flavorjones
merged 1 commit into
flavorjones:master
from
eventfuel:enable_whitelisting_css_functions
Feb 6, 2018
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the light of this comment: #123 (comment) I think this should be extended to cover rgb, rgba, hls, hlsa and probably a bunch more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, but I'd suggest merging in as it is and raising a separate issue for assessing other functions as defaults.
Until this is merged in, users of loofah can't whitelist any themselves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the two weeks this PR has been open, I think it wouldn't hurt to make it completely functional. Whitelisting just
calc
is very very limited. However, it's your PR, so it's yours and maintainers choice :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whitelisting many functions by default, opens up the gem as being the root cause of sanitization an XSS attack vector which, unless I'm mistaken, could potentially undermine many Rails projects.
The primary concern of this PR is to allow individuals to whitelist functions themselves, that they can assess in their own time.
I'd be quite happy to even remove
calc
as a default as long as the gem allowed definingACCEPTABLE_CSS_FUNCTIONS
it would fulfil the functionality aim I had.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, for your use-case this is enough. I'm rather thinking of the bigger picture. Gems like this one only make sense if they whitelist all allowed (according to W3C) tags, attributes, css functions, etc. etc. If you had to define all such lists on your own, this gem would be a major PITA to use. Not to mention it would lose all of its security features as a lot of ppl would whitelist stuff which shouldn't be allowed in the first place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enabling ppl to whitelist to their own demise is exactly what the gem should enable.
Rushing into having a large whitelist could potentially mean undermining the safety of sanitizing strings.
For example if the wrong function is accidently whitelisted, it could mean
sanitize(unsafe_html)
in all apps running a particular version of Loofah could be targets of a XSS attack.If each individual is responsible for whitelisting their own functions, it is unlikely that malicious attackers will have a way of identifying the version of Loofah being used through automated testing.
I'm not saying more shouldn't be added to the default function whitelist like the color functions. But before they are, there should be some research done into ways that each function may be used maliciously.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reference: https://www.quackit.com/css/functions/ -- all those functions should be added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick note: at least url() and image() can be used for arbitrary JS code execution and parameter snooping.
They can also be used to snoop URL params by logging all requests via a remote call.