Language: TypeScript
Label: vulnerable
CWE: CWE-1220 \u2014 Insufficient Granularity of Access Control
The product implements access controls via a policy or other feature with the intention to disable or restrict accesses (reads and/or writes) to assets in a system from untrusted agents. However, implemented access controls lack required granularity, which renders the control policy too broad because it allows accesses from unauthorized agents to the security-sensitive assets.

Code:
export const canCreateToken = (userScopes: string[], tokenScopes: string[]) => {
  return tokenScopes.every((scope) => userScopes.includes(scope))
}