Skip to content

πŸ›‘οΈ Sentinel: Enforce concurrency limit on daemon socket#92

Open
minibota wants to merge 1 commit intomainfrom
security/nightly-2026-01-29-1744658072634750238
Open

πŸ›‘οΈ Sentinel: Enforce concurrency limit on daemon socket#92
minibota wants to merge 1 commit intomainfrom
security/nightly-2026-01-29-1744658072634750238

Conversation

@minibota
Copy link
Copy Markdown
Contributor

πŸ” Issue: The daemon's socket listener (Accept loop) spawned a new goroutine for every incoming connection without limit. A local attacker could rapidly open thousands of connections, causing the daemon to spawn thousands of goroutines (Unbounded Concurrency), leading to resource exhaustion (DoS).

🧠 Risk: High. A local user (even unprivileged, depending on socket permissions) could crash the daemon or make the system unresponsive by flooding the socket.

πŸ› οΈ Fix:

  • Added a semaphore (chan struct{}) with a limit of 50 concurrent connections.
  • When the limit is reached, the Accept loop blocks, relying on the OS socket backlog to queue further connections.
  • Added explicit check for net.ErrClosed to ensure the listener loop exits cleanly during shutdown.

πŸ§ͺ Tests:

  • Added cmd/security_concurrency_test.go:
    • Simulates a flood of 100 concurrent connections.
    • Verifies that the number of goroutines spawned by the daemon is capped near the limit (tested with limit=10).
  • Ran go test ./cmd/... to ensure no regressions.

πŸ“Ž Notes: This change makes the daemon robust against connection floods while maintaining sufficient concurrency for legitimate execution reports.
This PR was created by an automated nightly security task.


PR created automatically by Jules for task 1744658072634750238 started by @minibota

… DoS

- Introduced `maxConcurrentConnections` (50) to limit active socket handlers.
- Implemented semaphore pattern in `startSocketListener` to apply backpressure.
- Fixed shutdown loop to exit cleanly on `net.ErrClosed`.
- Added `cmd/security_concurrency_test.go` to verify the fix and prevent regressions.

Co-authored-by: minibota <1483356+minibota@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

πŸ‘‹ Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a πŸ‘€ emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

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.

1 participant