fix(llm): rename APIKeyEnv to EnvVar (CodeQL fix)#162
fix(llm): rename APIKeyEnv to EnvVar (CodeQL fix)#162bussyjd merged 1 commit intointegration-okr-1from
Conversation
CodeQL flagged ProviderStatus.APIKeyEnv as sensitive data being logged. The field only stores the env var name (e.g. "ANTHROPIC_API_KEY"), not the actual key. Rename to EnvVar to avoid triggering the heuristic.
Security Audit: Clear-Text Logging of Sensitive InformationA security audit was performed to assess whether the CodeQL finding is legitimate and whether other sensitive data logging patterns exist in the codebase. CodeQL Finding (
|
| Severity | File | Line | Issue | Introduced by |
|---|---|---|---|---|
| HIGH | internal/openclaw/openclaw.go |
714 | fmt.Printf("Gateway token: %s\n", token) — prints actual gateway token to terminal |
Pre-existing |
| HIGH | internal/openclaw/openclaw.go |
711 | Dashboard URL with embedded token: http://localhost:PORT/#token=<TOKEN> printed to stdout |
Pre-existing |
| HIGH | internal/llm/llm.go |
53 | API key embedded in kubectl patch command args — visible in /proc/PID/cmdline while running |
Pre-existing |
| MODERATE | internal/openclaw/openclaw.go |
975 | Token passed as --token CLI arg to openclaw binary — visible in ps output |
Pre-existing |
| MODERATE | internal/openclaw/openclaw.go |
1315 | API key input not suppressed (echoed to terminal during interactive prompt) | Pre-existing |
| OK | internal/openclaw/openclaw.go |
1480 | collectSensitiveData() properly zeroes API keys/tokens after extraction |
PR #161 (good) |
Positive Patterns
collectSensitiveData()correctly strips literal secrets fromImportResultbefore overlay YAML generationwriteUserSecretsFile()uses0600permissions for the local secrets fileHasAPIKeyfield stores a boolean, not the key itselfEnvVarfield stores the env var name, not the value
Recommendations (separate follow-up)
- Gateway token logging (
openclaw.go:711-714): Replacefmt.Printf("Gateway token: %s\n", token)with a reference toobol openclaw token <id> - kubectl patch args (
llm.go:53): Pass patch JSON via stdin instead of-pflag to avoid/procexposure - Interactive API key input (
openclaw.go:1315): Usegolang.org/x/term.ReadPassword()to suppress echo
Verdict
This PR is clean. The rename from APIKeyEnv to EnvVar correctly resolves the CodeQL false positive. The high-severity findings are pre-existing and should be addressed in a separate PR.
Summary
ProviderStatus.APIKeyEnvtoProviderStatus.EnvVarininternal/llm/llm.goand updates the two references incmd/obol/llm.goContext
CodeQL flagged
APIKeyEnvas sensitive data flowing tofmt.Printfatcmd/obol/llm.go:78. The field only stores the env var name (e.g."ANTHROPIC_API_KEY"), not the actual secret — but theAPIKeysubstring in the field name triggers CodeQL's taint heuristic.Fix: https://github.com/ObolNetwork/obol-stack/runs/63785905429
Test plan
go build ./cmd/obolpassesgo test ./...— 28/28 pass