Skip to content

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

gate CA fetch behind perm check

x0322050d7fc419bf34
diff --git a/backend/src/ee/routes/v1/pam-routers/pam-account-router.ts b/backend/src/ee/routes/v1/pam-routers/pam-account-router.ts
index 485b3c7466..63c90467d7 100644
--- a/backend/src/ee/routes/v1/pam-routers/pam-account-router.ts
+++ b/backend/src/ee/routes/v1/pam-routers/pam-account-router.ts
@@ -416,7 +416,14 @@ export const registerPamAccountRouter = async (server: FastifyZodProvider) => {
config: { rateLimit: readLimit },
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => {
- return server.services.pamAccount.getSshCaPublicKey(req.params.accountId);
+ return server.services.pamAccount.getSshCaPublicKey({
+ accountId: req.params.accountId,
+ projectId: req.internalPamProjectId,
+ actorId: req.permission.id,
+ actor: req.permission.type,
+ actorOrgId: req.permission.orgId,
+ actorAuthMethod: req.permission.authMethod
+ });
}
});
@@ -435,7 +442,14 @@ export const registerPamAccountRouter = async (server: FastifyZodProvider) => {
config: { rateLimit: readLimit },
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req, reply) => {
- const { publicKey: caPublicKey } = await server.services.pamAccount.getSshCaPublicKey(req.params.accountId);
+ const { publicKey: caPublicKey } = await server.services.pamAccount.getSshCaPublicKey({
+ accountId: req.params.accountId,
+ projectId: req.internalPamProjectId,
+ actorId: req.permission.id,
+ actor: req.permission.type,
+ actorOrgId: req.permission.orgId,
+ actorAuthMethod: req.permission.authMethod
+ });
const setupScript = `#!/bin/bash
set -e
diff --git a/backend/src/ee/services/pam-account/pam-account-service.ts b/backend/src/ee/services/pam-account/pam-account-service.ts
index 4c980cbf71..0796fac3a6 100644
--- a/backend/src/ee/services/pam-account/pam-account-service.ts
+++ b/backend/src/ee/services/pam-account/pam-account-service.ts
@@ -446,15 +446,17 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>
return { publicKey, created: true, keyAlgorithm };
};
- const getSshCaPublicKey = async (accountId: string) => {
+ const getSshCaPublicKey = async ({ accountId, projectId, ...ctx }: TGetPamAccountDTO & TActorContext) => {
const account = await pamAccountDAL.findByIdWithDetails(accountId);
- if (!account) {
+ if (!account || account.projectId !== projectId) {
throw new NotFoundError({ message: `Account with ID '${accountId}' not found` });
}
+ await checkAccount(accountId, account.folderId, projectId, ResourcePermissionPamResourceActions.EditAccounts, ctx);
+
const metadata = parseInternalMetadata(
account.accountType as PamAccountType,
- await decryptInternalMetadata(account.projectId!, account.encryptedInternalMetadata)
+ await decryptInternalMetadata(projectId, account.encryptedInternalMetadata)
);
if (!metadata?.caPublicKey) {
diff --git a/backend/src/ee/services/pam-session-recording/pam-recording-chunk-service.ts b/backend/src/ee/services/pam-session-recording/pam-recording-chunk-service.ts
index 94d2796186..98f2683ca5 100644
--- a/backend/src/ee/services/pam-session-recording/pam-recording-chunk-service.ts
+++ b/backend/src/ee/services/pam-session-recording/pam-recording-chunk-service.ts
@@ -82,7 +82,7 @@ export const pamSessionChunkServiceFactory = ({
if (!config || config.backend === PamRecordingStorageBackend.Postgres) {
throw new BadRequestError({
message:
- "Project is not configured for object-storage recordings. Gateway should POST ciphertext to /chunks instead."
+ "Account is not configured for object-storage recordings. Gateway should POST ciphertext to /chunks instead."
});
}