Repository navigation
Stop the HTTP/1 request loop when the connection is aborted - #10225
Merged
Merged
Conversation
… connection is aborted Connection completion can set _connectionAborted without clearing _keepAlive. Request cleanup then skips body draining, but the request loop can parse unread body bytes as another request. This change clear _keepAlive before the volatile write to _connectionAborted so cleanup that observes the abort also observes persistence disabled. Keep _keepAlive as the sole request-loop condition and remove the unused OnRequestProcessingEnding hook. ## Customer Impact Prevents an aborted HTTP/1 connection from treating unread request-body bytes as a subsequent request, avoiding request desynchronization and unintended request dispatch after connection completion. ## Regression? - [x] Yes - [ ] No The regression was introduced by aspnet/KestrelHttpServer#2977. ## Risk - [ ] High - [ ] Medium - [X] Low The change is small and localized to Kestrel connection-abort ordering. The regression test covers the security-relevant case where unread request-body bytes resemble another request. ## Verification - [X] Manual (required) - [x] Automated ## Packaging changes reviewed? - [ ] Yes - [ ] No - [x] N/A ---- #### AI description (iteration 1) #### PR Classification Bug fix to prevent HTTP/1 connections from incorrectly parsing unread request body data as new requests when the connection is aborted. #### PR Summary This pull request fixes a bug where HTTP/1 request processing would continue and attempt to parse remaining data in the request body as a new request after the connection was aborted. The fix ensures the request loop terminates properly by disabling keep-alive before publishing the abort signal. - `HttpProtocol.cs`: Sets `_keepAlive` to false before setting `_connectionAborted` to ensure the request loop observes the disabled keep-alive state and stops processing - `HttpProtocol.cs`: Removes the unused `OnRequestProcessingEnding()` virtual method and related cleanup logic - `RequestTests.cs`: Adds test `InputCompletionDoesNotReparseUnreadRequestBody()` to verify that a GET request embedded in a POST body is not dispatched when the connection is aborted - `Http1Connection.cs`: Removes the empty override of `OnRequestProcessingEnding()` <!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot --> Co-authored-by: Copilot <[email protected]>
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The ordering fix is localized, memory-safe, and covered by a faithful regression test.
0 open findings
What changed in this PR
Stops the HTTP/1 request loop after connection abortion so unread body bytes cannot be parsed as another request.
Changes:
- Disables keep-alive before publishing the abort state.
- Adds regression coverage for unread request bodies.
- Removes an unused processing hook.
| File | Description |
|---|---|
HttpProtocol.cs |
Orders keep-alive shutdown before abort publication. |
Http1Connection.cs |
Removes the unused override. |
RequestTests.cs |
Verifies unread body bytes are not redispatched. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
halter73
approved these changes
Oct 14, 2026
This was referenced Oct 19, 2026
This was referenced Oct 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Connection completion can set _connectionAborted without clearing _keepAlive. Request cleanup then skips body draining, but the request loop can parse unread body bytes as another request.
This change clear _keepAlive before the volatile write to _connectionAborted so cleanup that observes the abort also observes persistence disabled. Keep _keepAlive as the sole request-loop condition and remove the unused OnRequestProcessingEnding hook.
Customer Impact
Prevents an aborted HTTP/1 connection from treating unread request-body bytes as a subsequent request, avoiding request desynchronization and unintended request dispatch after connection completion.
Regression?
The regression was introduced by aspnet/KestrelHttpServer#2977.
Risk
The change is small and localized to Kestrel connection-abort ordering. The regression test covers the security-relevant case where unread request-body bytes resemble another request.
Verification
Packaging changes reviewed?