Skip to content

fix(api): mask access token in Payload.toString() - #386

Open
buongarzoni wants to merge 1 commit into
masterfrom
fix/stop-logging-access-token
Open

buongarzoni wants to merge 1 commit into
masterfrom
fix/stop-logging-access-token

Conversation

@buongarzoni

Copy link
Copy Markdown
Collaborator

Description of the change

Payload.toString() printed the access token in plain text, and RollbarBase logs the payload at
DEBUG on every event (LOGGER.debug("Payload built: {}", payload)). Turning on DEBUG logging, which
people 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 last 4 characters, so you can still tell which
token is configured:

Before: Payload{accessToken='fake0000000000000000000000secret', data=...}
After:  Payload{accessToken='****cret', data=...}

Tokens of 8 characters or fewer are fully masked ('****'). A null token still prints null.
Serialization (asJson()) is unchanged, so the token is still sent to the API.

After changes
Captura de pantalla 2026-11-13 a la(s) 3 15 13 a  m

Type of change

  • Bug fix (non-breaking change that fixes an issue)

Checklists

Development

  • Lint rules pass locally (checkstyleMain)
  • The code changed/added as part of this pull request has been covered with tests
  • All tests related to the changed code pass in development (PayloadTest)

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T06:17:05.482413Z e96202b PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@devtools-agent

Copy link
Copy Markdown

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 **** followed by the token's last four characters. That is enough to tell which token is configured. Tokens of eight characters or fewer show as **** only, and a missing token shows as null.

The token sent to Rollbar does not change. Reports still reach the API with the full token. Only the log text is masked.

Token configured Log line before Log line after
Normal-length token full token **** + last 4 characters
8 characters or fewer full token ****
No token 'null' null

The only visible difference besides the masking is that a missing token now prints as null without quotes. Nothing in the repository depends on that text.

Conclusion: I found no blocking problem. Things I checked:

  • Where the token was logged. Within the SDK, the only place the full token reached a log was this one DEBUG line. It runs once per reported error (rollbar-java/src/main/java/com/rollbar/notifier/RollbarBase.java:349-353). The senders put the token only into the HTTP request header and do not log it (SyncSender.java:69-70, reactive-streams AsyncSender.java:46-47). Other logging that mentions payloads prints only attempt counts or exceptions. The configuration objects have no text form that could print the token.
  • What is sent to Rollbar. The data sent to Rollbar still contains the full token (Payload.java:117-119). The included test shouldReturnAsJson still expects the full token there.
  • Edge cases. An empty token is fully masked. A missing token cannot cause an error, because it is handled before the token's length is read. The new constants are static, so the saved form of reports waiting in the on-disk queue does not change.
  • Tests. The new tests cover the long-token, short-token and missing-token cases, and the expected strings match the code.

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.

@rollbar-rivet
rollbar-rivet Bot requested a review from matux November 16, 2026 20:01
@linear-code

linear-code Bot commented Nov 16, 2026

Copy link
Copy Markdown

CR-1168

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants