Skip to content

fix: redact GitHub PAT from PatBroadcastSynapse repr/str - #851

Closed
wmagev wants to merge 2 commits into
entrius:testfrom
wmagev:fix/pat-synapse-repr-leak
Closed

fix: redact GitHub PAT from PatBroadcastSynapse repr/str#851
wmagev wants to merge 2 commits into
entrius:testfrom
wmagev:fix/pat-synapse-repr-leak

Conversation

@wmagev

@wmagev wmagev commented Apr 29, 2026

Copy link
Copy Markdown

Summary

PatBroadcastSynapse.github_access_token was a vanilla pydantic field with no repr=False and no __repr__ override, so repr(synapse) and str(synapse) emitted the full GitHub PAT in plaintext. Any bt.logging.debug(synapse) call, uncaught-exception traceback that included the synapse, or log-shipper that captured stdout would leak every miner's PAT to disk and downstream log infrastructure.

This PR:

  • Marks github_access_token with Field(repr=False) so pydantic's default repr excludes it.
  • Overrides __repr__ / __str__ to render ***<last 4 chars> (last-4 kept so operators can correlate masked log lines with rotated tokens).
  • Leaves model_dump_json() and wire serialization unchanged — the token still transmits over the (HTTPS) axon channel.

Fix #850

Before:

>>> repr(PatBroadcastSynapse(github_access_token='ghp_SUPERSECRET12345'))
"PatBroadcastSynapse(github_access_token='ghp_SUPERSECRET12345', accepted=None, rejection_reason=None)"

`PatBroadcastSynapse.github_access_token` had no `repr=False` and no
`__repr__` override, so `repr(synapse)` and `str(synapse)` emitted the
full PAT in plaintext. Any `bt.logging.debug(synapse)` or uncaught
exception traceback that included the synapse leaked every miner's
PAT to logs.

Mark the field with `Field(repr=False)` and override `__repr__`/`__str__`
to render `***<last 4 chars>` instead. Wire format (`model_dump_json`)
is unchanged so the token still transmits to validators over the axon
channel.
@xiao-xiao-mao xiao-xiao-mao Bot added the bug Something isn't working label Apr 29, 2026
@anderdc anderdc added enhancement New feature or request and removed bug Something isn't working labels May 4, 2026
@anderdc

anderdc commented May 4, 2026

Copy link
Copy Markdown
Collaborator

fix ci

@wmagev wmagev closed this May 4, 2026
@plind-junior

Copy link
Copy Markdown
Contributor

Any specific reason of closing it?

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] PatBroadcastSynapse leaks miner GitHub PAT through repr()/str()

3 participants