#189: make the CSRF origin check fail closed #240
@ -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}`;
|
||||
},
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user