secret.Read panics on malformed input (missing colon or unknown proto) #26

Open
opened 2026-05-17 23:13:00 +02:00 by heiko · 1 comment
Owner

Summary

cmd/cert-proxy-client/secret/secret.go:16-19,34 has two panic paths instead of returning errors.

Panic 1 — missing colon in src:

var proto, value = func() (string, string) {
    x := strings.SplitN(src, ":", 2)
    return x[0], x[1]   // panics if src has no ":"
}()

If a user passes --passout plaintext (no colon), the client crashes with an index out of range panic instead of a helpful error message.

Panic 2 — unknown proto:

default:
    panic("unhandled secret source proto: " + proto)

Fix

Both paths should return fmt.Errorf(...) instead of panicking.

## Summary `cmd/cert-proxy-client/secret/secret.go:16-19,34` has two panic paths instead of returning errors. **Panic 1** — missing colon in src: ```go var proto, value = func() (string, string) { x := strings.SplitN(src, ":", 2) return x[0], x[1] // panics if src has no ":" }() ``` If a user passes `--passout plaintext` (no colon), the client crashes with an index out of range panic instead of a helpful error message. **Panic 2** — unknown proto: ```go default: panic("unhandled secret source proto: " + proto) ``` ## Fix Both paths should return `fmt.Errorf(...)` instead of panicking.
Author
Owner

AI attribution comment added per repository instruction for this open issue.\n\n(co)authored by ai:gpt-5-codex

AI attribution comment added per repository instruction for this open issue.\n\n(co)authored by ai:gpt-5-codex
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
heiko/cert-proxy#26
No description provided.