mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 07:26:45 +00:00
misc: security hardening for pam credential fetch
This commit is contained in:
@@ -490,6 +490,12 @@ export const pamAccountServiceFactory = ({
|
|||||||
const resource = await pamResourceDAL.findById(account.resourceId);
|
const resource = await pamResourceDAL.findById(account.resourceId);
|
||||||
if (!resource) throw new NotFoundError({ message: `Resource with ID '${account.resourceId}' not found` });
|
if (!resource) throw new NotFoundError({ message: `Resource with ID '${account.resourceId}' not found` });
|
||||||
|
|
||||||
|
if (resource.gatewayIdentityId !== actor.id) {
|
||||||
|
throw new ForbiddenRequestError({
|
||||||
|
message: "Identity does not have access to fetch the PAM session credentials"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const decryptedAccount = await decryptAccount(account, session.projectId, kmsService);
|
const decryptedAccount = await decryptAccount(account, session.projectId, kmsService);
|
||||||
|
|
||||||
const decryptedResource = await decryptResource(resource, session.projectId, kmsService);
|
const decryptedResource = await decryptResource(resource, session.projectId, kmsService);
|
||||||
|
|||||||
@@ -1,9 +1,24 @@
|
|||||||
|
import { Knex } from "knex";
|
||||||
|
|
||||||
import { TDbClient } from "@app/db";
|
import { TDbClient } from "@app/db";
|
||||||
import { TableName } from "@app/db/schemas";
|
import { TableName } from "@app/db/schemas";
|
||||||
import { ormify } from "@app/lib/knex";
|
import { ormify, selectAllTableCols } from "@app/lib/knex";
|
||||||
|
|
||||||
export type TPamResourceDALFactory = ReturnType<typeof pamResourceDALFactory>;
|
export type TPamResourceDALFactory = ReturnType<typeof pamResourceDALFactory>;
|
||||||
export const pamResourceDALFactory = (db: TDbClient) => {
|
export const pamResourceDALFactory = (db: TDbClient) => {
|
||||||
const orm = ormify(db, TableName.PamResource);
|
const orm = ormify(db, TableName.PamResource);
|
||||||
return { ...orm };
|
|
||||||
|
const findById = async (id: string, tx?: Knex) => {
|
||||||
|
const doc = await (tx || db.replicaNode())(TableName.PamResource)
|
||||||
|
.join(TableName.GatewayV2, `${TableName.PamResource}.gatewayId`, `${TableName.GatewayV2}.id`)
|
||||||
|
.select(selectAllTableCols(TableName.PamResource))
|
||||||
|
.select(db.ref("name").withSchema(TableName.GatewayV2).as("gatewayName"))
|
||||||
|
.select(db.ref("identityId").withSchema(TableName.GatewayV2).as("gatewayIdentityId"))
|
||||||
|
.where(`${TableName.PamResource}.id`, id)
|
||||||
|
.first();
|
||||||
|
|
||||||
|
return doc;
|
||||||
|
};
|
||||||
|
|
||||||
|
return { ...orm, findById };
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user