security: avoid logging Basic auth material (ai:gpt-5) #55

Closed
opened 2026-05-23 22:21:09 +02:00 by heiko · 1 comment
Owner

Finding from a whole-codebase security review.

Affected code:

  • cmd/once-server/auth/auth.go:28-31 includes the supplied Base64 token or decoded Basic-auth payload in returned error strings for malformed headers.
  • cmd/once-server/user.go:23-25 logs those errors.

Impact:
Malformed Authorization headers can place credential-like material into application logs. For example, a decoded Basic payload without the expected delimiter is logged in full. Logs often have a wider audience and longer retention than request handling, so authentication material should not be copied there even on parse errors.

Suggested fix:

  • Return sanitized auth errors that describe the class of failure without including raw header values, decoded payloads, or passwords.
  • Log only safe context such as remote address and an optional sanitized username when one is known.
  • Add tests that malformed Basic headers do not appear in error strings.
Finding from a whole-codebase security review. Affected code: - cmd/once-server/auth/auth.go:28-31 includes the supplied Base64 token or decoded Basic-auth payload in returned error strings for malformed headers. - cmd/once-server/user.go:23-25 logs those errors. Impact: Malformed Authorization headers can place credential-like material into application logs. For example, a decoded Basic payload without the expected delimiter is logged in full. Logs often have a wider audience and longer retention than request handling, so authentication material should not be copied there even on parse errors. Suggested fix: - Return sanitized auth errors that describe the class of failure without including raw header values, decoded payloads, or passwords. - Log only safe context such as remote address and an optional sanitized username when one is known. - Add tests that malformed Basic headers do not appear in error strings.
Author
Owner

implement secret obfuscation. and add --debug-show-secrets for advanced debugging

implement secret obfuscation. and add --debug-show-secrets for advanced debugging
heiko closed this issue 2026-05-24 16:37:02 +02:00
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
IUS/once#55
No description provided.