Bug: Clear-text logging of sensitive HTTP headers on authentication failure
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 504
- Forks
- 263
- Avg merge
- 4d 2h
- Merged PRs (30d)
- 5
Description
Location:
- Path:
plugin/input/http/http.go - Function:
ServeHTTP - Line:
zap.Any("headers", r.Header)insideif !ok { ... }block (~line 420)
Description
On authentication failure, the entire r.Header map is logged in plaintext:
p.logger.Warn("auth failed",
zap.String("user_agent", r.UserAgent()),
zap.Any("headers", r.Header), // logs all headers as-is
zap.String("remote_addr", r.RemoteAddr),
)
r.Header contains the Authorization header (or the custom Auth.Header) with live credentials: Basic <base64>, Bearer <token>, or API keys. These are serialized to JSON by zap.Any and written to logs without masking.
Risk
-
Failed auth requests contain the exact credentials just sent by the client; they are persisted in plaintext in logs accessible to operators, SOC, and external log aggregators.
-
Token/JWT leakage — even expired or malformed JWTs expose PII in the payload and may be replayable; Bearer tokens and API keys are usable as-is.
-
Compliance — violates PCI-DSS, GDPR Article 32, and SOC2 controls for credential storage/protection.
Recommendations:
-
Remove
zap.Any("headers", r.Header)from the auth-failure log. -
Log only safe metadata:
p.logger.Warn("auth failed",
zap.String("user_agent", r.UserAgent()),
zap.String("remote_addr", r.RemoteAddr),
zap.String("method", r.Method),
zap.String("uri", r.RequestURI),
zap.Bool("has_auth", r.Header.Get(p.config.Auth.Header) != ""),
)
- If correlation is needed, log a truncated SHA-256 hash of the auth header instead of the raw value.
References:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open plugin/input/http/http.go and inspect ServeHTTP's authentication-failure block around the zap.Any("headers", r.Header) call. Replace the raw header logging with the safe metadata described in the issue, or an appropriately truncated auth-header hash if correlation is required. Done means failed-auth logs no longer contain credentials or other sensitive headers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- security
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 75/100