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:
cdnutterandClaude Opus 5.5 committed 2026-11-23 13:16:31 -08:00
1 parent cb2604bd05
commit 796384420b
15 files changed
+220 -17

No files matched your search

+16 -1
View File
@@ -15,9 +15,24 @@ type loginPage struct {
Next string
}
// localPath reports whether next is a path on this site. Browsers drop tabs
// and newlines from URLs and treat a backslash like "/", so "/\t/evil.example"
// would become "//evil.example"; any control character or backslash fails.
func localPath(next string) bool {
if !strings.HasPrefix(next, "/") || strings.HasPrefix(next, "//") {
return false
}
for i := 0; i < len(next); i++ {
if c := next[i]; c < 0x20 || c == 0x7f || c == '\\' {
return false
}
}
return true
}
// safeNext only allows local redirect targets.
func safeNext(next string) string {
if !strings.HasPrefix(next, "/") || strings.HasPrefix(next, "//") || strings.HasPrefix(next, "/\\") {
if !localPath(next) {
return "/admin"
}
return next