Repository navigation
Description
Upstream dependencies
Keep this issue open until the relevant upstream changes are available, any required StackQL integration is complete, and the acceptance checks here pass. Upstream issue closure alone is not sufficient.
Constituent of #769. Reviewed current main at 1de4135 on 2026-10-08; this issue proposes work, no implementation is included.
CWEs: CWE-770.
Finding and evidence
wire.go creates an unbounded goroutine per accepted connection using context.Background. Deadline methods exist but have no production callers in the pinned fork. Each established connection creates driver/orchestrator state (internal/stackql/driver/driver.go).
SLEEP validates only a positive duration then calls time.Sleep without cancellation (internal/stackql/primitivegenerator/statement_analyzer.go). In debug mode, debugBuf is retained for the connection and GetDebugStr returns all accumulated bytes without reset; the wire layer sends it after queries. Repeated notices can increase retained memory and retransmitted data.
These are source-confirmed missing lifecycle controls. No large connection flood or memory-exhaustion test was run. The fork already has a message-size check; do not describe pgwire frame allocation as entirely unbounded.
Required outcome
- Add configurable connection admission, handshake/read/idle deadlines and bounded statement lifetime with cancellation propagated into execution.
- Bound or disable SLEEP for remote callers unless explicitly allowed; make it interruptible.
- Bound per-statement debug capture and clear consumed content instead of replaying the whole connection history. Document the opt-in exposure of request/response bodies in notices.
- Implement wire-level controls in psql-wire and consume them through stackql operator configuration.
Validation and acceptance
Use small deterministic tests for cap+1 connections, incomplete startup packets, idle clients, disconnect during SLEEP and cancellation. Test repeated debug-producing queries for bounded retention and no previous-query replay. Add robot server-liveness assertions and retain protocol frame-size tests.
Scope and related work
Connection authentication does not solve resource limits. #803 covers fuzzing; #359 covers header redaction. Avoid introducing a second general fuzz or logging issue for these same requirements.
Activity