Security audit fixes: JWT secret guard, WS revocation, nginx headers/TLS, loopback Gitea
Deploy with Docker Compose / deploy (push) Successful in 59s
Deploy with Docker Compose / deploy (push) Successful in 59s
- auth: panic at init if BACKEND_SECRET missing/short — HS256 would happily start with an empty key, making admin tokens forgeable by anyone - websocket: admin check now goes through AuthenticateTokenWithClaims so the "tv" token-version revocation applies on /ws too; a logged-out or password-changed token no longer keeps it alive for its full lifetime - admin diagnostics: check BACKEND_SECRET not the nonexistent AUTH_SECRET - rowing upload: 10MB cap before buffering + base64 (admin-only route, but unbounded read = easy memory exhaustion + huge paid Claude call) - nginx: shared security_headers.conf (XFO/nosniff/Referrer-Policy/HSTS/CSP) included in every location that sets its own add_header — nginx drops the parent's whole set otherwise; CSP added to the SPA document; ssl_protocols pinned to TLSv1.2/1.3; HSTS on apex redirect - compose: Gitea HTTP bound to 127.0.0.1 (plain HTTP was LAN-exposed); autoheal docker socket mount read-only Co-Authored-By: Claude Code <[email protected]>
This commit is contained in:
@@ -87,6 +87,15 @@ func (store *Store) CreateRowing(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// Cap the upload before buffering it (and then base64-encoding it, 1.33x
|
||||
// bigger): the route is admin-only but an unbounded read would still let
|
||||
// a giant file exhaust the Pi's memory and produce a huge paid API call.
|
||||
// 10MB is well above any photo this endpoint is meant to take.
|
||||
if file.Size > 10<<20 {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{"error": "image too large (max 10MB)"})
|
||||
return
|
||||
}
|
||||
|
||||
data, err := io.ReadAll(f)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, gin.H{"error": "failed to read image"})
|
||||
|
||||
Reference in New Issue
Block a user