Repository navigation
Prevent server token exposure in error logs and log files - #1063
Merged
Merged
Conversation
Exceptions raised by requests embed the request URL, which includes the server token in its query string. Redact the token before these errors are logged. Restrict log files to owner-only access (0600), including rotated files, and create a new log directory as 0700. Existing directories are left untouched, so rootless runs with a user-provided --log-file are not affected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Token redaction and log permissions retain exposure gaps, and exception reconstruction can break error handling.
4 open issues
What changed in this PR
This PR reduces server-token exposure by sanitizing request errors and restricting local log permissions.
Changes:
- Redacts encoded tokens from request exceptions.
- Restricts active and newly rotated logs to owner-only access.
- Creates new log directories with owner-only permissions.
| File | Description |
|---|---|
| gprofiler/log.py | Adds restrictive log-file and directory permissions. |
| gprofiler/client.py | Adds token redaction when rethrowing request exceptions. |
Review effort: Balanced
… redacting invalid JSON failures' Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
bkammerd
approved these changes
Oct 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
gprofiler/client.py): exceptions raised byrequestsembed the request URL, which includes the token in its query string (key=<token>). When such errors were logged (e.g. a failed server health check at startup, or a failed profile upload), the token ended up in the local log file, stdout, and uploaded logs. The token is now replaced with***, and the exception type is preserved (callers still catchTimeoutspecifically).gprofiler/log.py): log files are now owner-only (0600), including files left by older versions and files created on rotation. A log directory created by gProfiler is0700.Rootless / sudoless compatibility
--rootlessruns with a user-provided--log-file(e.g. in$HOMEor/tmp) are unaffected.Note
Non-root readers of
/var/log/gprofiler(e.g. log shippers running without root) will need elevated access once the directory and files are recreated with the new modes.Test plan
key=***, no raw or URL-encoded token0700; log and rotated log are0600; old0644log file becomes0600🤖 Generated with Claude Code