Skip to content
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

Actuator in Spring Boot 3.0 breaks RequestRejectedException logic #33985

Closed
alexey-halturin opened this issue Jan 26, 2023 · 1 comment
Closed
Labels
for: external-project For an external project and not something we can fix status: duplicate A duplicate of another issue

Comments

@alexey-halturin
Copy link

Summary

In Spring Security 6 RequestRejectedException behaviour was changed to return 400 (bad request) if URL contains text forbidden by HTTP firewall like ";", "//" etc. (spring-projects/spring-security#7568). However, after upgrading to Spring Boot 3.0.2, if the project contains spring-boot-starter-actuator as a dependency, the application responds with 200 instead of 400.

How to replicate

Create a new Spring Boot 3 application and implement the simple test:

@SpringBootTest
@AutoConfigureMockMvc
public class BadRequestTest {

    @Autowired
    private MockMvc mockMvc;

    @Test
    public void testBadRequest() throws Exception {
        mockMvc.perform(get("/orders;sds")).andExpect(status().isBadRequest());
    }

}

This test will succeed as expected.

Then add the dependency:

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-actuator</artifactId>
		</dependency>

The test will fail.

The reason

As I can see it happens because the requestRejectedHandler in the FilterChainProxy has been replaced with an ObservationMarkingRequestRejectedHandler which doesn't correctly handle the RequestRejectedException.

Workaround

As I workaround I excluded these autoconfigurations:
- org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration
- org.springframework.boot.actuate.autoconfigure.observation.web.servlet.WebMvcObservationAutoConfiguration

But I think that ObservationMarkingRequestRejectedHandler should handle such exception correctly by default and the response should be 400 as expected.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 26, 2023
@wilkinsona
Copy link
Member

Thanks for the report. This is a duplicate of spring-projects/spring-security#12548.

While we don't consider this to be security vulnerability, in the future please consider reporting security-related problems that have the potential to be a vulnerability by following the instructions in https://spring.io/security-policy.

@wilkinsona wilkinsona closed this as not planned Won't fix, can't repro, duplicate, stale Jan 26, 2023
@wilkinsona wilkinsona added status: duplicate A duplicate of another issue for: external-project For an external project and not something we can fix and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants