Skip to content

πŸ›‘οΈ Sentinel: Limit concurrent socket connections to prevent DoS#95

Open
minibota wants to merge 1 commit intomainfrom
security/nightly-2026-01-31-618719565753858636
Open

πŸ›‘οΈ Sentinel: Limit concurrent socket connections to prevent DoS#95
minibota wants to merge 1 commit intomainfrom
security/nightly-2026-01-31-618719565753858636

Conversation

@minibota
Copy link
Copy Markdown
Contributor

πŸ” Issue: The daemon's Unix socket listener (startSocketListener) accepted an unlimited number of concurrent connections, spawning a new goroutine for each one. A local attacker could exploit this to exhaust system resources (Goroutines, memory), leading to a Denial of Service (DoS).

🧠 Risk: High. A malicious local user or a compromised process could crash the agent or make it unresponsive, preventing legitimate cron jobs from reporting their status or receiving updates.

πŸ› οΈ Fix: Introduced a semaphore (buffered channel) to limit the number of concurrent active socket handlers to 50 (maxConcurrentConnections).

  • Connections are accepted by the listener loop.
  • Before spawning a handler goroutine, the loop attempts to acquire a token from the semaphore.
  • If the limit is reached, the loop blocks, providing backpressure. The OS socket backlog handles queuing pending connections.
  • The token is released when the handler completes.

πŸ§ͺ Tests: Added TestBoundedConcurrency in cmd/security_concurrency_test.go.

  • This test verifies that the daemon correctly limits concurrency.
  • It overrides the limit to 5, launches 50 clients, and asserts that the number of goroutines increases by ~5 (plus clients) rather than ~55.

πŸ“Ž Notes: This PR was created by an automated nightly security task.


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

Implements a semaphore to limit the number of concurrent connections
handled by the daemon's Unix socket listener. This prevents local
attackers from exhausting system resources (goroutines, memory)
by opening a large number of connections.

Limits concurrency to 50 active handlers. Clients beyond this limit
will be queued by the OS socket backlog until a slot becomes available.

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