Skip to content

[SECURITY] Contain server request panics at the goroutine that executes the request #830

Open

Description

@jeffreyaven

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-476, CWE-248.

Finding and evidence

The pgwire server's per-connection goroutine has no recovery boundary (wire.go); driver HandleSimpleQuery/HandleExecute likewise have none. MCP addToolWithGate does not recover handler panics (pkg/mcp_server/gate.go). The command-level recover in runMCPServer covers only its own goroutine, not SDK handler goroutines.

Source searches found no non-test recover in the pinned psql-wire or MCP Go SDK modules. net/http's own recovery does not contain a panic in a separately spawned SDK/backend goroutine. This is failure-containment hardening, not a newly demonstrated remotely triggerable nil dereference. Previously fixed crashers such as #793 must not be refiled as current defects.

Required outcome

  • Establish recovery at relevant request/connection execution boundaries, including spawned execution workers, translating recoverable request panics to errors and closing only affected resources.
  • Preserve server diagnostics while avoiding stack/path/secret disclosure to clients.
  • Ensure transaction/lock/semaphore cleanup and define when a session must be discarded rather than reused after a panic.

Validation and acceptance

Add fault-injection tests in subprocesses for simple/extended pgwire and MCP stdio/HTTP handlers and workers; assert a bounded error/closed offending session and a successful subsequent request from another client. Continue root-cause fixes and fuzz liveness checks.

Scope and related work

#633 remains the tracker for concrete nil-reference fixes and #803 for fuzzing. This is the independent containment boundary, not a replacement for fixing the underlying bugs.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions