Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat: remove stale changes and validate the scopes at dynamic secret creation as well

adilsond0bb1125de01
diff --git a/backend/src/ee/services/dynamic-secret/providers/models.ts b/backend/src/ee/services/dynamic-secret/providers/models.ts
index 1e7e5d4cb9..0087766b36 100644
--- a/backend/src/ee/services/dynamic-secret/providers/models.ts
+++ b/backend/src/ee/services/dynamic-secret/providers/models.ts
@@ -818,6 +818,16 @@ export enum TailscaleAuthMethod {
OAuth = "oauth"
}
+// OAuth/federated credentials issued with these scopes could create or modify other credentials,
+// which would let a lease escalate its own privileges. Block them at both the schema and provider level.
+export const TAILSCALE_BLOCKED_SCOPES = new Set([
+ "auth_keys",
+ "oauth_keys",
+ "federated_keys",
+ "api_access_tokens",
+ "all"
+]);
+
const DynamicSecretTailscaleAuthSchema = z.discriminatedUnion("method", [
z.object({
method: z.literal(TailscaleAuthMethod.ApiKey),
@@ -910,6 +920,18 @@ export const DynamicSecretTailscaleSchema = z
message: "Tags are required when the key type is OAuth or Federated Identity"
});
}
+
+ // Block scopes that would let a lease escalate its own privileges (e.g. mint new auth/OAuth keys).
+ if (
+ (data.authType === TailscaleKeyAuthType.OAuthKeys || data.authType === TailscaleKeyAuthType.FederatedKeys) &&
+ data.scopes.some((scope) => TAILSCALE_BLOCKED_SCOPES.has(scope))
+ ) {
+ ctx.addIssue({
+ code: z.ZodIssueCode.custom,
+ path: ["scopes"],
+ message: "OAuth credentials cannot be used to create or modify other credentials"
+ });
+ }
});
export const DynamicSecretSshSchema = z.object({
diff --git a/backend/src/ee/services/dynamic-secret/providers/tailscale.ts b/backend/src/ee/services/dynamic-secret/providers/tailscale.ts
index 66f00ec4b8..24d64d3d4f 100644
--- a/backend/src/ee/services/dynamic-secret/providers/tailscale.ts
+++ b/backend/src/ee/services/dynamic-secret/providers/tailscale.ts
@@ -5,7 +5,13 @@ import { BadRequestError } from "@app/lib/errors";
import { sanitizeString } from "@app/lib/fn";
import { safeRequest } from "@app/lib/validator";
-import { DynamicSecretTailscaleSchema, TailscaleAuthMethod, TailscaleKeyAuthType, TDynamicProviderFns } from "./models";
+import {
+ DynamicSecretTailscaleSchema,
+ TAILSCALE_BLOCKED_SCOPES,
+ TailscaleAuthMethod,
+ TailscaleKeyAuthType,
+ TDynamicProviderFns
+} from "./models";
const TAILSCALE_API_BASE_URL = "https://api.tailscale.com/api/v2";
@@ -78,10 +84,10 @@ export const TailscaleProvider = (): TDynamicProviderFns => {
};
// oauth credentials issued can have the auth-keys or oauth scope, which allow them
- // to modify other credentials. Let's block it so this is not possible
+ // to modify other credentials. This is also blocked at the schema level (see
+ // DynamicSecretTailscaleSchema); kept here as defense-in-depth for direct provider calls.
const $validateScopes = (scopes: string[]) => {
- const blockedScopes = new Set(["auth_keys", "oauth_keys", "federated_keys", "api_access_tokens", "all"]);
- if (scopes.some((scope) => blockedScopes.has(scope))) {
+ if (scopes.some((scope) => TAILSCALE_BLOCKED_SCOPES.has(scope))) {
throw new BadRequestError({ message: "OAuth credentials cannot be used to create or modify other credentials" });
}
return scopes;
diff --git a/docs/documentation/platform/dynamic-secrets/tailscale.mdx b/docs/documentation/platform/dynamic-secrets/tailscale.mdx
index 14edd5f93c..832fa30d4d 100644
--- a/docs/documentation/platform/dynamic-secrets/tailscale.mdx
+++ b/docs/documentation/platform/dynamic-secrets/tailscale.mdx
@@ -140,7 +140,7 @@ Infisical needs a credential that is allowed to create and revoke keys in your t
</ParamField>
<Note>
- OAuth clients cannot be created with the `auth-keys` or `oauth` scopes. Those scopes can create or modify other credentials in your tailnet, so Infisical blocks them to prevent leases from changing existing Tailscale credentials.
+ OAuth clients cannot be created with the `auth_keys`, `oauth_keys`, `federated_keys`, `api_access_tokens`, and `all` scopes. Those scopes can create or modify other credentials in your tailnet, so Infisical blocks them to prevent leases from changing existing Tailscale credentials.
</Note>
</Tab>
<Tab title="Federated Identity">
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/TailscaleInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/TailscaleInputForm.tsx
index c17411f33f..54a0bb8a21 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/TailscaleInputForm.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/TailscaleInputForm.tsx
@@ -477,9 +477,9 @@ export const TailscaleInputForm = ({
isError={Boolean(error?.message)}
errorText={error?.message}
isRequired
- helperText="Comma-separated OAuth scopes (e.g. devices:core, auth_keys)."
+ helperText="Comma-separated OAuth scopes (e.g. devices:core, users:read)."
>
- <Input {...field} placeholder="devices:core, auth_keys" />
+ <Input {...field} placeholder="devices:core, users:read" />
</FormControl>
)}
/>
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretTailscaleForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretTailscaleForm.tsx
index af3c1cf97f..2012cde054 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretTailscaleForm.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretTailscaleForm.tsx
@@ -498,9 +498,9 @@ export const EditDynamicSecretTailscaleForm = ({
isError={Boolean(error?.message)}
errorText={error?.message}
isRequired
- helperText="Comma-separated OAuth scopes (e.g. devices:core, auth_keys)."
+ helperText="Comma-separated OAuth scopes (e.g. devices:core, users:read)."
>
- <Input {...field} placeholder="devices:core, auth_keys" />
+ <Input {...field} placeholder="devices:core, users:read" />
</FormControl>
)}
/>