Skip to content

test: flip a byte of the decoded sealed cookie in the tamper test - #387

Merged
Upd4ting merged 1 commit into
mainfrom
test/wffd6e624-31-tamper-a-byte
Nov 20, 2026
Merged

Upd4ting merged 1 commit into
mainfrom
test/wffd6e624-31-tamper-a-byte

Conversation

@Upd4ting

Copy link
Copy Markdown
Member

Wffd6e624-31: follow-up of Wffd6e624-13 (#385).

Summary

tests/server-modules-sealed.test.ts tampered a sealed cookie by replacing its last two base64url characters with xx. When those characters already decoded to the same bytes (about once in 256 runs, the IV being random) the cookie stayed valid, opened, and the test failed (CI run 44666382646). The test now decodes the value and flips every bit of its last byte, so the cookie always differs.

Proof

Before: the xx replacement leaves the decoded bytes unchanged on about 1 run in 256, so the test fails on those runs.

After: 600 consecutive runs of node --import tsx --test tests/server-modules-sealed.test.ts (twice: once in one loop of 600, once as 2 x 300):

runs=600 failures=0
runs=300 failures=0
runs=300 failures=0
flowchart LR
  A[sealed cookie] --> B[base64url decode]
  B --> C[flip last byte with XOR 0xff]
  C --> D[base64url encode]
  D --> E[inspect route: seal fails to open]
  E --> F[guard never called, seen is empty]
Loading

Follow-ups

  • none

@Upd4ting
Upd4ting marked this pull request as ready for review November 20, 2026 13:00
@Upd4ting
Upd4ting enabled auto-merge November 20, 2026 13:00
@Upd4ting
Upd4ting added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit 45d376c Nov 20, 2026
12 of 21 checks passed
@Upd4ting
Upd4ting deleted the test/wffd6e624-31-tamper-a-byte branch November 20, 2026 13:15
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