-
Notifications
You must be signed in to change notification settings - Fork 1.7k
CodeQL query to detect open Spring Boot actuator endpoints #2901
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
CodeQL query to detect open Spring Boot actuator endpoints #2901
Conversation
Apologies for the delay in reviewing this PR. We think this is a useful contribution but it will likely require a number of changes before we can accept it into our standard query set. In order to streamline our review process going forward, we are now accepting experimental contributions. If you'd like to move this query into the Otherwise the query looks mostly good, although I'd like to see at least one result on some project to verify the applicability of the query. As for the documentation, it is claimed that this can "lead to information disclosure or even to remote code execution" - it would be nice to include some references or explanation to document how this happens. |
We tried running this across all of lgtm.com https://lgtm.com/query/483327956475899158/ and got zero results. |
Thank you very much for those references. This definitely helps our evaluation. |
java/ql/src/experimental/Security/CWE/CWE-016/SpringBootActuators.qll
Outdated
Show resolved
Hide resolved
…ors.qll Co-Authored-By: Anders Schack-Mulligen <[email protected]>
Thanks for the suggestion. I've committed the change. Please verify if everything is fine, especially |
I've removed |
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.
Thanks a lot for adding the working test. This looks ready to merge.
predicate permitsSpringBootActuators() { | ||
exists(AuthorizeRequestsCall authorizeRequestsCall | | ||
// .requestMatcher(EndpointRequest).authorizeRequests([...]).[...] | ||
authorizeRequestsCall.getQualifier() instanceof RequestMatcherCall | ||
or | ||
// .requestMatchers(matcher -> EndpointRequest).authorizeRequests([...]).[...] | ||
authorizeRequestsCall.getQualifier() instanceof RequestMatchersCall | ||
or | ||
// http.authorizeRequests([...]).[...] | ||
authorizeRequestsCall.getQualifier() instanceof VarAccess |
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.
@ggolawski this clause seems to be causing many FPs where there are no evidences that Spring Actuators are being used.
See results here https://lgtm.com/query/4456298315122374638/
If EndpointRequest
is not used, we need a different way to know that Actuators are indeed enabled.
Having said that, those results may be of interest for a different query in the line of https://vulncat.fortify.com/en/weakness?q=spring%20security%20misconfiguration
Also, for lines 91 and 93 there are some FPs in the form of:
http.authorizeRequests().requestMatchers(EndpointRequest.to("info", "health")).permitAll();
which could be solved by checking that TypeEndpointRequestMatcher
matches only EndpointRequestMatcher
returned by toAnyEndpoint()
or by to()
if arguments contains an edpoint other than health
and info
which are of no interest and public
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.
Thanks for spotting this. My intention was to raise the flag only if EndpointRequest.toAnyEndpoint()
is being used. I'll check what's wrong and correct this query.
@pwntester I fixed these FPs in #3506. Please check it. |
Awesome, thanks! |
Hi there, have you considered promoting this out of Recent news suggest this is something companies sometimes get wrong and should be concerned with. See: |
This PR adds a query to detect open Spring Boot actuator endpoints. It flags custom Spring Security configurations that allow unauthenticated access to an actuator endpoint, like this one:
Unauthenticated Spring Boot actuators may leak sensitive information or even lead to remote code execution: https://www.veracode.com/blog/research/exploiting-spring-boot-actuators, https://spaceraccoon.dev/remote-code-execution-in-three-acts-chaining-exposed-actuators-and-h2-database.
Test cases are also added, but without the
.expected
file.