feat(security): implement security hardening #199
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
thwap/ttheart!199
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/implement-security-hardening"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Implement security hardening features:
PATH=/usr/local/bin:/usr/bin:/binandHOME=/var/empty(#141)rate_limitin config (#142)tls_certandtls_keyconfig options enable HTTPS (#143)Why
Production security requirements. Rate limiting prevents DoS, TLS secures transport, restricted env prevents information leaks via child processes, and privilege drop limits impact of compromise.
Testing
go test ./...and pre-commit passBreaking Changes
None. All features are opt-in via config.
Notes
rate_limit: 0disables rate limiting (default)Closes #144
Closes #140
Closes #141
Closes #142
Closes #143
Review
Solid security hardening. Full project lint, vet, all tests pass.
Features implemented:
Privilege drop (
main.go:107-117) — checksos.Getuid(), drops to UID/GID 65534 viasyscall.Setgidthensyscall.Setuid. Non-fatal on failure (log warning). Correct order: GID before UID.Restricted command environment (
executor.go:96-99) —c.Env = []string{"PATH=/usr/local/bin:/usr/bin:/bin", "HOME=/var/empty"}. Strips all inherited env vars, preventing secret leakage to child processes.Per-IP rate limiting (
middleware.go:33-97) — token bucket algorithm, configurable viarate_limitin config (0 = disabled). Returns 429 when exhausted. Logging middleware wraps rate limiter so rate-limited requests are still logged.TLS support (
main.go:92-101) —tls_cert/tls_keyconfig options, auto-detect: if both set →ListenAndServeTLS, else plain HTTP.Models:
TLSCert,TLSKey,RateLimitadded to Config with YAML tags. All optional (zero-value = disabled).Non-blocking: The rate limiter's
clientsmap grows unboundedly with unique IPs. Consider periodic cleanup of stale entries for long-running servers under wide IP attacks.No blocking issues.
APPROVED