Skip to content

Fix httpexchanges filter missing Security-rejected requests#50765

Open
VedPatel2811 wants to merge 1 commit into
spring-projects:mainfrom
VedPatel2811:fix/6545-trace-filter-security-requests
Open

Fix httpexchanges filter missing Security-rejected requests#50765
VedPatel2811 wants to merge 1 commit into
spring-projects:mainfrom
VedPatel2811:fix/6545-trace-filter-security-requests

Conversation

@VedPatel2811

Copy link
Copy Markdown

Problem

The /actuator/httpexchanges endpoint (formerly /trace) does not record
requests that are rejected by Spring Security, because HttpExchangesFilter
runs at LOWEST_PRECEDENCE - 10, after Spring Security's FilterChainProxy
has already short-circuited the request.

Solution

Add a new HttpExchangesStartingFilter that runs at HIGHEST_PRECEDENCE + 1
(before Spring Security). It starts recording the exchange and stores the
HttpExchange.Started instance as a request attribute. HttpExchangesFilter
is updated to reuse that attribute when present, and signals back via a
second attribute to prevent double-recording. If HttpExchangesFilter is
never reached (e.g. 401 from Security), the starting filter's finally
block records the exchange instead.

Testing

  • HttpExchangesStartingFilterTests: unit tests for the new filter
    including filterRecordsWhenChainTerminatesEarly which directly
    simulates the Security short-circuit scenario
  • HttpExchangesFilterTests: updated to cover coordination between
    both filters (twoFiltersCombinedRecordExchangeOnce,
    filterReusesStartedExchangeFromStartingFilter,
    filterSetsFinishedAttributeAfterRecording)
  • ServletHttpExchangesAutoConfigurationTests: confirms both filters
    are registered as beans by autoconfiguration

Fixes gh-6545

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 13, 2026
Add HttpExchangesStartingFilter that runs at HIGHEST_PRECEDENCE + 1
to record exchanges before Spring Security can short-circuit the
filter chain. HttpExchangesFilter coordinates with it via request
attributes to avoid double-recording.

Fixes spring-projectsgh-6545

Signed-off-by: Ved Patel <veds28112004@gmail.com>
@VedPatel2811 VedPatel2811 force-pushed the fix/6545-trace-filter-security-requests branch from 762f299 to b0026a2 Compare June 13, 2026 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/trace filter misses requests that are handled by other filters (especially Spring Security)

2 participants