Skip to content

Commit 3f12859

Browse files
sec(postgres): bound DedicatedProvider Neon HTTP client with neonHTTPTimeout (#32)
Closes SEC-PROV finding (audit wave 2026-05-29): NewDedicatedProvider used `&http.Client{}` with NO timeout for the Neon Management API path. A hung Neon connection would wedge the provisioning gRPC handler (and any caller — worker storage tick, regrader) indefinitely, piling up goroutines until OOM. NeonBackend already bounds its client at neonHTTPTimeout (30s); the DedicatedProvider path was an oversight in the same family. Fix: 1-line — set Timeout on the &http.Client literal. Reuses the existing constant so any future tuning lands in one place. Production LOC delta: 1 functional + 5 comment lines. Co-authored-by: Manas Srivastava <[email protected]> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 3e99ea1 commit 3f12859

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

internal/backend/postgres/dedicated.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,17 @@ type DedicatedProvider struct {
3434
// NewDedicatedProvider creates a DedicatedProvider.
3535
// adminDSN is used when neonAPIKey is empty (local/dev simulation).
3636
// neonAPIKey triggers the real Neon API path.
37+
// SEC (2026-05-29): the httpClient uses neonHTTPTimeout (defined in neon.go)
38+
// so a hung Neon Management API connection cannot wedge the provisioning
39+
// gRPC handler indefinitely. Without this bound a default `&http.Client{}`
40+
// has NO timeout — a single Neon outage would pile up goroutines until the
41+
// pod OOMs. Matches the timeout already on NeonBackend.client.
3742
func NewDedicatedProvider(adminDSN, neonAPIKey string) *DedicatedProvider {
3843
return &DedicatedProvider{
3944
adminDSN: adminDSN,
4045
neonAPIKey: neonAPIKey,
4146
neonBaseURL: neonAPIBase, // reuse the constant from neon.go
42-
httpClient: &http.Client{},
47+
httpClient: &http.Client{Timeout: neonHTTPTimeout},
4348
}
4449
}
4550

0 commit comments

Comments
 (0)