🛡️ Sentinel: [Critical] Prevent DoS by enforcing idle timeouts in TCP proxy#236
🛡️ Sentinel: [Critical] Prevent DoS by enforcing idle timeouts in TCP proxy#236google-labs-jules[bot] wants to merge 2 commits into
Conversation
… 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.
|
👋 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 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.
Severity: Critical
Vulnerability: The proxy used
io.CopyBufferon plainnet.Connwithout 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, anet.Connwrapper 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
timeoutConninterferes with valid long-lived streams (e.g., SSH without keep-alive), revert this change and instead expose a configurable idle timeout inTailscaleProxyServerOptions.Next Knobs: The
TCPIdleTimeoutglobal 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