-
-
Notifications
You must be signed in to change notification settings - Fork 738
ascanrules: detect Escaped XSS encodeURIComponent #6686
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
base: main
Are you sure you want to change the base?
ascanrules: detect Escaped XSS encodeURIComponent #6686
Conversation
All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA |
This comment was marked as outdated.
This comment was marked as outdated.
Should have unit tests for the new situation/coverage, as well as a chaneglog note. |
|
Great job! No new security vulnerabilities introduced in this pull requestCommunicate with Checkmarx by submitting a PR comment with @Checkmarx followed by one of the supported commands. Learn about the supported commands here. |
Please, make sure to link to related issues: zaproxy/zaproxy#7122 and zaproxy/zaproxy#7148. |
The payload is being added everywhere, see usages of |
I run this command. There were no errors. Build was successful. |
I need to add code for the new unit test? I am not familiar with this. |
Where can I see the usage of |
This applies the code formatting requirements. You can commit and push again.
Yup there are lots of examples there already.
In the rule you're modifying. |
Okay, I will try to write a unit test. |
I likely won't get a chance to check again until the morning, the change note should be in the Unreleased section (the version and date are set at release). |
|
Use Java 17 as mentioned in https://www.zaproxy.org/docs/developer/quick-start-build/#preparation |
Java 17.0.12 should work right? |
Yes, what command are you using? |
I'd suggest testing just the add-on you are changing, |
Depends on the tests, you need to check the assertions and see if the tests need to be updated (e.g. other attack being used) or the new code changes corrected (e.g. introduces FPs). |
This is how you'd test just the one class from the CLI:
I can confirm on Edit: Two of them seem to be an unexpected attack value. Three of them seem to be false positives (alert raised where none is expected). |
To address the two that are returning the unexpected attack you can simply move your new code below the contexts2 handling and before the return false. |
Got it, Thanks! |
I tried this just now. The two unexpected attacks are not showing any more at the I haven't understood completely that how the code is analyzing if the payload actually triggered the alert. Can I get some help on this? ![]() ![]() |
Okay, got it. I have done the spotlessApply, earlier something was missed I guess. |
I modified the Changelog comment as suggested. |
|
To resolve this, I should focus on changing my scan rule, or changing these unit tests? |
Well it depends why they're now failing. Given that no alert is raised at all it "seems" like it is something in the new changes that needs to be changed further. |
Have you re-built the add-on and tested it against Firing Range? |
Is there a way through which I see which functions are being triggered when the contexts are being checked in CrossSiteScriptingScanRule.java? |
Sorry my earlier message was wrong, it should have said: I had a quick look at all three tests that are failing, it seems the new payload is always being assigned to a var which doesn't really represent an XSS, ex: |
You can add print statements or use a debugger. |
Okay, got it. And for that to print do I need to make some configuration change? |
Okay, I understand. Thanks |
Using |
I am using VS Code, and executing the commands through terminal. |
Hmmm that might be easier said than done. |
Okay, I understand. |
If we knew that the variable the payload is assigned to is being executed in an eval. |
I checked that isInTagWithSrc value is true for the context when using |
Not sure, its been a while since I've looked at the code. But injecting into a string like that does not indicate a vulnerability. We need to be able to break out of the string and execute something we're specifying... |
Or we'd have to know that something like |
Yeah got it. I have been debugging, and I will have to think of the logic again, it doesn't seem entirely correct. |
|
No, contexts should be handled the same in unit tests and in the app, otherwise the unit tests would be meaningless 😁 |
This is to enhance the detection capability of the active scanner for XSS.
Escaped XSS - /js/encodeURIComponent
alert(1)
in directAttack function