mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
misc: added validation against confused deputy
This commit is contained in:
@@ -146,6 +146,18 @@ export const getGcpSecretManagerProjects = async (appConnection: TGcpConnection)
|
||||
};
|
||||
|
||||
export const validateGcpConnectionCredentials = async (appConnection: TGcpConnectionConfig) => {
|
||||
// Check if provided service account email prefix matches organization ID.
|
||||
// We do this to mitigate confused deputy attacks in multi-tenant instances
|
||||
const expectedEmailPrefix = appConnection.orgId.split("-").slice(0, 2).join("-");
|
||||
if (
|
||||
appConnection.credentials.serviceAccountEmail &&
|
||||
!appConnection.credentials.serviceAccountEmail.startsWith(expectedEmailPrefix)
|
||||
) {
|
||||
throw new BadRequestError({
|
||||
message: `GCP service account email must have a prefix of "${expectedEmailPrefix}"`
|
||||
});
|
||||
}
|
||||
|
||||
await getAuthToken(appConnection);
|
||||
|
||||
return appConnection.credentials;
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
import { GcpConnectionMethod } from "./gcp-connection-enums";
|
||||
|
||||
export const GcpConnectionServiceAccountImpersonationCredentialsSchema = z.object({
|
||||
serviceAccountEmail: z.string().trim().min(1, "Service account email required")
|
||||
serviceAccountEmail: z.string().email().trim().min(1, "Service account email required")
|
||||
});
|
||||
|
||||
const BaseGcpConnectionSchema = BaseAppConnectionSchema.extend({ app: z.literal(AppConnection.GCP) });
|
||||
|
||||
Reference in New Issue
Block a user