Skip to content

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

address llm comments

adilson5f3831140927
diff --git a/backend/src/ee/services/secret-rotation-v2/litellm-api-key/litellm-api-key-rotation-constants.ts b/backend/src/ee/services/secret-rotation-v2/litellm-api-key/litellm-api-key-rotation-constants.ts
index 5df0eb728e..c10d7389a5 100644
--- a/backend/src/ee/services/secret-rotation-v2/litellm-api-key/litellm-api-key-rotation-constants.ts
+++ b/backend/src/ee/services/secret-rotation-v2/litellm-api-key/litellm-api-key-rotation-constants.ts
@@ -24,6 +24,16 @@ export const LITELLM_RESERVED_KEY_OPTIONS = [
"models"
];
+/**
+ * Additional options that must not be set on rotated keys. Unlike reserved options (Infisical-owned
+ * fields), these are blocked because they would grant permissions that could affect other keys —
+ * e.g. allowed_routes, permission, or object_permission.
+ */
+export const LITELLM_FORBIDDEN_KEY_OPTIONS = ["allowed_routes", "permission", "object_permission"];
+
+/** Max number of top-level keys allowed in the additional options JSON object. */
+export const LITELLM_ADDITIONAL_OPTIONS_MAX_KEYS = 55;
+
export const LITELLM_API_KEY_ROTATION_LIST_OPTION: TSecretRotationV2ListItem = {
name: "LiteLLM API Key",
type: SecretRotation.LiteLLMApiKey,
diff --git a/backend/src/ee/services/secret-rotation-v2/litellm-api-key/litellm-api-key-rotation-fns.ts b/backend/src/ee/services/secret-rotation-v2/litellm-api-key/litellm-api-key-rotation-fns.ts
index dcd795fedf..a5b0a09e1f 100644
--- a/backend/src/ee/services/secret-rotation-v2/litellm-api-key/litellm-api-key-rotation-fns.ts
+++ b/backend/src/ee/services/secret-rotation-v2/litellm-api-key/litellm-api-key-rotation-fns.ts
@@ -8,10 +8,9 @@ import {
TRotationFactoryRevokeCredentials,
TRotationFactoryRotateCredentials
} from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-types";
-import { request } from "@app/lib/config/request";
import { BadRequestError } from "@app/lib/errors";
import { removeTrailingSlash } from "@app/lib/fn/string";
-import { blockLocalAndPrivateIpAddresses } from "@app/lib/validator";
+import { safeRequest } from "@app/lib/validator";
import {
TLiteLLMApiKeyGenerateResponse,
@@ -60,9 +59,6 @@ export const litellmApiKeyRotationFactory: TRotationFactory<
* Creates a new virtual key via the LiteLLM key-management API.
*/
const $createApiKey = async () => {
- // Guard the user-supplied instance host against SSRF, matching the connection validator.
- await blockLocalAndPrivateIpAddresses(baseUrl);
-
try {
const userOptions: Record<string, unknown> = additionalOptions
? (JSON.parse(additionalOptions) as Record<string, unknown>)
@@ -80,7 +76,7 @@ export const litellmApiKeyRotationFactory: TRotationFactory<
send_invite_email: false
};
- const { data } = await request.post<TLiteLLMApiKeyGenerateResponse>(`${baseUrl}/key/generate`, requestBody, {
+ const { data } = await safeRequest.post<TLiteLLMApiKeyGenerateResponse>(`${baseUrl}/key/generate`, requestBody, {
headers: {
Authorization: `Bearer ${provisioningApiKey}`,
"Content-Type": "application/json"
@@ -101,10 +97,8 @@ export const litellmApiKeyRotationFactory: TRotationFactory<
* Deletes a virtual key via the LiteLLM key-management API. LiteLLM deletes by the key value.
*/
const $deleteApiKey = async (apiKey: string) => {
- await blockLocalAndPrivateIpAddresses(baseUrl);
-
try {
- await request.post(
+ await safeRequest.post(
`${baseUrl}/key/delete`,
{ keys: [apiKey] },
{
@@ -181,11 +175,9 @@ export const litellmApiKeyRotationFactory: TRotationFactory<
const checkActiveCredentials: TRotationFactoryCheckActiveCredentials<
TLiteLLMApiKeyRotationGeneratedCredentials
> = async ({ apiKey }) => {
- await blockLocalAndPrivateIpAddresses(baseUrl);
-
try {
// Verify the rotated key exists using the management key.
- await request.get(`${baseUrl}/key/info`, {
+ await safeRequest.get(`${baseUrl}/key/info`, {
params: { key: apiKey },
headers: { Authorization: `Bearer ${provisioningApiKey}` }
});
diff --git a/backend/src/ee/services/secret-rotation-v2/litellm-api-key/litellm-api-key-rotation-schemas.ts b/backend/src/ee/services/secret-rotation-v2/litellm-api-key/litellm-api-key-rotation-schemas.ts
index 55c8d04443..3e5f584b93 100644
--- a/backend/src/ee/services/secret-rotation-v2/litellm-api-key/litellm-api-key-rotation-schemas.ts
+++ b/backend/src/ee/services/secret-rotation-v2/litellm-api-key/litellm-api-key-rotation-schemas.ts
@@ -1,6 +1,10 @@
import { z } from "zod";
-import { LITELLM_RESERVED_KEY_OPTIONS } from "@app/ee/services/secret-rotation-v2/litellm-api-key/litellm-api-key-rotation-constants";
+import {
+ LITELLM_ADDITIONAL_OPTIONS_MAX_KEYS,
+ LITELLM_FORBIDDEN_KEY_OPTIONS,
+ LITELLM_RESERVED_KEY_OPTIONS
+} from "@app/ee/services/secret-rotation-v2/litellm-api-key/litellm-api-key-rotation-constants";
import { SecretRotation } from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-enums";
import {
BaseCreateSecretRotationSchema,
@@ -42,7 +46,26 @@ const AdditionalOptionsSchema = z
return;
}
- const reservedKeys = Object.keys(parsed).filter((key) => LITELLM_RESERVED_KEY_OPTIONS.includes(key));
+ const keys = Object.keys(parsed);
+
+ if (keys.length > LITELLM_ADDITIONAL_OPTIONS_MAX_KEYS) {
+ ctx.addIssue({
+ code: z.ZodIssueCode.custom,
+ message: `Additional options cannot contain more than ${LITELLM_ADDITIONAL_OPTIONS_MAX_KEYS} keys (received ${keys.length}).`
+ });
+ return;
+ }
+
+ const forbiddenKeys = keys.filter((key) => LITELLM_FORBIDDEN_KEY_OPTIONS.includes(key));
+ if (forbiddenKeys.length) {
+ ctx.addIssue({
+ code: z.ZodIssueCode.custom,
+ message: `The following options are not allowed in additional options: ${forbiddenKeys.join(", ")}. They would grant key-management permissions that could modify other keys.`
+ });
+ return;
+ }
+
+ const reservedKeys = keys.filter((key) => LITELLM_RESERVED_KEY_OPTIONS.includes(key));
if (reservedKeys.length) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
diff --git a/backend/src/services/app-connection/litellm/litellm-connection-fns.ts b/backend/src/services/app-connection/litellm/litellm-connection-fns.ts
index 64a6d9d618..4511717bb7 100644
--- a/backend/src/services/app-connection/litellm/litellm-connection-fns.ts
+++ b/backend/src/services/app-connection/litellm/litellm-connection-fns.ts
@@ -1,8 +1,7 @@
-import { request } from "@app/lib/config/request";
import { BadRequestError, UnauthorizedError } from "@app/lib/errors";
import { removeTrailingSlash } from "@app/lib/fn/string";
import { logger } from "@app/lib/logger";
-import { blockLocalAndPrivateIpAddresses } from "@app/lib/validator";
+import { safeRequest } from "@app/lib/validator";
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
import { LiteLLMConnectionMethod } from "./litellm-connection-enums";
@@ -20,11 +19,9 @@ export const validateLiteLLMConnectionCredentials = async (config: TLiteLLMConne
const { apiKey, instanceUrl } = config.credentials;
const baseUrl = removeTrailingSlash(instanceUrl);
- // Guard the user-supplied host against SSRF (blocks localhost/private IPs outside of dev mode)
- await blockLocalAndPrivateIpAddresses(baseUrl);
-
+ // safeRequest guards the user-supplied host against SSRF (blocks localhost/private IPs outside of dev mode)
try {
- await request.get(`${baseUrl}/key/info`, {
+ await safeRequest.get(`${baseUrl}/key/info`, {
headers: {
Authorization: `Bearer ${apiKey}`
},
@@ -52,10 +49,9 @@ const getLiteLLMErrorMessage = (error: unknown) => (error instanceof Error ? err
export const listLiteLLMUsers = async (connection: TLiteLLMConnection): Promise<TLiteLLMListItem[]> => {
const baseUrl = getLiteLLMBaseUrl(connection);
- await blockLocalAndPrivateIpAddresses(baseUrl);
try {
- const { data } = await request.get<{
+ const { data } = await safeRequest.get<{
users?: { user_id: string; user_email?: string | null; user_alias?: string | null }[];
}>(`${baseUrl}/user/list`, {
params: { page_size: 100 },
@@ -76,10 +72,9 @@ export const listLiteLLMTeams = async (
userId?: string
): Promise<TLiteLLMListItem[]> => {
const baseUrl = getLiteLLMBaseUrl(connection);
- await blockLocalAndPrivateIpAddresses(baseUrl);
try {
- const { data } = await request.get<{
+ const { data } = await safeRequest.get<{
teams?: { team_id: string; team_alias?: string | null }[];
}>(`${baseUrl}/v2/team/list`, {
params: { user_id: userId, page_size: 100 },
@@ -97,10 +92,9 @@ export const listLiteLLMTeams = async (
export const listLiteLLMModels = async (connection: TLiteLLMConnection): Promise<TLiteLLMListItem[]> => {
const baseUrl = getLiteLLMBaseUrl(connection);
- await blockLocalAndPrivateIpAddresses(baseUrl);
try {
- const { data } = await request.get<{ data?: { id: string }[] }>(`${baseUrl}/models`, {
+ const { data } = await safeRequest.get<{ data?: { id: string }[] }>(`${baseUrl}/models`, {
headers: { Authorization: `Bearer ${connection.credentials.apiKey}` }
});
diff --git a/frontend/public/images/integrations/LiteLLMOld.png b/frontend/public/images/integrations/LiteLLMOld.png
deleted file mode 100644
index 6f71480bd1..0000000000
Binary files a/frontend/public/images/integrations/LiteLLMOld.png and /dev/null differ
diff --git a/frontend/public/images/integrations/LiteLLMwrong.jpeg b/frontend/public/images/integrations/LiteLLMwrong.jpeg
deleted file mode 100644
index c2aec9ca3d..0000000000
Binary files a/frontend/public/images/integrations/LiteLLMwrong.jpeg and /dev/null differ
diff --git a/frontend/src/components/secret-rotations-v2/forms/schemas/litellm-api-key-rotation-schema.ts b/frontend/src/components/secret-rotations-v2/forms/schemas/litellm-api-key-rotation-schema.ts
index 7cdba04a1c..66766df90a 100644
--- a/frontend/src/components/secret-rotations-v2/forms/schemas/litellm-api-key-rotation-schema.ts
+++ b/frontend/src/components/secret-rotations-v2/forms/schemas/litellm-api-key-rotation-schema.ts
@@ -19,6 +19,10 @@ const LITELLM_RESERVED_KEY_OPTIONS = [
"models"
];
+const LITELLM_FORBIDDEN_KEY_OPTIONS = ["allowed_routes", "permission", "object_permission"];
+
+const LITELLM_ADDITIONAL_OPTIONS_MAX_KEYS = 55;
+
export const LiteLLMApiKeyRotationSchema = z
.object({
type: z.literal(SecretRotation.LiteLLMApiKey),
@@ -57,9 +61,26 @@ export const LiteLLMApiKeyRotationSchema = z
return;
}
- const reservedKeys = Object.keys(parsed).filter((key) =>
- LITELLM_RESERVED_KEY_OPTIONS.includes(key)
- );
+ const keys = Object.keys(parsed);
+
+ if (keys.length > LITELLM_ADDITIONAL_OPTIONS_MAX_KEYS) {
+ ctx.addIssue({
+ code: z.ZodIssueCode.custom,
+ message: `Additional options cannot contain more than ${LITELLM_ADDITIONAL_OPTIONS_MAX_KEYS} keys (received ${keys.length}).`
+ });
+ return;
+ }
+
+ const forbiddenKeys = keys.filter((key) => LITELLM_FORBIDDEN_KEY_OPTIONS.includes(key));
+ if (forbiddenKeys.length) {
+ ctx.addIssue({
+ code: z.ZodIssueCode.custom,
+ message: `The following options are not allowed in additional options: ${forbiddenKeys.join(", ")}. They would grant key-management permissions that could modify other keys.`
+ });
+ return;
+ }
+
+ const reservedKeys = keys.filter((key) => LITELLM_RESERVED_KEY_OPTIONS.includes(key));
if (reservedKeys.length) {
ctx.addIssue({
code: z.ZodIssueCode.custom,