Skip to content

Fix installation-token redaction regex for new stateless token format - #4721

Open
aravindgee wants to merge 3 commits into
masterfrom
fix/token-redaction-regex-stateless-format
Open

Fix installation-token redaction regex for new stateless token format#4721
aravindgee wants to merge 3 commits into
masterfrom
fix/token-redaction-regex-stateless-format

Conversation

@aravindgee

@aravindgee aravindgee commented Aug 11, 2026

Copy link
Copy Markdown

Widens the installation-token redaction regex (only hit when .token extraction fails) to fully cover GitHub's new stateless token format — see the announcement.

- sed -E 's/(ghs_|ghu_)[A-Za-z0-9]+/\1REDACTED/g'
+ sed -E 's/(ghs_|ghu_)[A-Za-z0-9._-]+/\1REDACTED/g'

New tokens are ghs_<id>_<base64url JWT> and contain ./-, which the old [A-Za-z0-9]+ class didn't match — redaction stopped at the first one, leaking the rest of a real token into logs. No minimum length: GitHub's post recommends {36,}, but that reintroduces a hardcoded-length assumption (a 35-char tail goes fully unredacted) — the exact thing the post warns against — so this drops it. Same fix applied to nitro, nitro-private, and infrastructure (identical line in all three buildspecs).

Tracked in SREP-3581.

GitHub's new stateless installation token format (ghs_<id>_<base64url JWT>)
contains '.' and '-', which the existing [A-Za-z0-9]+ character class in the
error-log redaction regex does not match. Redaction would stop at the first
'.' or '-', leaking the remainder of a real token into CI logs if one ever
appeared in the error response body. Widen the character class to include
the full base64url + JWT-separator alphabet.
{36,} reintroduces the exact hardcoded-length assumption we're fixing:
a token at 35 chars after the prefix goes completely unredacted.
[A-Za-z0-9._-]+ has no such cliff edge.
@aravindgee
aravindgee marked this pull request as ready for review August 11, 2026 21:09
@aravindgee aravindgee changed the title [WIP] Fix installation-token redaction regex for new stateless token format Fix installation-token redaction regex for new stateless token format Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant