GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — CodeQL query to detect open Spring Boot actuator endpoints by ggolawski · Pull Request #2901 · github/codeql

Conversation

@ggolawski

@ggolawski ggolawski commented Feb 23, 2020

Copy link
Copy Markdown
Contributor

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:

@Configuration(proxyBeanMethods = false)
public class ActuatorSecurity extends WebSecurityConfigurerAdapter {

  @Override
  protected void configure(HttpSecurity http) throws Exception {
    // BAD: Unauthenticated access to Spring Boot actuator endpoints is allowed
    http.requestMatcher(EndpointRequest.toAnyEndpoint()).authorizeRequests((requests) ->
        requests.anyRequest().permitAll());
  }
}

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ggolawski
CodeQL query to detect open Spring Boot actuator endpoints
fda4ab1
@ggolawski
ggolawski requested review from a team and felicitymay as code owners February 23, 2020 19:23
@ggolawski ggolawski mentioned this pull request Feb 23, 2020
CodeQL query to detect open Spring Boot actuator endpoints github/securitylab#42
Closed
1 task
@aschackmull aschackmull added the Java label Mar 6, 2020
@aschackmull

aschackmull commented Mar 31, 2020

Copy link
Copy Markdown
Contributor

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 experimental directory as per those guidelines, then we'll be able to proceed more quickly with this PR.

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@aschackmull

aschackmull commented Apr 2, 2020

Copy link
Copy Markdown
Contributor

We tried running this across all of lgtm.com https://lgtm.com/query/483327956475899158/ and got zero results.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ggolawski added 3 commits April 2, 2020 22:06
@ggolawski
Merge branch 'master' into java-spring-boot-actuators
cffe89f
@ggolawski
Move to experimental
f05b2af
@ggolawski
Fix
6ca963a
@ggolawski

ggolawski commented Apr 2, 2020

Copy link
Copy Markdown
Contributor Author

I've moved the query to experimental and added the reference to an article that describes how to exploit this to get RCE (https://www.veracode.com/blog/research/exploiting-spring-boot-actuators).

When you search for EndpointRequest.toAnyEndpoint() in GitHub and exclude test classes, you'll get 2K results (https://github.com/search?l=Java&p=36&q=EndpointRequest.toAnyEndpoint%28%29+-filename%3A%2ATests.java&type=Code), but indeed mainly in demos and samples. I was pretty sure that this kind of misconfiguration is much more common. Anyway I think that I could find some 'real' projects (I'm not sure about this, so please verify):

  • https://github.com/arianthox/CoreEngine (https://github.com/arianthox/CoreEngine/blob/3f9cb6552b4559ca1fb1cb15f6468aabaef94922/src/main/java/com/arianthox/predictor/config/SecurityConfig.java)
  • https://github.com/davidwadden/conductor-workers (https://github.com/davidwadden/conductor-workers/blob/b49809908a02229c8bafbb3ba5f08422f80a8c9f/workers-app/src/main/java/io/pivotal/conductor/worker/app/WebSecurityConfig.java)
  • https://github.com/hoffipublic/minimal_microservices (https://github.com/hoffipublic/minimal_microservices/blob/6e8f7392566b305178ff89cc78cc24c0a7ff41d9/microservice/src/main/java/com/hoffi/minimal/microservices/microservice/bootconfigs/ActuatorConfig.java)

These projects are not available on LGTM, but the actuators are exposed in the same as in my test code, so my query should detect these issues.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@aschackmull

aschackmull commented Apr 3, 2020

Copy link
Copy Markdown
Contributor

Thank you very much for those references. This definitely helps our evaluation.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

aschackmull
aschackmull reviewed Apr 3, 2020
View reviewed changes
Comment thread java/ql/src/experimental/Security/CWE/CWE-016/SpringBootActuators.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

ggolawski and others added 2 commits April 3, 2020 21:36
@ggolawski @aschackmull
Update java/ql/src/experimental/Security/CWE/CWE-016/SpringBootActuat…
79d7ea3
…ors.qll

Co-Authored-By: Anders Schack-Mulligen <[email protected]>
@ggolawski
Make the test runnable via codeql test run
1d8da90
@ggolawski

ggolawski commented Apr 3, 2020

Copy link
Copy Markdown
Contributor Author

Thanks for the suggestion. I've committed the change.
I've also added stubs, qlpack.yml and expected results, so the test for the query is runnable via codeql test run.

Please verify if everything is fine, especially qlpack.yml files - I had to add them in src/experimental and test/experimental.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ggolawski
Remove qlpack.yml as these are not needed
639aa82
@ggolawski

ggolawski commented Apr 27, 2020

Copy link
Copy Markdown
Contributor Author

I've removed qlpack.yml files - I've realized that they're not needed.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

aschackmull
aschackmull approved these changes Apr 29, 2020
View reviewed changes

@aschackmull aschackmull left a comment

Copy link
Copy Markdown
Contributor

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ggolawski reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@aschackmull
aschackmull merged commit 29a5ea1 into github:master Apr 29, 2020
@ggolawski
ggolawski deleted the java-spring-boot-actuators branch April 30, 2020 18:25
pwntester
pwntester reviewed May 15, 2020
View reviewed changes
Comment thread java/ql/src/experimental/Security/CWE/CWE-016/SpringBootActuators.qll
Comment on lines +88 to +97
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

@pwntester pwntester May 15, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@ggolawski ggolawski May 18, 2020

Copy link
Copy Markdown
Contributor Author

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ggolawski ggolawski mentioned this pull request May 18, 2020
Fixes FPs in SpringBootActuators query #3506
Merged
@ggolawski

ggolawski commented May 18, 2020

Copy link
Copy Markdown
Contributor Author

@pwntester I fixed these FPs in #3506. Please check it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pwntester

pwntester commented May 19, 2020

Copy link
Copy Markdown
Contributor

Awesome, thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iamvolvo

iamvolvo commented Jan 9, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Hi there, have you considered promoting this out of experimental?

Recent news suggest this is something companies sometimes get wrong and should be concerned with. See:

  • https://www.spiegel.de/netzwelt/web/volkswagen-konzern-datenleck-wir-wissen-wo-dein-auto-steht-a-e12d33d0-97bc-493c-96d1-aa5892861027
  • https://media.ccc.de/v/38c3-wir-wissen-wo-dein-auto-steht-volksdaten-von-volkswagen#l=eng&t=1344
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jcogs33 jcogs33 mentioned this pull request Feb 25, 2025
Java: Promote Spring Boot Actuators query from experimental #18793
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@aschackmull aschackmull aschackmull approved these changes
@felicitymay felicitymay Awaiting requested review from felicitymay
+1 more reviewer
@pwntester pwntester pwntester left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

Java

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@ggolawski @aschackmull @pwntester @iamvolvo
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.