Skip to content

fix(gateway): redact DNS credential tokens by character, not byte - #1355

Merged
kvinwang merged 1 commit into
nextfrom
fix/gateway-redact-token-chars
Sep 24, 2026
Merged

kvinwang merged 1 commit into
nextfrom
fix/gateway-redact-token-chars

Conversation

@kvinwang

@kvinwang kvinwang commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

Split from #1235.

redact_token byte-sliced the token (&token[..4], &token[len - 4..]). The token comes from Admin.CreateDnsCredential / UpdateDnsCredential unvalidated, so a multi-byte character at either cut panics, and with panic = "abort" the gateway dies:

byte index 4 is not a char boundary; it is inside 'é' (bytes 3..5) of `abcé12345`

The credential is replicated before any read path formats it, so afterwards every ListDnsCredentials / GetDnsCredential aborts whichever node serves it.

Fixed by counting and slicing chars(). redacts_by_character fails against next.

redact_token byte-sliced the API token at offsets 4 and len-4. A Cloudflare
token containing any multi-byte character puts one of those indices inside a
character and panics; release builds set panic = "abort", so the process dies.

The token is not validated as ASCII anywhere on the way in: CreateDnsCredential
stores it and the write replicates to every peer before any read path formats
it. The panic therefore lands on ListDnsCredentials/GetDnsCredential, aborting
every node in the cluster rather than rejecting the bad credential.

Count and slice characters instead. Short tokens keep the full mask.
@kvinwang
kvinwang force-pushed the fix/gateway-redact-token-chars branch from f2f0a03 to 0265ec1 Compare September 24, 2026 08:16
@kvinwang
kvinwang enabled auto-merge September 24, 2026 08:27
@kvinwang
kvinwang merged commit ec1d5d4 into next Sep 24, 2026
14 checks passed
@kvinwang
kvinwang deleted the fix/gateway-redact-token-chars branch September 24, 2026 08:33
kvinwang added a commit that referenced this pull request Sep 25, 2026
…cuts

PR #1355 redacts DNS credential tokens by character. tc-gw-certificat-003
stores a token whose byte cuts fall inside characters and reads it back
through create, get and list.

Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang added a commit that referenced this pull request Nov 8, 2026
…cuts

PR #1355 redacts DNS credential tokens by character. tc-gw-certificat-003
stores a token whose byte cuts fall inside characters and reads it back
through create, get and list.

Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang added a commit that referenced this pull request Nov 8, 2026
…cuts

PR #1355 redacts DNS credential tokens by character. tc-gw-certificat-003
stores a token whose byte cuts fall inside characters and reads it back
through create, get and list.

Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang added a commit that referenced this pull request Nov 10, 2026
…cuts

PR #1355 redacts DNS credential tokens by character. tc-gw-certificat-003
stores a token whose byte cuts fall inside characters and reads it back
through create, get and list.

Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang added a commit that referenced this pull request Nov 11, 2026
…cuts

PR #1355 redacts DNS credential tokens by character. tc-gw-certificat-003
stores a token whose byte cuts fall inside characters and reads it back
through create, get and list.

Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang added a commit that referenced this pull request Nov 11, 2026
…cuts

PR #1355 redacts DNS credential tokens by character. tc-gw-certificat-003
stores a token whose byte cuts fall inside characters and reads it back
through create, get and list.

Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang added a commit that referenced this pull request Nov 16, 2026
…cuts

PR #1355 redacts DNS credential tokens by character. tc-gw-certificat-003
stores a token whose byte cuts fall inside characters and reads it back
through create, get and list.

Signed-off-by: Kevin Wang <wy721@qq.com>
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