-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Java: CWE-489 Query to detect main() method in servlets #5102
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
I'm not really familiar with Java EE but why is this a problem?
If I understand it right, the |
Hi @intrigus-lgtm, The If the A simple example is that a servlet defines a static attribute:
Then the Also leaving To address this issue, either the Hope this answers your question. |
java/ql/src/experimental/Security/CWE/CWE-489/ServletMain.qhelp
Outdated
Show resolved
Hide resolved
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 one last change request that should help in maintainability. Otherwise it looks good to me.
@luchua-bc Thank you for this contribution. |
A common development practice is to add "back door" code specifically designed for debugging or testing purposes that is not intended to be shipped or deployed with the application. The most common example of forgotten debug code is a main() method appearing in a web application.
When this sort of debug code is accidentally left in the application, the application is open to unintended modes of interaction. These back door entry points create security risks because they are not considered during design or testing and fall outside of the expected operating conditions of the application.
This type of vulnerabilities is categorized as CWE-489: Active Debug Code.
This query detects the implementation of a main method in Java EE components including servlets, filters and listeners. Please consider to merge the PR.
Thanks,
@luchua-bc