Skip to content

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

Removed scope edit flow from code-signing requests

Carlos Monastyrski3c7798de63ec
diff --git a/backend/src/ee/services/audit-log/audit-log-types.ts b/backend/src/ee/services/audit-log/audit-log-types.ts
index f6ad01fd16..d5b453f046 100644
--- a/backend/src/ee/services/audit-log/audit-log-types.ts
+++ b/backend/src/ee/services/audit-log/audit-log-types.ts
@@ -813,7 +813,6 @@ export enum EventType {
PKI_SIGNER_REQUEST_TO_SIGN = "pki-signer-request-to-sign",
PKI_SIGNER_PRE_APPROVE_SIGNING = "pki-signer-pre-approve-signing",
PKI_SIGNER_REVOKE_REQUEST = "pki-signer-revoke-request",
- PKI_SIGNER_REMOVE_REQUEST_SCOPE_FIELDS = "pki-signer-remove-request-scope-fields",
ADD_PKI_SIGNER_MEMBER = "add-pki-signer-member",
UPDATE_PKI_SIGNER_MEMBER = "update-pki-signer-member",
REMOVE_PKI_SIGNER_MEMBER = "remove-pki-signer-member",
@@ -4813,15 +4812,6 @@ interface PkiSignerRevokeRequestEvent {
};
}
-interface PkiSignerRemoveRequestScopeFieldsEvent {
- type: EventType.PKI_SIGNER_REMOVE_REQUEST_SCOPE_FIELDS;
- metadata: {
- signerId: string;
- requestId: string;
- removedFields: string[];
- };
-}
-
interface AddPkiSignerMemberEvent {
type: EventType.ADD_PKI_SIGNER_MEMBER;
metadata: {
@@ -7409,7 +7399,6 @@ export type Event =
| PkiSignerRequestToSignEvent
| PkiSignerPreApproveSigningEvent
| PkiSignerRevokeRequestEvent
- | PkiSignerRemoveRequestScopeFieldsEvent
| AddPkiSignerMemberEvent
| UpdatePkiSignerMemberEvent
| RemovePkiSignerMemberEvent
diff --git a/backend/src/server/routes/v1/signer-routers/requests-router.ts b/backend/src/server/routes/v1/signer-routers/requests-router.ts
index 4371e22811..d483ad0b15 100644
--- a/backend/src/server/routes/v1/signer-routers/requests-router.ts
+++ b/backend/src/server/routes/v1/signer-routers/requests-router.ts
@@ -4,12 +4,9 @@ import { EventType } from "@app/ee/services/audit-log/audit-log-types";
import { ApiDocsTags } from "@app/lib/api-docs";
import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
-import { CodeSigningScopeField } from "@app/services/approval-policy/code-signing/code-signing-policy-enums";
import {
CODE_SIGNING_SCOPE_API_DESCRIPTION,
- CodeSigningRequestSchema,
CodeSigningScopeInputSchema,
- RemoveCodeSigningScopeFieldsSchema,
SigningWindowDurationSchema
} from "@app/services/approval-policy/code-signing/code-signing-policy-schemas";
import { AuthMode } from "@app/services/auth/auth-type";
@@ -153,53 +150,6 @@ export const registerSignerRequestsRouter = async (server: FastifyZodProvider) =
}
});
- server.route({
- method: "PATCH",
- url: "/:signerId/requests/:requestId/scope",
- config: { rateLimit: writeLimit },
- schema: {
- hide: false,
- operationId: "removeSignerRequestScopeFields",
- tags: [ApiDocsTags.PkiSigners],
- description: "Stop enforcing scope parameters on a pending signing request. Open to the approvers deciding it.",
- params: SignerRequestParamsSchema,
- body: RemoveCodeSigningScopeFieldsSchema,
- response: {
- 200: z.object({
- request: CodeSigningRequestSchema,
- removedFields: z.array(z.nativeEnum(CodeSigningScopeField))
- })
- }
- },
- onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
- handler: async (req) => {
- const { request, removedFields } = await server.services.signerPolicy.removeRequestScopeFields({
- signerId: req.params.signerId,
- requestId: req.params.requestId,
- removeFields: req.body.removeFields,
- actor: req.permission.type,
- actorId: req.permission.id,
- actorAuthMethod: req.permission.authMethod,
- actorOrgId: req.permission.orgId
- });
-
- await server.services.auditLog.createAuditLog({
- ...req.auditLogInfo,
- projectId: await server.services.pkiSigner.getProjectIdForSigner(req.params.signerId),
- event: {
- type: EventType.PKI_SIGNER_REMOVE_REQUEST_SCOPE_FIELDS,
- metadata: {
- signerId: req.params.signerId,
- requestId: req.params.requestId,
- removedFields
- }
- }
- });
-
- return { request, removedFields };
- }
- });
-
server.route({
method: "POST",
url: "/:signerId/requests/:requestId/revoke",
diff --git a/backend/src/services/approval-policy/code-signing/code-signing-policy-fns.test.ts b/backend/src/services/approval-policy/code-signing/code-signing-policy-fns.test.ts
index ef228b8b60..6706776b6f 100644
--- a/backend/src/services/approval-policy/code-signing/code-signing-policy-fns.test.ts
+++ b/backend/src/services/approval-policy/code-signing/code-signing-policy-fns.test.ts
@@ -4,8 +4,7 @@ import {
commandsMatch,
getCodeSigningScopeMismatches,
normalizeCodeSigningScope,
- redactCommandCredentials,
- removeCodeSigningScopeFields
+ redactCommandCredentials
} from "./code-signing-policy-fns";
const DIGEST = "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9";
@@ -245,36 +244,3 @@ describe("redactCommandCredentials", () => {
expect(bound?.command).not.toContain("hunter2");
});
});
-
-describe("removeCodeSigningScopeFields", () => {
- const scope = {
- [CodeSigningScopeField.Command]: "signtool sign app.exe",
- [CodeSigningScopeField.Hostname]: "build-01",
- [CodeSigningScopeField.DataHash]: DIGEST
- };
-
- test("takes out the named parameters and keeps the rest", () => {
- const result = removeCodeSigningScopeFields(scope, [CodeSigningScopeField.DataHash]);
-
- expect(result.removed).toEqual([CodeSigningScopeField.DataHash]);
- expect(result.scope).toEqual({
- [CodeSigningScopeField.Command]: "signtool sign app.exe",
- [CodeSigningScopeField.Hostname]: "build-01"
- });
- });
-
- // Removing twice must land in the same place, so a retried call is not an error.
- test("a parameter the scope does not declare is not reported as removed", () => {
- const result = removeCodeSigningScopeFields(scope, [CodeSigningScopeField.IpAddress]);
-
- expect(result.removed).toEqual([]);
- expect(result.scope).toEqual(scope);
- });
-
- test("removing every parameter leaves no scope at all", () => {
- const result = removeCodeSigningScopeFields(scope, Object.values(CodeSigningScopeField));
-
- expect(result.scope).toBeUndefined();
- expect(result.removed).toHaveLength(3);
- });
-});
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.ts
index f8ff495ce0..f611acec51 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
@@ -46,26 +46,6 @@ export const normalizeCodeSigningScope = (scope: TCodeSigningScope | undefined):
return hasAny ? declared : undefined;
};
-/**
- * The scope with the named parameters taken out. Removing a parameter widens what the approval will
- * cover, so this only ever runs on a pending request and never on an issued grant.
- */
-export const removeCodeSigningScopeFields = (
- scope: TCodeSigningScope,
- fields: readonly CodeSigningScopeField[]
-): { scope: TCodeSigningScope | undefined; removed: CodeSigningScopeField[] } => {
- const removed = Object.values(CodeSigningScopeField).filter(
- (field) => fields.includes(field) && Boolean(scope[field])
- );
-
- const remaining: TCodeSigningScope = {};
- Object.values(CodeSigningScopeField).forEach((field) => {
- if (scope[field] && !removed.includes(field)) remaining[field] = scope[field];
- });
-
- return { scope: Object.keys(remaining).length ? remaining : undefined, removed };
-};
-
export type TObservedSigningContext = {
[CodeSigningScopeField.Command]?: string;
[CodeSigningScopeField.SigningApplication]?: string;
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.ts
index 5f619cb89a..5ad5f19d66 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
@@ -73,16 +73,6 @@ 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.";
-export const RemoveCodeSigningScopeFieldsSchema = z.object({
- removeFields: z
- .array(z.nativeEnum(CodeSigningScopeField))
- .min(1)
- .max(Object.keys(CodeSigningScopeField).length)
- .describe(
- "Scope parameters to stop enforcing on this request, for example ['dataHash'] so the approval covers the same command and machine for any payload. Parameters left in place still have to match at signing time, and naming one the request does not declare has no effect."
- )
-});
-
export const CodeSigningPolicyConstraintsSchema = z
.object({
maxWindowDuration: SigningWindowDurationSchema.optional(),
diff --git a/backend/src/services/signer/signer-policy-service.ts b/backend/src/services/signer/signer-policy-service.ts
index b0928306e1..b025c7342d 100644
--- a/backend/src/services/signer/signer-policy-service.ts
+++ b/backend/src/services/signer/signer-policy-service.ts
@@ -8,7 +8,7 @@ import {
ResourcePermissionSignerActions,
ResourcePermissionSub
} from "@app/ee/services/permission/resource-permission";
-import { BadRequestError, ForbiddenRequestError, NotFoundError } from "@app/lib/errors";
+import { BadRequestError, NotFoundError } from "@app/lib/errors";
import { ms } from "@app/lib/ms";
import {
@@ -20,8 +20,7 @@ import {
ApprovalPolicyScope,
ApprovalPolicyType,
ApprovalRequestGrantStatus,
- ApprovalRequestStatus,
- ApproverType
+ ApprovalRequestStatus
} from "../approval-policy/approval-policy-enums";
import {
TApprovalRequestDALFactory,
@@ -31,10 +30,7 @@ import {
} from "../approval-policy/approval-request-dal";
import { createApprovalRequestWithSteps, notifyStepApprovers } from "../approval-policy/approval-request-fns";
import { CodeSigningScopeField } from "../approval-policy/code-signing/code-signing-policy-enums";
-import {
- normalizeCodeSigningScope,
- removeCodeSigningScopeFields
-} from "../approval-policy/code-signing/code-signing-policy-fns";
+import { normalizeCodeSigningScope } from "../approval-policy/code-signing/code-signing-policy-fns";
import { TCodeSigningRequestData, TCodeSigningScope } from "../approval-policy/code-signing/code-signing-policy-types";
import { ActorType } from "../auth/auth-type";
import { TIdentityDALFactory } from "../identity/identity-dal";
@@ -49,7 +45,6 @@ import {
TGetSignerPolicyDTO,
TListSignerRequestsDTO,
TPreApproveSigningDTO,
- TRemoveSignerRequestScopeFieldsDTO,
TRequestToSignDTO,
TRevokeSignerRequestDTO,
TSignerRequestStatusFilter,
@@ -63,7 +58,7 @@ type TSignerPolicyServiceFactoryDep = {
approvalPolicyStepApproversDAL: Pick<TApprovalPolicyStepApproversDALFactory, "create" | "delete">;
approvalRequestDAL: Pick<
TApprovalRequestDALFactory,
- "create" | "find" | "findById" | "findByIdForUpdate" | "findStepsByRequestId" | "updateById" | "transaction"
+ "create" | "find" | "findById" | "findStepsByRequestId" | "updateById" | "transaction"
>;
signerRequestDAL: TSignerRequestDALFactory;
approvalRequestStepsDAL: Pick<TApprovalRequestStepsDALFactory, "create">;
@@ -71,7 +66,7 @@ type TSignerPolicyServiceFactoryDep = {
approvalRequestGrantsDAL: Pick<TApprovalRequestGrantsDALFactory, "create" | "find" | "updateById">;
membershipDAL: Pick<TMembershipDALFactory, "find" | "transaction">;
membershipRoleDAL: Pick<TMembershipRoleDALFactory, "find">;
- userGroupMembershipDAL: Pick<TUserGroupMembershipDALFactory, "find" | "findGroupMembershipsByUserIdInOrg">;
+ userGroupMembershipDAL: Pick<TUserGroupMembershipDALFactory, "find">;
identityGroupMembershipDAL: Pick<TIdentityGroupMembershipDALFactory, "find">;
userDAL: Pick<TUserDALFactory, "findById" | "find">;
identityDAL: Pick<TIdentityDALFactory, "findById">;
@@ -779,96 +774,6 @@ export const signerPolicyServiceFactory = ({
return result;
};
- const removeRequestScopeFields = async (dto: TRemoveSignerRequestScopeFieldsDTO) => {
- const signer = await $loadSignerOrThrow(signerDAL, dto.signerId);
- await $assertResourcePermission(
- signer.id,
- signer.projectId,
- dto.actor,
- dto.actorId,
- dto.actorAuthMethod,
- dto.actorOrgId,
- ResourcePermissionSignerActions.Read
- );
-
- const request = await approvalRequestDAL.findById(dto.requestId);
- if (!request || request.scopeId !== signer.id || request.type !== ApprovalPolicyType.CertCodeSigning) {
- throw new NotFoundError({ message: `Request with ID '${dto.requestId}' not found on this signer.` });
- }
- if (request.status !== ApprovalRequestStatus.Pending) {
- throw new BadRequestError({
- message: `This request is ${request.status}. Scope parameters can only be removed while a request is pending review.`
- });
- }
-
- const requestData = (request.requestData as { requestData?: TCodeSigningRequestData } | null)?.requestData;
- const scope = requestData?.scope;
- if (!scope || !Object.values(scope).some(Boolean)) {
- throw new BadRequestError({ message: "This request has no scope parameters to remove." });
- }
-
- const steps = await approvalRequestDAL.findStepsByRequestId(dto.requestId);
- const currentStep = steps.find((step) => step.stepNumber === request.currentStep);
-
- if (currentStep?.approvals.length) {
- throw new BadRequestError({
- message:
- "This request already has an approval on its current step. Reject it and open a new request to sign with different parameters."
- });
- }
-
- const groupIds = new Set(
- dto.actor === ActorType.USER && dto.actorOrgId
- ? (await userGroupMembershipDAL.findGroupMembershipsByUserIdInOrg(dto.actorId, dto.actorOrgId)).map(
- (membership) => membership.groupId
- )
- : []
- );
- const isApprover = Boolean(
- dto.actor === ActorType.USER &&
- currentStep?.approvers.some(
- (approver) =>
- (approver.type === ApproverType.User && approver.id === dto.actorId) ||
- (approver.type === ApproverType.Group && groupIds.has(approver.id))
- )
- );
- if (!isApprover) {
- throw new ForbiddenRequestError({
- message: "Only an approver on this request can remove its scope parameters."
- });
- }
-
- const { request: updatedRow, removedFields } = await approvalRequestDAL.transaction(async (tx) => {
- const locked = await approvalRequestDAL.findByIdForUpdate(dto.requestId, tx);
- if (!locked || locked.status !== ApprovalRequestStatus.Pending) {
- throw new BadRequestError({ message: "This request is no longer pending review." });
- }
-
- const lockedBlob = locked.requestData as { version: number; requestData: TCodeSigningRequestData };
- const lockedScope = lockedBlob.requestData.scope;
- const { scope: remainingScope, removed } = lockedScope
- ? removeCodeSigningScopeFields(lockedScope, dto.removeFields)
- : { scope: undefined, removed: [] };
-
- const updatedRequest = await approvalRequestDAL.updateById(
- dto.requestId,
- {
- requestData: {
- ...lockedBlob,
- requestData: { ...lockedBlob.requestData, scope: remainingScope }
- }
- },
- tx
- );
-
- return { request: updatedRequest, removedFields: removed };
- });
-
- const updatedBlob = updatedRow.requestData as { version: 1; requestData: TCodeSigningRequestData };
-
- return { request: { ...updatedRow, requestData: updatedBlob, steps }, removedFields };
- };
-
const revokeRequest = async (dto: TRevokeSignerRequestDTO) => {
const signer = await $loadSignerOrThrow(signerDAL, dto.signerId);
await $assertResourcePermission(
@@ -915,7 +820,6 @@ export const signerPolicyServiceFactory = ({
listRequests,
requestToSign,
preApproveSigning,
- removeRequestScopeFields,
revokeRequest
};
};
diff --git a/backend/src/services/signer/signer-types.ts b/backend/src/services/signer/signer-types.ts
index fe1d4d410f..c960e8360e 100644
--- a/backend/src/services/signer/signer-types.ts
+++ b/backend/src/services/signer/signer-types.ts
@@ -4,7 +4,6 @@ import { z } from "zod";
import { SigningAlgorithm } from "@app/lib/crypto/sign/types";
import { TProjectPermission } from "@app/lib/types";
-import { CodeSigningScopeField } from "../approval-policy/code-signing/code-signing-policy-enums";
import { TCodeSigningScope } from "../approval-policy/code-signing/code-signing-policy-types";
import { CertKeyAlgorithm } from "../certificate/certificate-types";
import { CaType } from "../certificate-authority/certificate-authority-enums";
@@ -196,12 +195,6 @@ export type TPreApproveSigningDTO = {
scope?: TCodeSigningScope;
} & TActorPermission;
-export type TRemoveSignerRequestScopeFieldsDTO = {
- signerId: string;
- requestId: string;
- removeFields: CodeSigningScopeField[];
-} & TActorPermission;
-
export type TRevokeSignerRequestDTO = {
signerId: string;
requestId: string;
diff --git a/docs/documentation/platform/pki/code-signing/approvals.mdx b/docs/documentation/platform/pki/code-signing/approvals.mdx
index c69768322a..7df1a89c78 100644
--- a/docs/documentation/platform/pki/code-signing/approvals.mdx
+++ b/docs/documentation/platform/pki/code-signing/approvals.mdx
@@ -132,15 +132,11 @@ The [PKCS#11 module](/documentation/platform/pki/code-signing/pkcs11-module) and
Filling in a digest by hand is fiddly, because a sign call carries a digest rather than the file, so the value to declare is the hash of the bytes the call submits and not `sha256sum yourfile`. If you are calling the API directly, see the [Sign API reference](/api-reference/endpoints/code-signing/signers/sign).
</Note>
-### Removing a parameter from a request
+### When the scope needs to change
-A scoped request is not fixed once it is open. While it is still pending review, an approver deciding it can stop enforcing any parameter on it, from the **Request Scope** panel on the request. The requester cannot: widening is a reviewer's decision, and the requester is often the signing client itself. The parameters left in place still have to match at signing time.
+A request's scope is fixed once it is open. Nobody edits it during review, including the approvers: an approval means the parameters shown on the request, so if they are wrong the request is rejected and a new one is opened with the parameters you want.
-This is what makes a digest-scoped request usable for a pipeline that signs on every build. A client opens its request pinned to the artifact it was denied on, someone drops **Data Digest**, and the approval that follows covers that command on that machine for any artifact until the window or the signature count runs out.
-
-<Warning>
- Removing a parameter widens what the approval will cover, so it is recorded in the audit log against whoever did it. Once a request is approved its scope is fixed: the access record enforces exactly the parameters that were left in place, and loosening it further means a new request.
-</Warning>
+For a pipeline that signs a different artifact on every run, do not fight this per request. Tell the signing client which parameters to leave out in the first place, with `approval.exclude_scope_fields` in the [PKCS#11 module](/documentation/platform/pki/code-signing/pkcs11-module#leaving-parameters-out-of-a-request) or the [Windows KSP](/documentation/platform/pki/code-signing/windows-ksp#leaving-parameters-out-of-a-request). Excluding `data_hash` is the common case: a timestamped signature changes the digest between runs even for the same file, so pinning it would mean a fresh approval for every build. Exclude one parameter at a time. Each one you drop widens what the approval covers, and because an approval belongs to the identity rather than to a machine, excluding all of them grants that identity any signature it asks for until the window or count runs out.
## Access lifecycle
diff --git a/docs/documentation/platform/pki/code-signing/pkcs11-module.mdx b/docs/documentation/platform/pki/code-signing/pkcs11-module.mdx
index a79f1d2f7d..9350d6ce79 100644
--- a/docs/documentation/platform/pki/code-signing/pkcs11-module.mdx
+++ b/docs/documentation/platform/pki/code-signing/pkcs11-module.mdx
@@ -119,6 +119,7 @@ export INFISICAL_CONFIG=/path/to/your/pkcs11.conf
| `cache.signer_ttl_seconds` | No | `300` | How long the list of Signers is cached. |
| `approval.signing_duration` | No | None | Auto-request signing access with this window when no active access exists. Valid range: `1m` to `30d`. |
| `approval.signing_count` | No | None | Auto-request signing access for this many signatures when no active access exists. |
+| `approval.exclude_scope_fields` | No | None | Signing parameters to leave out of the requests the module opens, so one approval covers any value of them. Any of `command`, `signing_application`, `signing_application_hash`, `hostname`, `os_username`, `data_hash`. An unknown name is rejected at startup. |
| `log_level` | No | `info` | One of `trace`, `debug`, `info`, `warn`, `error`. |
| `log_file` | No | stderr | Optional path to a log file. |
@@ -206,9 +207,33 @@ The request is [scoped](/documentation/platform/pki/code-signing/approvals#scopi
<Note>
The first sign call **still fails**, because an approver has to act on the request. Once approved, run the same command again and it succeeds.
- The approval covers that exact command and artifact, so a different artifact, a changed argument, or reordered flags needs a new request. Widen the scope in Infisical when one approval should cover a batch.
+ The approval covers that exact command and artifact, so a different artifact, a changed argument, or reordered flags needs a new request. A request's parameters are fixed once it is open, so when they are wrong the request is rejected and reopened rather than edited. To have one approval cover a batch, leave the parameters that vary out of the request from the start.
</Note>
+### Leaving parameters out of a request
+
+Every parameter on a request has to match at signing time, so a request that names the artifact digest covers exactly one artifact. When a run should cover a series of builds instead, name the parameters that vary in `approval.exclude_scope_fields` and the module leaves them off every request it opens:
+
+```json
+{
+ "approval": {
+ "signing_duration": "8h",
+ "signing_count": 10,
+ "exclude_scope_fields": ["data_hash"]
+ }
+}
+```
+
+`data_hash` is the usual one. A timestamped signature changes the digest between runs even for the same file, so pinning it means a fresh approval for every build. The other names are `command`, `signing_application`, `signing_application_hash`, `hostname` and `os_username`.
+
+Leave out only what genuinely varies, and be aware that dropping a parameter widens the approval further than the machine you configured it on. An approval belongs to the identity that asked for it, not to a host, so once `hostname` is excluded the same approval covers that identity signing from anywhere its credentials are installed.
+
+<Warning>
+ Excluding every parameter leaves the request with no scope at all. The resulting approval permits any command, on any machine, against any artifact, for the whole of its window and signature count, which is the same access you would have with no scoping at all. Excluding `data_hash` alone is almost always what a build pipeline needs.
+</Warning>
+
+An excluded parameter is still recorded on the signing operation, so the command, machine, account and artifact digest behind every signature stay available to auditors even when they no longer constrain the approval.
+
### Example CI workflow
1. Pipeline calls `jarsigner` (or any PKCS#11 tool) against the Infisical module.
diff --git a/docs/documentation/platform/pki/code-signing/windows-ksp.mdx b/docs/documentation/platform/pki/code-signing/windows-ksp.mdx
index bf1fdb2825..fa86754366 100644
--- a/docs/documentation/platform/pki/code-signing/windows-ksp.mdx
+++ b/docs/documentation/platform/pki/code-signing/windows-ksp.mdx
@@ -125,6 +125,7 @@ $env:INFISICAL_TOKEN = "<your-access-token>"
| `cache.signer_ttl_seconds` | No | `300` | How long to reuse the list of Signers. |
| `approval.signing_duration` | No | None | Ask for an access window of this length when signing is denied for want of approved access (`30m`, `8h`, `2d`). The provider accepts 1m to 30d as a sanity check; the real limit is the Signer's approval policy. The window starts when the request is approved, so time spent waiting for an approver does not eat into it. |
| `approval.signing_count` | No | None | Ask for access good for this many signing operations. |
+| `approval.exclude_scope_fields` | No | None | Signing parameters to leave out of the requests the provider opens, so one approval covers any value of them. Any of `command`, `signing_application`, `signing_application_hash`, `hostname`, `os_username`, `data_hash`. An unknown name is rejected at startup. |
| `log_level` | No | `info` | How much detail to log: `trace`, `debug`, `info`, `warn`, or `error`. |
| `log_file` | No | `%ProgramData%\Infisical\ksp.log` | Where to write the log. `signtool` has no window to print to, so the plug-in writes here by default. |
@@ -208,9 +209,33 @@ The request is [scoped](/documentation/platform/pki/code-signing/approvals#scopi
<Note>
The first signing attempt **still fails**, because an approver has to act on the request. Once approved, run the same command again and it succeeds.
- The approval covers that exact command and artifact, so a different artifact, a changed argument, or reordered flags needs a new request. Widen the scope in Infisical when one approval should cover a batch.
+ The approval covers that exact command and artifact, so a different artifact, a changed argument, or reordered flags needs a new request. A request's parameters are fixed once it is open, so when they are wrong the request is rejected and reopened rather than edited. To have one approval cover a batch, leave the parameters that vary out of the request from the start.
</Note>
+### Leaving parameters out of a request
+
+Every parameter on a request has to match at signing time, so a request that names the artifact digest covers exactly one artifact. When a run should cover a series of builds instead, name the parameters that vary in `approval.exclude_scope_fields` and the provider leaves them off every request it opens:
+
+```json
+{
+ "approval": {
+ "signing_duration": "8h",
+ "signing_count": 10,
+ "exclude_scope_fields": ["data_hash"]
+ }
+}
+```
+
+`data_hash` is the usual one. A timestamped signature changes the digest between runs even for the same file, so pinning it means a fresh approval for every build. The other names are `command`, `signing_application`, `signing_application_hash`, `hostname` and `os_username`.
+
+Leave out only what genuinely varies, and be aware that dropping a parameter widens the approval further than the machine you configured it on. An approval belongs to the identity that asked for it, not to a host, so once `hostname` is excluded the same approval covers that identity signing from anywhere its credentials are installed.
+
+<Warning>
+ Excluding every parameter leaves the request with no scope at all. The resulting approval permits any command, on any machine, against any artifact, for the whole of its window and signature count, which is the same access you would have with no scoping at all. Excluding `data_hash` alone is almost always what a build pipeline needs.
+</Warning>
+
+An excluded parameter is still recorded on the signing operation, so the command, machine, account and artifact digest behind every signature stay available to auditors even when they no longer constrain the approval.
+
### Example CI workflow
1. The pipeline runs `signtool sign ... /csp "Infisical Key Storage Provider" /kc <signer>`.
diff --git a/frontend/src/hooks/api/signers/index.tsx b/frontend/src/hooks/api/signers/index.tsx
index b2f48beeb2..c2da06ccfb 100644
--- a/frontend/src/hooks/api/signers/index.tsx
+++ b/frontend/src/hooks/api/signers/index.tsx
@@ -12,7 +12,6 @@ export {
useReissueSignerCertificate,
useRemoveSignerGroupMember,
useRemoveSignerIdentityMember,
- useRemoveSignerRequestScopeFields,
useRemoveSignerUserMember,
useRequestToSign,
useRevokeSignerRequest,
diff --git a/frontend/src/hooks/api/signers/mutations.tsx b/frontend/src/hooks/api/signers/mutations.tsx
index 884f815141..7d3f21b006 100644
--- a/frontend/src/hooks/api/signers/mutations.tsx
+++ b/frontend/src/hooks/api/signers/mutations.tsx
@@ -3,11 +3,9 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { createNotification } from "@app/components/notifications";
import { apiRequest } from "@app/config/request";
import { approvalRequestQuery } from "@app/hooks/api/approvalRequests/queries";
-import { TApprovalRequest } from "@app/hooks/api/approvalRequests/types";
import { signerKeys } from "./queries";
import {
- CodeSigningScopeField,
SignerStatus,
TAddSignerGroupMemberDTO,
TAddSignerIdentityMemberDTO,
@@ -20,7 +18,6 @@ import {
TReissueSignerCertificateDTO,
TRemoveSignerGroupDTO,
TRemoveSignerIdentityDTO,
- TRemoveSignerRequestScopeFieldsDTO,
TRemoveSignerUserDTO,
TRequestToSignDTO,
TRevokeSignerRequestDTO,
@@ -419,26 +416,3 @@ export const useRevokeSignerRequest = () => {
}
});
};
-
-export const useRemoveSignerRequestScopeFields = () => {
- const queryClient = useQueryClient();
-
- return useMutation<
- { removedFields: CodeSigningScopeField[]; request: TApprovalRequest },
- object,
- TRemoveSignerRequestScopeFieldsDTO
- >({
- mutationFn: async ({ signerId, requestId, removeFields }) => {
- const { data } = await apiRequest.patch<{
- removedFields: CodeSigningScopeField[];
- request: TApprovalRequest;
- }>(`/api/v1/cert-manager/signers/${signerId}/requests/${requestId}/scope`, { removeFields });
- return data;
- },
- onSuccess: (_, { signerId }) => {
- queryClient.invalidateQueries({ queryKey: signerKeys.requests(signerId) });
- queryClient.invalidateQueries({ queryKey: approvalRequestQuery.allKey() });
- createNotification({ text: "Scope parameter removed from the request", type: "success" });
- }
- });
-};
diff --git a/frontend/src/hooks/api/signers/types.ts b/frontend/src/hooks/api/signers/types.ts
index 27bee98dae..e96be1ac2d 100644
--- a/frontend/src/hooks/api/signers/types.ts
+++ b/frontend/src/hooks/api/signers/types.ts
@@ -521,9 +521,4 @@ export type TPreApproveSigningDTO = {
requestedWindowDuration?: string;
scope?: TCodeSigningScope;
};
-export type TRemoveSignerRequestScopeFieldsDTO = {
- signerId: string;
- requestId: string;
- removeFields: CodeSigningScopeField[];
-};
export type TRevokeSignerRequestDTO = { signerId: string; requestId: string };
diff --git a/frontend/src/pages/cert-manager/ApprovalRequestDetailPage/ApprovalRequestDetailPage.tsx b/frontend/src/pages/cert-manager/ApprovalRequestDetailPage/ApprovalRequestDetailPage.tsx
index ba11fac241..aa12130217 100644
--- a/frontend/src/pages/cert-manager/ApprovalRequestDetailPage/ApprovalRequestDetailPage.tsx
+++ b/frontend/src/pages/cert-manager/ApprovalRequestDetailPage/ApprovalRequestDetailPage.tsx
@@ -1,37 +1,20 @@
-import { useState } from "react";
import { Helmet } from "react-helmet";
import { faBan, faChevronLeft } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { useQuery } from "@tanstack/react-query";
import { Link, useNavigate, useParams, useSearch } from "@tanstack/react-router";
import { format } from "date-fns";
-import { XIcon } from "lucide-react";
import { twMerge } from "tailwind-merge";
import { createNotification } from "@app/components/notifications";
import { ConfirmActionModal, ContentLoader, EmptyState } from "@app/components/v2";
-import {
- Badge,
- Button,
- Dialog,
- DialogContent,
- DialogDescription,
- DialogFooter,
- DialogHeader,
- DialogTitle,
- IconButton
-} from "@app/components/v3";
-import { useOrganization, useProject, useProjectPermission, useUser } from "@app/context";
+import { Badge, Button } from "@app/components/v3";
+import { useOrganization, useProject, useUser } from "@app/context";
import { usePopUp } from "@app/hooks";
-import {
- ApprovalPolicyScope,
- ApprovalPolicyType,
- ApproverType
-} from "@app/hooks/api/approvalPolicies";
+import { ApprovalPolicyScope, ApprovalPolicyType } from "@app/hooks/api/approvalPolicies";
import {
approvalRequestQuery,
ApprovalRequestStatus,
- ApprovalRequestStepStatus,
CertRequestRequestData,
CodeSigningRequestData,
useCancelApprovalRequest
@@ -40,8 +23,7 @@ import { useGetPkiApplicationById } from "@app/hooks/api/pkiApplications";
import {
CodeSigningScopeField,
codeSigningScopeFieldLabels,
- MONOSPACED_SCOPE_FIELDS,
- useRemoveSignerRequestScopeFields
+ MONOSPACED_SCOPE_FIELDS
} from "@app/hooks/api/signers";
import {
@@ -56,33 +38,12 @@ const ROUTE_ID =
const CodeSigningDetailsSection = ({
requestData,
requesterName,
- requesterEmail,
- requestId,
- canEditScope
+ requesterEmail
}: {
requestData: CodeSigningRequestData;
requesterName?: string;
requesterEmail?: string;
- requestId: string;
- canEditScope: boolean;
}) => {
- const removeScopeFields = useRemoveSignerRequestScopeFields();
- const [fieldToRemove, setFieldToRemove] = useState<CodeSigningScopeField | null>(null);
-
- const handleRemove = async () => {
- if (!fieldToRemove) return;
- try {
- await removeScopeFields.mutateAsync({
- signerId: requestData.signerId,
- requestId,
- removeFields: [fieldToRemove]
- });
- setFieldToRemove(null);
- } catch {
- // The mutation cache reports the failure
- }
- };
-
return (
<div className="flex flex-col gap-4">
<div className="rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
@@ -136,71 +97,24 @@ const CodeSigningDetailsSection = ({
{Object.values(CodeSigningScopeField)
.filter((field) => requestData.scope?.[field])
.map((field) => (
- <div key={field} className="flex items-start justify-between gap-3">
- <div className="min-w-0">
- <span className="text-xs text-mineshaft-400">
- {codeSigningScopeFieldLabels[field]}
- </span>
- <p
- className={twMerge(
- "text-sm break-all text-mineshaft-100",
- MONOSPACED_SCOPE_FIELDS.includes(field) && "font-mono text-xs"
- )}
- >
- {requestData.scope?.[field]}
- </p>
- </div>
- {canEditScope && (
- <IconButton
- variant="ghost"
- size="sm"
- className="shrink-0"
- aria-label={`Stop enforcing ${codeSigningScopeFieldLabels[field]}`}
- onClick={() => setFieldToRemove(field)}
- >
- <XIcon className="size-4" />
- </IconButton>
- )}
+ <div key={field}>
+ <span className="text-xs text-mineshaft-400">
+ {codeSigningScopeFieldLabels[field]}
+ </span>
+ <p
+ className={twMerge(
+ "text-sm break-all text-mineshaft-100",
+ MONOSPACED_SCOPE_FIELDS.includes(field) && "font-mono text-xs"
+ )}
+ >
+ {requestData.scope?.[field]}
+ </p>
</div>
))}
</div>
</div>
)}
</div>
-
- <Dialog
- open={Boolean(fieldToRemove)}
- onOpenChange={(isOpen) => {
- if (!isOpen) setFieldToRemove(null);
- }}
- >
- <DialogContent className="max-w-lg">
- <DialogHeader>
- <DialogTitle>
- {fieldToRemove
- ? `Stop enforcing ${codeSigningScopeFieldLabels[fieldToRemove]}?`
- : "Stop enforcing this parameter?"}
- </DialogTitle>
- <DialogDescription>
- Signing will be allowed whatever value this parameter takes. The other parameters
- still have to match.
- </DialogDescription>
- </DialogHeader>
- <DialogFooter>
- <Button variant="outline" onClick={() => setFieldToRemove(null)} className="flex-1">
- Cancel
- </Button>
- <Button
- variant="danger"
- onClick={handleRemove}
- isPending={removeScopeFields.isPending}
- className="flex-1"
- >
- Stop enforcing
- </Button>
- </DialogFooter>
- </DialogContent>
- </Dialog>
</div>
);
};
@@ -211,8 +125,6 @@ const PageContent = () => {
const { currentOrg } = useOrganization();
const { currentProject } = useProject();
const { user: currentUser } = useUser();
- const { memberships } = useProjectPermission();
- const userGroupIds = memberships.map((membership) => membership.actorGroupId).filter(Boolean);
const cancelApprovalRequest = useCancelApprovalRequest();
const navigate = useNavigate();
const { handlePopUpOpen, handlePopUpToggle, popUp } = usePopUp(["cancelRequest"]);
@@ -395,23 +307,11 @@ const PageContent = () => {
const renderDetailsSection = () => {
if (isCodeSigning) {
const reqData = request.requestData.requestData as CodeSigningRequestData;
- const currentStep = request.steps.find(
- (step) => step.status === ApprovalRequestStepStatus.InProgress
- );
- const isCurrentStepApprover = Boolean(
- currentStep?.approvers.some((approver) =>
- approver.type === ApproverType.User
- ? approver.id === currentUser?.id
- : userGroupIds.includes(approver.id)
- )
- );
return (
<CodeSigningDetailsSection
requestData={reqData}
requesterName={request.requesterName}
requesterEmail={request.requesterEmail}
- requestId={request.id}
- canEditScope={request.status === ApprovalRequestStatus.Pending && isCurrentStepApprover}
/>
);
}