Fix share token confusion vulnerability
Cache tokens from /api/send and share tokens were both signed with the same secret and parsed without distinguishing claim types, allowing a public cache token to be replayed as x-umami-share-token to read any website's analytics. Add explicit token type claims (share/cache) and require the matching type when parsing each.
This commit is contained in:
1 parent
c4b1452c29
commit
8bc49a29e3
4 files changed
+27
-7
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { getBoardEntityIds } from '@/lib/boards';
|
||||
import { ENTITY_TYPE, ROLES } from '@/lib/constants';
|
||||
import { ENTITY_TYPE, ROLES, SHARE_TOKEN_TYPE } from '@/lib/constants';
|
||||
import { secret } from '@/lib/crypto';
|
||||
import { createToken } from '@/lib/jwt';
|
||||
import prisma from '@/lib/prisma';
|
||||
@@ -91,7 +91,7 @@ export async function GET(_request: Request, { params }: { params: Promise<{ slu
|
||||
return notFound();
|
||||
}
|
||||
|
||||
data.token = createToken(data, secret());
|
||||
data.token = createToken({ ...data, type: SHARE_TOKEN_TYPE }, secret());
|
||||
|
||||
const accountId = await getAccountId(entity);
|
||||
|
||||
|
||||
Reference in new issue
Block a user