Skip to content

Commit a63df40

Browse files
author
kjgbot
committed
fix: reject OIDC token confusion
1 parent 165e4bb commit a63df40

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

packages/server/src/lib/sponsor-binding.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ export class SponsorOidcService {
169169
|| header.alg !== "RS256"
170170
|| typeof header.kid !== "string"
171171
|| !header.kid
172+
|| (header.typ !== undefined && header.typ !== "JWT")
172173
|| header.crit !== undefined
173174
|| !claims
174175
) {
@@ -316,6 +317,7 @@ export class SponsorOidcService {
316317
!header
317318
|| header.alg !== "RS256"
318319
|| header.kid !== expectedKid
320+
|| (header.typ !== undefined && header.typ !== "JWT")
319321
|| header.crit !== undefined
320322
|| !claims
321323
) {
@@ -514,9 +516,6 @@ function normalizeAudience(value: unknown): string[] {
514516
}
515517

516518
function mapSponsorId(claim: string, prefix: string): string {
517-
if (SPONSOR_ID_PATTERN.test(claim)) {
518-
return claim;
519-
}
520519
if (!/^user_[A-Za-z0-9_-]*$/u.test(prefix)) {
521520
throw configurationError("sponsorIdPrefix must begin with user_ and contain only token-safe characters");
522521
}

0 commit comments

Comments
 (0)