-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Java: CWE-625 Query to detect regex dot bypass #9873
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
Conversation
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.
Hey @luchua-bc, thanks for your contribution. I made some inline comments, and also pushed a commit to make SpringUrlRedirect.qll
a shared library, since you're reusing it from another experimental query.
java/ql/src/experimental/Security/CWE/CWE-625/PermissiveDotRegex.ql
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-625/PermissiveDotRegex.ql
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-625/PermissiveDotRegex.ql
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-625/PermissiveDotRegex.ql
Outdated
Show resolved
Hide resolved
java/ql/src/experimental/Security/CWE/CWE-625/PermissiveDotRegex.ql
Outdated
Show resolved
Hide resolved
f4fb4bb
to
1d12bd1
Compare
Thank @atorralba a lot for reviewing this PR. I’m on a vacation trip now and will work on the changes early next week after I’m back. Have a nice day! |
Thank @atorralba for the commit of shared library and the comments. I've made all the suggested changes. Please review again when you have a chance. Cheers, |
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.
I added another comment.
Additionally, I tried to verify the Apache Shiro result with your query and it seems it's no longer working. Could you take a look?
java/ql/src/experimental/Security/CWE/CWE-625/PermissiveDotRegex.ql
Outdated
Show resolved
Hide resolved
Thank @atorralba a lot for all your help with this PR. |
By default, "dot" (
.
) in regular expressions matches all characters except newline characters\n
and\r
. Regular expressions containing a dot can be bypassed with the characters\r(%0a)
and\n(%0d)
when the default regex matching implementations of Java are used. When regular expressions serve to match protected resource patterns to grant access to protected application resources, attackers can gain access to unauthorized paths.This query helps to detect insecure patterns and guard against unauthorized access by checking two patterns:
Please consider to merge this PR.
Thanks,
@luchua-bc