Repository navigation
Description
Constituent of #769. Reviewed current main at 1de4135 on 2026-10-08; this issue proposes work, no implementation is included.
CWEs: CWE-73, CWE-200, CWE-488.
Source: GitHub Security Lab finding 21537, originally tested at adc0956, plus current-code review and the validation below. Credit: GitHub Security Lab Taskflow Agent, GitHub Secure Open Source Fund, reported by @JarLob.
Finding and evidence
internal/stackql/planbuilder/plan_builder.go writes KeyFilePath/KeyEnvVar before prov.Auth returns. internal/stackql/handler/handler.go returns the shared pointer, and Clone shares the auth map (internal/stackql/handler/handler.go, internal/stackql/handler/handler.go). SET SESSION "$.auth.<provider>..." is another credential mutation route.
Reproduced on the current build using the local k8s fixture and a loopback HTTP collector with fake tokens only:
- A SELECT sent
Bearer FAKE-OPERATOR-TOKEN. AUTH LOGIN k8s SA '<temporary-other-token-file>' ''returned unsupported service-account authentication.- A new connection's SELECT sent
Bearer FAKE-OTHER-TOKEN. AUTH LOGIN k8s SA '' 'SECURITY_PROBE_TOKEN'also errored; a third connection sent that fake environment token.
The lab independently reproduced this with mTLS. Authenticating the connection does not prevent credential-source redirection. Environment credentials take precedence over files; this AUTH path cannot clear fields. Header validation blocks newline-containing values, so do not claim wholesale PEM or arbitrary multiline-file exfiltration.
Required outcome
- Make credential-source mutation a deliberate operator capability on server surfaces, covering AUTH and SET, with restricted named sources if overrides are supported.
- Define session versus process scope and ensure a rejected change leaves existing credentials intact. If session changes are supported, isolate auth contexts and cached provider/auth state coherently, including concurrent access.
- Keep operator-controlled credential reload working. Scrub client-facing OS paths and credential parse details from rejected source reads while retaining useful server diagnostics.
Validation and acceptance
Add black-box tests using two simultaneous clients and fake files/env vars: denied overrides, failed AUTH atomicity, source precedence, SET aliases/scopes, disconnect/reconnect, and unchanged credentials in the other session. Include an mTLS server and race-focused tests for supported mutation paths.
Scope and related work
Credential-source control is distinct from destination/egress control, which can expose an already configured token without AUTH. Full RBAC belongs to #312. PR #804 deferred this design; a shallow pointer copy alone is not a complete fix.
Activity