Skip to content

Fix MessageBuffer.ResendAsync and send-side FIN DoS - #10241

Merged
akoeplinger merged 1 commit into
mainfrom
porting
Oct 15, 2026
Merged

akoeplinger merged 1 commit into
mainfrom
porting

Conversation

@cincuranet

Copy link
Copy Markdown
Contributor

Prevents malicious or abruptly disconnected stateful-reconnect clients from indefinitely blocking SignalR broadcasts and retaining server resources. Healthy reconnects remain unaffected as long as replay continues making progress.

…d-side FIN DoS

Prevents malicious or abruptly disconnected stateful-reconnect clients from indefinitely blocking SignalR broadcasts and retaining server resources. Healthy reconnects remain unaffected as long as replay continues making progress.

- [ ] Yes
- [x] No

- [ ] High
- [x] Medium
- [ ] Low

The code change is localized to the opt-in stateful reconnect path, but it modifies concurrency, cancellation, timer, and connection-abort behavior shared by both SignalR server and .NET client implementations.

- [x] Manual (required)
- [x] Automated

- [ ] Yes
- [ ] No
- [x] N/A

----

Bug fix to address denial of service vulnerabilities in SignalR's MessageBuffer component related to backpressure handling and resource cleanup.

This PR fixes two critical issues in SignalR's MessageBuffer: a DoS vulnerability caused by indefinite blocking during backpressure scenarios and improper disposal handling. The changes add timeout mechanisms to prevent infinite waits and ensure proper resource cleanup.

- `MessageBuffer.cs`: Added 5-second backpressure timeout to `ResendAsync` method with cancellation token support to prevent indefinite blocking during message resend operations
- `MessageBuffer.cs`: Added backpressure timeout to `RunTimer` method's ACK message sending and implemented connection abort on timeout to prevent send-side FIN DoS attacks
- `MessageBuffer.cs`: Added thread-safe disposal pattern using `Interlocked.Exchange` and wrapped timer disposal to prevent double-dispose exceptions
- `MessageBufferTests.cs`: Added test coverage for backpressure timeout scenarios including `ResendBackpressureTimesOutAndUnblocksPendingWrites` and `AckBackpressureTimesOutReleasesWriteLockAndAbortsConnection`
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
Copilot AI balanced review requested due to automatic review settings October 15, 2026 12:04
@dotnet-policy-service
dotnet-policy-service Bot requested a review from a team October 15, 2026 12:04
@azure-pipelines

Copy link
Copy Markdown
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new abort paths do not terminate .NET client connections, leaving sending or acknowledgment processing broken after timeouts.

1 open finding
What changed in this PR

Bounds SignalR stateful-reconnect stalls to prevent blocked broadcasts and retained resources while allowing replay to continue as it makes progress.

Changes:

  • Adds acknowledgment and replay timeouts, with resets after replay progress.
  • Stops replay on canceled or completed flushes.
  • Adds timeout, progress, and write-unblocking tests.
File Description
src/​aspnetcore/​src/​SignalR/​server/​SignalR/​test/​Microsoft.AspNetCore.SignalR.Tests/​Internal/​MessageBufferTests.cs Adds regression tests and controllable pipe writers.
src/​aspnetcore/​src/​SignalR/​common/​Shared/​MessageBuffer.cs Adds bounded waits, failure handling, and guarded disposal.

🧠 Review effort: Balanced


💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@akoeplinger

Copy link
Copy Markdown
Member

Failure is a known issue: #10115

@akoeplinger
akoeplinger merged commit d230a4a into main Oct 15, 2026
9 of 11 checks passed
@akoeplinger
akoeplinger deleted the porting branch October 15, 2026 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants