#189: make the CSRF origin check fail closed #240

Merged
stwaidele merged 2 commits from feat/189-csrf-fail-closed into main 2026-07-30 11:02:59 +02:00
Showing only changes of commit 214e707102 - Show all commits

View File

@ -108,8 +108,12 @@ describe('collab authentication', () => {
name: 'page-x',
token: async () => {
const [h, p, s = ''] = (await signCollabToken(claims, secret, 60)).split('.');
// Flip the last character of the signature.
const flipped = s.slice(0, -1) + (s.endsWith('A') ? 'B' : 'A');
// Flip the FIRST signature character — its bits are all significant.
// The last character is not: its low bits are base64url padding that
// decoders ignore, so a last-char flip of a signature ending in 'A'
// decodes to the same bytes and verifies (jose compares decoded
// bytes, unlike the pre-#188 code that compared encoded strings).
const flipped = (s.startsWith('A') ? 'B' : 'A') + s.slice(1);
return `${h}.${p}.${flipped}`;
},
},