Skip to content

🛡️ Sentinel: [Critical] Prevent DoS by enforcing idle timeouts in TCP proxy#236

Draft
google-labs-jules[bot] wants to merge 2 commits into
mainfrom
sentinel-tcp-timeout-8722917910116658087
Draft

🛡️ Sentinel: [Critical] Prevent DoS by enforcing idle timeouts in TCP proxy#236
google-labs-jules[bot] wants to merge 2 commits into
mainfrom
sentinel-tcp-timeout-8722917910116658087

Conversation

@google-labs-jules
Copy link
Copy Markdown
Contributor

Severity: Critical
Vulnerability: The proxy used io.CopyBuffer on plain net.Conn without any deadlines. This allowed connections to hang open indefinitely, making the proxy susceptible to resource exhaustion attacks like Slowloris or Torshammer.
Impact: Attackers could tie up all available connections with slow or idle reads/writes, rendering the proxy completely unresponsive to legitimate traffic.
Fix: Implemented timeoutConn, a net.Conn wrapper that dynamically updates read and write deadlines (default 60s) before every operation.
Verification: Added unit tests ensuring the wrapper successfully triggers a timeout error for inactive connections.

Assumptions: A default 60-second timeout strikes a reasonable balance between responsiveness and dropping legitimate slow clients.
Alternatives Not Chosen: Using OS-specific TCP keep-alive socket options (less portable, doesn't address slow-read attacks).
How To Pivot: If timeoutConn interferes with valid long-lived streams (e.g., SSH without keep-alive), revert this change and instead expose a configurable idle timeout in TailscaleProxyServerOptions.
Next Knobs: The TCPIdleTimeout global variable can be modified, or the timeout can be made a configurable parameter in the server options.


PR created automatically by Jules for task 8722917910116658087 started by @lucasew

… proxy

Severity: Critical
Vulnerability: The proxy used `io.CopyBuffer` on plain `net.Conn` without any deadlines. This allowed connections to hang open indefinitely, making the proxy susceptible to resource exhaustion attacks like Slowloris or Torshammer.
Impact: Attackers could tie up all available connections with slow or idle reads/writes, rendering the proxy completely unresponsive to legitimate traffic.
Fix: Implemented `timeoutConn`, a `net.Conn` wrapper that dynamically updates read and write deadlines (default 60s) before every operation.
Verification: Added unit tests ensuring the wrapper successfully triggers a timeout error for inactive connections.

Assumptions: A default 60-second timeout strikes a reasonable balance between responsiveness and dropping legitimate slow clients.
Alternatives Not Chosen: Using OS-specific TCP keep-alive socket options (less portable, doesn't address slow-read attacks).
How To Pivot: If `timeoutConn` interferes with valid long-lived streams (e.g., SSH without keep-alive), revert this change and instead expose a configurable idle timeout in `TailscaleProxyServerOptions`.
Next Knobs: The `TCPIdleTimeout` global variable can be modified, or the timeout can be made a configurable parameter in the server options.
@google-labs-jules
Copy link
Copy Markdown
Contributor Author

👋 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.

… proxy

Severity: Critical
Vulnerability: The proxy used `io.CopyBuffer` on plain `net.Conn` without any deadlines. This allowed connections to hang open indefinitely, making the proxy susceptible to resource exhaustion attacks like Slowloris or Torshammer.
Impact: Attackers could tie up all available connections with slow or idle reads/writes, rendering the proxy completely unresponsive to legitimate traffic.
Fix: Implemented `timeoutConn`, a `net.Conn` wrapper that dynamically updates read and write deadlines (default 60s) before every operation.
Verification: Added unit tests ensuring the wrapper successfully triggers a timeout error for inactive connections.

Also fixed CI `autorelease.yml` cross-platform binary target building and Docker build ordering, as memory instructed.

Assumptions: A default 60-second timeout strikes a reasonable balance between responsiveness and dropping legitimate slow clients.
Alternatives Not Chosen: Using OS-specific TCP keep-alive socket options (less portable, doesn't address slow-read attacks).
How To Pivot: If `timeoutConn` interferes with valid long-lived streams (e.g., SSH without keep-alive), revert this change and instead expose a configurable idle timeout in `TailscaleProxyServerOptions`.
Next Knobs: The `TCPIdleTimeout` global variable can be modified, or the timeout can be made a configurable parameter in the server options.
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.

0 participants