GeezerVison is showing github.com — [vf] [New Rule] Handle XSS violations that can occur within Html Style tags by rmohan20 · Pull Request #3005 · pmd/pmd
Conversation
rmohan20
commented
Jan 11, 2021
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Describe the PR
This PR introduces a new rule, VfHtmlStyleTagXss, to check encoding in <style/> tags that are present in visualforce code.
This rule is based on Salesforce Security's recommendation to prevent XSS in Visualforce as mentioned here.
Currently, in PMD, while the <script/> tag rules are already handled thoroughly, <style/> tag rules have been missing. The newly added rule expects URLENCODING or JSINHTMLENCODING for url-based style values and any kind of encoding for non-url style values.
cc @jbartolotta-sfdc
The new rule throws violations for:
- No encoding at all for non-url based value in style tag:
<apex:page>
<style>
a { {!XSSHere} }
</style>
</apex:page>
- No encoding at all for url-based value in style tag:
<apex:page>
<style>
div {
background: url('{!XSSHere}');
}
</style>
</apex:page>
- HTML encoding for url-based value in style tag:
<apex:page>
<style>
div {
background: url('{!HTMLENCODE(XSSHere)}');
}
</style>
</apex:page>
- JS encoding for url-based value in style tag:
<apex:page>
<style>
div {
background: url('{!JSENCODE(XSSHere)}');
}
</style>
</apex:page>
The new rule allows:
- Any encoding for non-url based value in style tag:
<apex:page>
<style>
a { {!HTMLENCODING(XSSHere)} }
</style>
</apex:page>
(HTMLENCODING can be replaced with JSENCODING, JSINHTMLENCODING and URLENCODING - no violation will be thrown)
- JS in HTML encoding for url-based value in style tag:
<apex:page>
<style>
div {
background: url('{!JSINHTMLENCODE(XSSHere)}');
}
</style>
</apex:page>
- URL encoding for url-based value in style tag:
<apex:page>
<style>
div {
background: url('{!URLENCODE(XSSHere)}');
}
</style>
</apex:page>
Related issues
No relevant open issue exists at the moment.
Ready?
- Added unit tests for fixed bug/feature
- Passing all unit tests
- Complete build
./mvnw clean verify passes (checked automatically by travis)
- Added (in-code) documentation (if needed)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Get latest from GitHub/12/16/2020
author rmohan <[email protected]> 1608240897 -0800
committer rmohan <[email protected]> 1610153787 -0800
gpgsig -----BEGIN PGP SIGNATURE-----
iQIzBAABCAAdFiEEPykD30Ug+JG+ZQ7x5XWwXqT2VuwFAl/4/zsACgkQ5XWwXqT2
VuwJoBAAsdl/TU3nculnOPwrCHtaxgtM/4zB+wLdw7f+KtIaGMv5A8v8gMbqh0V+
OTPV0Q/CTEk4PxA2qD5aCPLOaO9+LHOKjPdkWalttVjINtTVPR2pKo0PKR+f2q77
79eFkhiB1uNx741ThGIZoWPv8eMKHYP+1BEwndFdByxSA70+gdYkbmZqKLLOOrTE
2uxuGwnNM02ZYskupvgPW2pZvWFviR2sZt/GbFPkqAwgjf40MxM5+3cujOOV850E
hLHCcch5G5sh8sHTb9nCyNmc6i1kSw9+OOpOHmJGV4u3DRBBtTE9FdwyEUJ2VliZ
77VrfRPxwzkAE3jTH7EGCY7kpf84jQMqrGn/gav1LfH4DscPZmF617r9iYZ5fOr6
Z2Fun4vaCXk0h1CojCOpnh4WAthhiVtvBJmdiyO489/hmbtwWuz7KBkCsEVBS+8E
ViEaQylIOWjcFXkAq5PQ8fCxIqqMgbI7p5kQL6zatpykteMT5zoJj41t8oyjr5Rz
RUGXNPxpW3zKq3jw4VsjZ8qNYuoSerTzx0qGuUQIALO97HZ8ZBsxmcDTFJrzAkj7
yfslzLRIoPlL4ZKdpOgCGzVLBX1D/YCBn9KXQiYEYRh57umIt0wpM/Y/Xkl+/Jr4
97DYj7GQr1gYavSqe7z5n3aUixyibpWy/wx2K3VN6PmtZ3FEB5I=
=dqIs
-----END PGP SIGNATURE-----
Creating new VfHtmlStyleTagXss rule to handle XSS in style tags.
Also, refactoring common code out of VfUnescapeElRule to avoid duplication.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
|
@adangel @rsoesemann can you please have a look at this PR when you get a chance and let me know what you think? This has a few new XSS checks for Visualforce.
|
rsoesemann reacted with eyes emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Looks great. I couldn't find anything I didn't like. @adangel you?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
rmohan20 reacted with hooray emoji
|
@rsoesemann Thanks for the approval.
@adangel Would love to hear your thoughts on this PR as well.
FYI, starting next week, I'll be on a break till mid-March and may not be able to address any new feedback until then.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
rmohan20 reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
@rmohan20 Thanks for working on this, especially, for the thorough explanations. I can fix those comments myself if you're away, let me know
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
rmohan20 reacted with thumbs up emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
|
@oowekyala Thanks for the thorough review. I've made the changes based on your feedback. Will check back during the weekend to see if you have more suggestions.
|
rsoesemann reacted with eyes emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
1 Message
|
| 📖 |
No java rules are changed! |
Generated by 🚫 Danger
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…/security/VfHtmlXssStyleTagUrlPatternMatchingTest.java
Co-authored-by: Clément Fournier <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
adangel
changed the title
[vf] [New Rule] Handle Xss violations that can occur within Html Style tags
[vf] [New Rule] Handle XSS violations that can occur within Html Style tags
Jan 21, 2021
adangel
added a commit
that referenced
this pull request
Jan 21, 2021
- ElEscapeDetector is utility class now
- Improved description and example of new rule
adangel
added a commit
that referenced
this pull request
Jan 21, 2021
[vf] [New Rule] Handle XSS violations that can occur within Html Style
tags #3005
Reviewers
adangel
adangel left review comments
+1 more reviewer
Reviewers whose approvals may not affect merge requirements
Uh oh!
There was an error while loading. Please reload this page.
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|