Skip to content

fix(client): reject spaced secret keys in web pages - #9

Merged
MobileMage merged 2 commits into
gatepost-dev:mainfrom
lui01212:codex/reject-spaced-secret-keys
Oct 4, 2026
Merged

MobileMage merged 2 commits into
gatepost-dev:mainfrom
lui01212:codex/reject-spaced-secret-keys

Conversation

@lui01212

@lui01212 lui01212 commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Check the trimmed API key before applying the browser secret-key guard (SEC-1). Leading white
space can otherwise hide a secret-key prefix that header normalisation later exposes. Add eight
regression cases for both secret-key forms and a patch changeset.

All eight new cases fail on the old guard. pnpm check, Node 22 tests, Firefox and WebKit journeys,
secret scanning and the PR checks pass after the fix. The existing tests also cover publishable
keys and server clients. The error message never contains the key.

CI: https://github.com/lui01212/js/actions/runs/37173546409
Before the fix: https://github.com/lui01212/js/actions/runs/37173442275

Closes #7

Codex helped write the guard change, tests and changeset, and review the diff.

Signed-off-by: Lui Lui 40736418+lui01212@users.noreply.github.com

SEC-1 must hold when header normalisation strips leading white space.
Cover both secret key forms before changing the browser guard (T-1).

Signed-off-by: Lui Lui <40736418+lui01212@users.noreply.github.com>
Check the trimmed key before applying SEC-1, because header normalisation removes white space.

Signed-off-by: Lui Lui <40736418+lui01212@users.noreply.github.com>
@MobileMage
MobileMage merged commit 69d7dd4 into gatepost-dev:main Oct 4, 2026
11 checks passed
@MobileMage

Copy link
Copy Markdown
Collaborator

Merged as 69d7dd4. The test commit before the fix, with a CI run that shows the eight cases failing on the old guard, made the review easy. The field package trims the key too, so both layers now refuse a padded secret key.

One related question is still open in the issue: whether the guard should allow only the publishable prefix instead of refusing the two secret ones. That needs a change to client.md in the spec repo first. If you want to take it, open an issue there with your view and we can settle the wording before any code.

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.

Refuse a secret key that has white space before it

2 participants