A server-side secret read from the environment flows into an HTTP response body, leaking it to the client.
Why AI tools produce this: AI coding tools generate this anti-pattern by default, it appears in a large share of AI-written auth code.
Dataflow rule. This is a taint-mode rule: it traces a hardcoded secret, token or credential through your code to the HTTP response body, so indirection across multiple lines is caught, not just the direct one-line form. Routing the value through a recognised validation / allow-list sanitizer clears the taint and suppresses the finding. Why dataflow →
Why this matters
Values such as an API key, client secret, access key, or private key are meant to stay on the server; writing one to the http.ResponseWriter (via Write, fmt.Fprint(f), io.WriteString, or a JSON encoder) publishes it to every caller, including attackers probing your endpoints.
Never return a credential to the client. Send only the data the caller legitimately needs; if a secret must appear in a debug/diagnostic path, redact or mask it first. Read secrets exclusively in server-internal code and keep them out of any response payload. See CWE-200.
Suppressing this rule
If a finding is a genuine false positive, scope the suppression to the exact line and leave a reason, never disable the rule project-wide. Disable directives are line-scoped by design.
// oauthlint-disable-next-line auth.go.flow.secret-in-response -- <reason>