Repository navigation
fix(api): mask access token in Payload.toString() - #386
buongarzoni wants to merge 3 commits into
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
AI Agent Review (anthropic, CLI default model; requested openai/openai-astra)Scrutiny: standard (public API) With DEBUG logging turned on, the SDK writes each error report to the application log just before sending it to Rollbar. That log line included the project access token in plain text. Anyone who could read the logs could copy the token, and so could any log shipper or archive the logs went to. After this change the log line shows only The token sent to Rollbar does not change. Reports still reach the API with the full token. Only the log text is masked.
The only visible difference besides the masking is that a missing token now prints as Conclusion: I found no blocking problem. Things I checked:
Limits. I read the tests but did not run them. I also could not confirm the author's statement that the lint check (checkstyle) passes. The new lines look like they fit within the 100-character limit. |
AI Agent Review (anthropic, CLI default model; requested openai/openai-astra)Scrutiny: standard (public API) When debug logging is enabled, the SDK logs every event it is about to send. Previously, that log line included the full project access token, so anyone with access to the logs (or any system they were shipped to) could read it off. Since debug logging is often turned on during incident investigation, this was especially risky at exactly the wrong time. The fix truncates the token in the debug log line to the first six characters followed by |
| } | ||
|
|
||
| /** | ||
| * Masks the token so it never ends up in logs. Keeps the first characters of long enough tokens, |
There was a problem hiding this comment.
Minor documentation issue — When Logstash records DEBUG arguments, the full token can still appear in arg0.accessToken beside the masked message.
Evidence and suggested wording
RollbarBase passes the Payload object to the logger. With includeNonStructuredArguments enabled, the Logstash encoder serializes that object separately. Its public getAccessToken() returns the full token. The option is off by default. I verified this path in source and did not run the encoder. SDK log call · Logstash argument encoder
That behavior predates this PR. The new comment says the token “never ends up in logs.” A narrower description would be “Masks the access token in the string returned by Payload.toString().”
AI Agent Review (anthropic, anthropic-balanced; requested openai/openai-astra)Scrutiny: standard (public API) This PR fixes a security issue in the Java SDK where enabling DEBUG logging could leak the full Rollbar access token in plain text. Separately, the DEBUG log call was changed to explicitly log I found no blocking issues. The included tests cover a normal-length token, a short (12-char) fully-masked token, and a null token, matching the scenarios described. I read these tests but did not run them. A note in the PR explains that a test for the actual log line wasn't added because it requires a logging backend in the test classpath — a reasonable, declared limitation since the core masking logic is already covered. |
Description of the change
Payload.toString()printed the access token in plain text, andRollbarBaselogs the payload atDEBUG on every event (
LOGGER.debug("Payload built: {}", payload)). Turning on DEBUG logging, whichpeople often do while debugging an incident, wrote the token to log files and any log shipper.
toString()now masks the token and keeps only its first 6 characters, as other Rollbar SDKs do, soyou can still tell which token is configured:
Tokens of 12 characters or fewer are fully masked (
'****'). Anulltoken still printsnull.Serialization (
asJson()) is unchanged, so the token is still sent to the API.RollbarBasenow logspayload.toString()instead of thePayloadobject, guarded byisDebugEnabled(). Structured encoders such as Logstash's (withincludeNonStructuredArguments) serialize log arguments through their getters, so passing the object would still expose the full token throughgetAccessToken().Type of change
Checklists
Development
checkstyleMain)RollbarBaselog call, which would need a logging backend in the test classpath)PayloadTest)