Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
Address greptile comments
Carlos Monastyrskib1773cd3a62b
diff --git a/backend/src/ee/services/audit-log/audit-log-types.ts b/backend/src/ee/services/audit-log/audit-log-types.tsindex 0d3c25c33a..d5b453f046 100644--- a/backend/src/ee/services/audit-log/audit-log-types.ts+++ b/backend/src/ee/services/audit-log/audit-log-types.ts@@ -4715,6 +4715,7 @@ interface GetPkiSigningOperationsEvent {type: EventType.GET_PKI_SIGNING_OPERATIONS;metadata: {signerId: string;+ signerName: string;count: number;};}@@ -4723,6 +4724,7 @@ interface GetPkiSigningOperationEvent {type: EventType.GET_PKI_SIGNING_OPERATION;metadata: {signerId: string;+ signerName: string;operationId: string;};}diff --git a/backend/src/server/routes/v1/signer-routers/operations-router.ts b/backend/src/server/routes/v1/signer-routers/operations-router.tsindex 801450ba98..1f851d4275 100644--- a/backend/src/server/routes/v1/signer-routers/operations-router.ts+++ b/backend/src/server/routes/v1/signer-routers/operations-router.ts@@ -56,6 +56,7 @@ export const registerSignerOperationsRouter = async (server: FastifyZodProvider)type: EventType.GET_PKI_SIGNING_OPERATIONS,metadata: {signerId: req.params.signerId,+ signerName: result.signerName,count: result.operations.length}}@@ -103,6 +104,7 @@ export const registerSignerOperationsRouter = async (server: FastifyZodProvider)type: EventType.GET_PKI_SIGNING_OPERATION,metadata: {signerId: req.params.signerId,+ signerName: result.signerName,operationId: req.params.operationId}}diff --git a/backend/src/server/routes/v1/signer-routers/requests-router.ts b/backend/src/server/routes/v1/signer-routers/requests-router.tsindex f093086319..4b247aabcf 100644--- a/backend/src/server/routes/v1/signer-routers/requests-router.ts+++ b/backend/src/server/routes/v1/signer-routers/requests-router.ts@@ -6,7 +6,7 @@ import { readLimit, writeLimit } from "@app/server/config/rateLimiter";import { verifyAuth } from "@app/server/plugins/auth/verify-auth";import {CODE_SIGNING_SCOPE_API_DESCRIPTION,- CodeSigningScopeSchema+ CodeSigningScopeInputSchema} from "@app/services/approval-policy/code-signing/code-signing-policy-schemas";import { AuthMode } from "@app/services/auth/auth-type";@@ -71,9 +71,7 @@ export const registerSignerRequestsRouter = async (server: FastifyZodProvider) =requestedSignings: z.number().int().min(1).optional(),requestedWindowStart: z.string().datetime().optional(),requestedWindowEnd: z.string().datetime().optional(),- // Strict: an unrecognized key here would otherwise be dropped, turning a scoped- // request into an unscoped one that authorizes every signing context.- scope: CodeSigningScopeSchema.strict().optional().describe(CODE_SIGNING_SCOPE_API_DESCRIPTION)+ scope: CodeSigningScopeInputSchema.optional().describe(CODE_SIGNING_SCOPE_API_DESCRIPTION)})},onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),@@ -117,7 +115,7 @@ export const registerSignerRequestsRouter = async (server: FastifyZodProvider) =requestedSignings: z.number().int().min(1).optional(),requestedWindowStart: z.string().datetime().optional(),requestedWindowEnd: z.string().datetime().optional(),- scope: CodeSigningScopeSchema.strict().optional().describe(CODE_SIGNING_SCOPE_API_DESCRIPTION)+ scope: CodeSigningScopeInputSchema.optional().describe(CODE_SIGNING_SCOPE_API_DESCRIPTION)})},onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),diff --git a/backend/src/services/approval-policy/code-signing/code-signing-policy-fns.ts b/backend/src/services/approval-policy/code-signing/code-signing-policy-fns.tsindex cccc4446a7..1178552906 100644--- a/backend/src/services/approval-policy/code-signing/code-signing-policy-fns.ts+++ b/backend/src/services/approval-policy/code-signing/code-signing-policy-fns.ts@@ -102,8 +102,8 @@ type TRequestedSigningWindow = { start?: string; end?: string };** A signing client re-derives its window from a configured duration on every call, so a retry asks* for identical terms at a later absolute window. Comparing instants would never match and every- * retry would open a duplicate request. A person picks absolute times, where 10:00-11:00 and- * 11:00-12:00 are two different asks that merely share a duration.+ * retry would open a duplicate request. A person picks absolute times, so both ends of the window+ * are compared: 10:00-18:00 and 12:00-18:00 are different asks even though they end together.*/export const isSameRequestedSigningWindow = (isHumanRequester: boolean,@@ -111,7 +111,7 @@ export const isSameRequestedSigningWindow = (incoming: TRequestedSigningWindow): boolean => {const sameEnd = (pending.end ?? null) === (incoming.end ?? null);- if (isHumanRequester) return sameEnd;+ if (isHumanRequester) return sameEnd && (pending.start ?? null) === (incoming.start ?? null);if (!pending.start || !pending.end || !incoming.start || !incoming.end) return sameEnd;diff --git a/backend/src/services/approval-policy/code-signing/code-signing-policy-schemas.ts b/backend/src/services/approval-policy/code-signing/code-signing-policy-schemas.tsindex 331c11a91e..e7c2226aa9 100644--- a/backend/src/services/approval-policy/code-signing/code-signing-policy-schemas.ts+++ b/backend/src/services/approval-policy/code-signing/code-signing-policy-schemas.ts@@ -69,6 +69,8 @@ export const CodeSigningScopeSchema = z.object({[CodeSigningScopeField.DataHash]: scopeSha256("Data digest must be a 64-character SHA-256 hex string")});+export const CodeSigningScopeInputSchema = CodeSigningScopeSchema.strict();+export const CODE_SIGNING_SCOPE_API_DESCRIPTION ="Optional parameters to scope this approval to (command, signingApplication, signingApplicationHash, hostname, osUsername, ipAddress, dataHash). Every value declared here must match at signing time or the sign call is denied; parameters left out are not restricted. A command must match exactly, apart from whitespace, so a different order of options is a different command. ipAddress is compared against the address the sign call arrives from and dataHash against the digest of the submitted payload, so those two hold even if a caller reports something else.";@@ -121,7 +123,9 @@ export const CodeSigningRequestSchema = BaseApprovalRequestSchema.extend({});export const CreateCodeSigningRequestSchema = BaseCreateApprovalRequestSchema.extend({- requestData: CodeSigningPolicyRequestDataSchema+ requestData: CodeSigningPolicyRequestDataSchema.extend({+ scope: CodeSigningScopeInputSchema.optional()+ })});export const CodeSigningRequestGrantSchema = BaseApprovalRequestGrantSchema.extend({diff --git a/backend/src/services/signer/signer-service.ts b/backend/src/services/signer/signer-service.tsindex 389edede0a..0bd99d96d4 100644--- a/backend/src/services/signer/signer-service.ts+++ b/backend/src/services/signer/signer-service.ts@@ -1908,7 +1908,7 @@ export const signerServiceFactory = ({const totalCount = await signingOperationDAL.countBySignerId(dto.signerId, dto.status);- return { operations, totalCount, projectId: signer.projectId };+ return { operations, totalCount, signerName: signer.name, projectId: signer.projectId };};const getOperationById = async (dto: TGetSigningOperationDTO) => {diff --git a/docs/documentation/platform/pki/code-signing/approvals.mdx b/docs/documentation/platform/pki/code-signing/approvals.mdxindex 91f3ed21ae..70ff66fa81 100644--- a/docs/documentation/platform/pki/code-signing/approvals.mdx+++ b/docs/documentation/platform/pki/code-signing/approvals.mdx@@ -139,32 +139,35 @@ A pipeline can ask for approval of one specific artifact before it signs. BuildThe digest to declare is the SHA-256 of **the bytes your sign call submits**, because that is what Infisical hashes to check the scope. The recipe below therefore applies when the pipeline posts the file itself to the Sign API:```bash-# 1. Hash the artifact you intend to sign+# 1. Digest the artifact. This is what a signing tool submits, and what you will sign.DIGEST=$(sha256sum installer-v2.4.0.msi | cut -d' ' -f1)-# 2. Ask for one signature over exactly that artifact+# 2. Scope the request to it. Infisical hashes whatever the sign call submits, so the value+# to declare is the hash of those digest bytes rather than the hash of the file.+SCOPE_HASH=$(echo -n "$DIGEST" | xxd -r -p | sha256sum | cut -d' ' -f1)+curl -s -X POST "$INFISICAL_URL/api/v1/cert-manager/signers/$SIGNER_ID/requests" \-H "Authorization: Bearer $TOKEN" \-H "Content-Type: application/json" \-d "{\"justification\": \"Release v2.4.0 Windows installer\",\"requestedSignings\": 1,- \"scope\": { \"dataHash\": \"$DIGEST\" }+ \"scope\": { \"dataHash\": \"$SCOPE_HASH\" }}"-# 3. Sign the file itself, so the digest Infisical computes is the one you declared+# 3. Once it is approved, sign the digestcurl -s -X POST "$INFISICAL_URL/api/v1/cert-manager/signers/$SIGNER_ID/sign" \-H "Authorization: Bearer $TOKEN" \-H "Content-Type: application/json" \-d "{- \"data\": \"$(base64 -w0 installer-v2.4.0.msi)\",+ \"data\": \"$(echo -n "$DIGEST" | xxd -r -p | base64 -w0)\",\"signingAlgorithm\": \"RSASSA_PKCS1_V1_5_SHA_256\",- \"isDigest\": false+ \"isDigest\": true}"```<Warning>- **Do not use `sha256sum yourfile` when your tool pre-hashes.** Tools like `signtool` and `jarsigner` submit a digest rather than the file, so Infisical hashes that digest and the scope value becomes a digest of a digest. Declaring `sha256sum yourfile` in that case never matches and every sign call is denied. Let the [PKCS#11 module](/documentation/platform/pki/code-signing/pkcs11-module) or the Windows KSP fill the digest in for you instead of computing it by hand.+ **`sha256sum yourfile` is not the value to declare.** A sign call carries a digest, not the file, so the value Infisical compares is the hash of that digest, as in step 2 above. Declaring the file's own hash never matches and every sign call is denied. The [PKCS#11 module](/documentation/platform/pki/code-signing/pkcs11-module) and the [Windows KSP](/documentation/platform/pki/code-signing/windows-ksp) work this out for you, so scoping by artifact is far easier through them than by hand.</Warning>An approver reviews the request and approves it. The pipeline then signs that artifact, and only that artifact: any other payload is refused because Infisical recomputes the digest from whatever is submitted. An Administrator can do the same up front with **Pre-approve signing**, which skips the review step.