Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
fix(agent-vault): raise OAuth scope limit to 200 (#9086)
BlackMagiq3296f853daff
diff --git a/backend/src/ee/services/agent-vault-oauth/agent-vault-oauth-discovery-fns.ts b/backend/src/ee/services/agent-vault-oauth/agent-vault-oauth-discovery-fns.tsindex c15e11572f..978be41232 100644--- a/backend/src/ee/services/agent-vault-oauth/agent-vault-oauth-discovery-fns.ts+++ b/backend/src/ee/services/agent-vault-oauth/agent-vault-oauth-discovery-fns.ts@@ -8,9 +8,9 @@ import { TOauthHttpClient, TOauthHttpResponse } from "./agent-vault-oauth-http-fimport { AgentVaultOauthCompatibility } from "./agent-vault-oauth-types";export const OFFLINE_ACCESS_SCOPE = "offline_access";-// The spec sets no limit. Slack, the largest real server found, lists 30; this only stops a buggy or hostile+// The spec sets no limit. PostHog, the largest real server found, lists 153; this only stops a buggy or hostile// server from making every authorization store and send an enormous scope list.-export const MAX_OAUTH_SCOPES = 100;+export const MAX_OAUTH_SCOPES = 200;// Each request has its own 10 second timeout, so without an overall budget a server that hangs could hold the// request past a 60 second gateway.const DISCOVERY_BUDGET_MS = 25_000;diff --git a/backend/src/ee/services/agent-vault-oauth/agent-vault-oauth-service.test.ts b/backend/src/ee/services/agent-vault-oauth/agent-vault-oauth-service.test.tsindex 1aa644f112..8b40836674 100644--- a/backend/src/ee/services/agent-vault-oauth/agent-vault-oauth-service.test.ts+++ b/backend/src/ee/services/agent-vault-oauth/agent-vault-oauth-service.test.ts@@ -1437,11 +1437,13 @@ describe("refreshing a service's token", () => {rejectedTokenHash: hashAccessToken("old-access"),requiredScopes: Array.from({ length: 50 }, (_, index) => `${prefix}:${index}`)});- await report("a");- await report("b");- await report("c");+ const reports = MAX_OAUTH_SCOPES / 50 + 1;+ for (let i = 0; i < reports; i += 1) {+ // eslint-disable-next-line no-await-in-loop+ await report(`r${i}`);+ }expect(config().requiredScopes).toHaveLength(MAX_OAUTH_SCOPES);- expect(config().requiredScopes).not.toContain("c:0");+ expect(config().requiredScopes).not.toContain(`r${reports - 1}:0`);});test("a scope report for a service that moved is a 409 and changes nothing", async () => {diff --git a/backend/src/ee/services/agent-vault-oauth/agent-vault-oauth-token-fns.ts b/backend/src/ee/services/agent-vault-oauth/agent-vault-oauth-token-fns.tsindex 7f59ca8d93..d36dd7cfc6 100644--- a/backend/src/ee/services/agent-vault-oauth/agent-vault-oauth-token-fns.ts+++ b/backend/src/ee/services/agent-vault-oauth/agent-vault-oauth-token-fns.ts@@ -168,7 +168,7 @@ export const parseGrantedScopes = (return { scopes: splitScopes(scope), commaSeparated: false };};-// A reauthorize asks for at most the 100 discovered scopes plus 100 an agent reported, so no real server grants more.+// A reauthorize asks for at most the 200 discovered scopes plus 200 an agent reported, so no real server grants more.// Granted scopes go into the pending authorization in Redis and are asked for again on every reauthorize.export const MAX_GRANTED_OAUTH_SCOPES = 2 * MAX_OAUTH_SCOPES;