Security sweep: fix open redirect, XFF rate-limit bypass, SSRF; harden image and compose
- Reject control chars and backslashes in redirect targets - Use proxy-added X-Forwarded-For entry, cap limiter keys - Block private/loopback/link-local addresses on image fetch - HSTS over HTTPS, generic error on custom CSS - x/crypto 0.59.0, pin golang:1.27.4-alpine3.24 and alpine:3.24.4 - Compose: cap_drop ALL, no-new-privileges, read_only, limits, labels - Add SECURITY.md, CHANGELOG.md, TODO.md Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cb2604bd05
commit
796384420b
15 files changed
+220
-17
No files matched your search
@@ -77,10 +77,22 @@ func (l *Limiter) Blocked(key string) bool {
|
||||
return len(l.prune(key, time.Now())) >= l.max
|
||||
}
|
||||
|
||||
// maxKeys caps how many keys a Limiter tracks, so a flood of failures from
|
||||
// many addresses can't grow it without bound.
|
||||
const maxKeys = 10000
|
||||
|
||||
func (l *Limiter) Fail(key string) {
|
||||
l.mu.Lock()
|
||||
defer l.mu.Unlock()
|
||||
now := time.Now()
|
||||
if _, ok := l.hits[key]; !ok && len(l.hits) >= maxKeys {
|
||||
for k := range l.hits {
|
||||
l.prune(k, now)
|
||||
}
|
||||
if len(l.hits) >= maxKeys {
|
||||
return // still full: drop this one rather than grow
|
||||
}
|
||||
}
|
||||
l.hits[key] = append(l.prune(key, now), now)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user