π‘οΈ Sentinel: [MEDIUM] Fix missing input length limits#245
Conversation
Added explicit bounds checking to `c.PostForm` calls across authentication, API token creation, IP list, and exclusion management endpoints. This prevents Denial of Service (DoS) attacks caused by uncontrolled resource consumption when processing excessively long string inputs. Co-authored-by: arumes31 <114224498+arumes31@users.noreply.github.com>
|
π 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. |
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the βοΈ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
β¨ Finishing Touchesπ§ͺ Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
π¨ Severity: MEDIUM
π‘ Vulnerability: The application extracted fields from HTTP requests using
c.PostForm()without verifying the length of the provided strings. This allowed an attacker to submit massive payloads (e.g., a 2GB username), which the server would allocate memory for during processing, leading to rapid memory exhaustion and Denial of Service (CWE-400).π― Impact: An unauthenticated or authenticated attacker could crash the server by continuously submitting requests with excessively large form fields, severely impacting availability.
π§ Fix: Added defensive bounds checking (e.g.,
len(field) > MAX_LEN) immediately after data extraction inauth_handlers.go,excluded_handlers.go, andip_handlers.go. Short fields (usernames, TOTP codes) are capped at 255 bytes, while longer fields (passwords, allowed IPs, URLs) are capped at 2048 bytes. Exceeding these limits securely rejects the request.β Verification:
go test -short ./...to ensure no functionality is broken.curl -d "username=$(head -c 300 < /dev/zero | tr '\0' 'A')&password=foo" -X POST http://localhost:8080/login) and verify it fails securely with an "Invalid input length" error rather than processing it.PR created automatically by Jules for task 1616583081484492151 started by @arumes31