Skip to content

Commit 9e51b01

Browse files
Jami CogswellJami Cogswell
authored andcommitted
Java: handle example in Spring docs
1 parent b2469ff commit 9e51b01

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

java/ql/lib/semmle/code/java/security/SpringBootActuatorsQuery.qll

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,5 +142,14 @@ predicate permitsSpringBootActuators(PermitAllCall permitAllCall) {
142142
registryRequestMatchersCall.getQualifier() = authorizeCall and
143143
permitAllCall.getQualifier() = registryRequestMatchersCall
144144
)
145+
or
146+
exists(Variable v, MatcherCall matcherCall |
147+
// http.securityMatcher(EndpointRequest.toAnyEndpoint());
148+
// http.authorizeRequests([...].permitAll())
149+
v.getAnAccess() = authorizeCall.getQualifier() and
150+
v.getAnAccess() = matcherCall.getQualifier() and
151+
authorizeCall.getArgument(0).(LambdaExpr).getExprBody() = permitAllCall and
152+
permitAllCall.getQualifier() instanceof AnyRequestCall
153+
)
145154
)
146155
}

java/ql/test/query-tests/security/CWE-016/SpringBootActuatorsTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,4 +264,11 @@ protected void configureOkNoPermitAll4_securityMatchers(HttpSecurity http) throw
264264
protected void configureOkNoPermitAll7_securityMatchers(HttpSecurity http) throws Exception {
265265
http.securityMatchers(matcher -> EndpointRequest.toAnyEndpoint()).authorizeHttpRequests().anyRequest();
266266
}
267+
268+
// Spring doc example
269+
// https://docs.spring.io/spring-boot/reference/actuator/endpoints.html#actuator.endpoints.security
270+
public void securityFilterChain(HttpSecurity http) throws Exception {
271+
http.securityMatcher(EndpointRequest.toAnyEndpoint());
272+
http.authorizeHttpRequests((requests) -> requests.anyRequest().permitAll()); // $ hasExposedSpringBootActuator
273+
}
267274
}

0 commit comments

Comments
 (0)