Skip to content

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

feat(pki): infer the signing address on code-signing approval requests

Carlos Monastyrski1682fa3f2b8e
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 d483ad0b15..b8d561a75b 100644
--- a/backend/src/server/routes/v1/signer-routers/requests-router.ts
+++ b/backend/src/server/routes/v1/signer-routers/requests-router.ts
@@ -6,6 +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,
+ CodeSigningRequestScopeInputSchema,
CodeSigningScopeInputSchema,
SigningWindowDurationSchema
} from "@app/services/approval-policy/code-signing/code-signing-policy-schemas";
@@ -73,7 +74,7 @@ export const registerSignerRequestsRouter = async (server: FastifyZodProvider) =
requestedWindowDuration: SigningWindowDurationSchema.optional().describe(
"How long the approval stays usable once it is granted, for example '4h'. The window starts when the request is approved."
),
- scope: CodeSigningScopeInputSchema.optional().describe(CODE_SIGNING_SCOPE_API_DESCRIPTION)
+ scope: CodeSigningRequestScopeInputSchema.optional().describe(CODE_SIGNING_SCOPE_API_DESCRIPTION)
})
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
@@ -84,7 +85,8 @@ export const registerSignerRequestsRouter = async (server: FastifyZodProvider) =
actor: req.permission.type,
actorId: req.permission.id,
actorAuthMethod: req.permission.authMethod,
- actorOrgId: req.permission.orgId
+ actorOrgId: req.permission.orgId,
+ ipAddress: req.realIp
});
await server.services.auditLog.createAuditLog({
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 5ad5f19d66..a7fa2d8fe6 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
@@ -70,8 +70,12 @@ export const CodeSigningScopeSchema = z.object({
export const CodeSigningScopeInputSchema = CodeSigningScopeSchema.strict();
+export const CodeSigningRequestScopeInputSchema = CodeSigningScopeSchema.extend({
+ [CodeSigningScopeField.IpAddress]: CodeSigningScopeSchema.shape[CodeSigningScopeField.IpAddress].nullable()
+}).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.";
+ "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. A machine identity that declares a scope without naming ipAddress has it filled in with the address the request arrives from; send null to leave signing unrestricted by address.";
export const CodeSigningPolicyConstraintsSchema = z
.object({
diff --git a/backend/src/services/approval-policy/code-signing/code-signing-policy-types.ts b/backend/src/services/approval-policy/code-signing/code-signing-policy-types.ts
index ae5144e73d..b92a617b04 100644
--- a/backend/src/services/approval-policy/code-signing/code-signing-policy-types.ts
+++ b/backend/src/services/approval-policy/code-signing/code-signing-policy-types.ts
@@ -8,6 +8,7 @@ import {
CodeSigningPolicySchema,
CodeSigningRequestGrantSchema,
CodeSigningRequestSchema,
+ CodeSigningRequestScopeInputSchema,
CodeSigningScopeSchema
} from "./code-signing-policy-schemas";
@@ -22,3 +23,4 @@ export type TCodeSigningRequestData = z.infer<typeof CodeSigningPolicyRequestDat
export type TCodeSigningGrantAttributes = z.infer<typeof CodeSigningRequestGrantSchema>["attributes"];
export type TCodeSigningScope = z.infer<typeof CodeSigningScopeSchema>;
+export type TCodeSigningRequestScopeInput = z.infer<typeof CodeSigningRequestScopeInputSchema>;
diff --git a/backend/src/services/signer/signer-policy-service.ts b/backend/src/services/signer/signer-policy-service.ts
index b025c7342d..8f599ca6fa 100644
--- a/backend/src/services/signer/signer-policy-service.ts
+++ b/backend/src/services/signer/signer-policy-service.ts
@@ -31,7 +31,11 @@ import {
import { createApprovalRequestWithSteps, notifyStepApprovers } from "../approval-policy/approval-request-fns";
import { CodeSigningScopeField } from "../approval-policy/code-signing/code-signing-policy-enums";
import { normalizeCodeSigningScope } from "../approval-policy/code-signing/code-signing-policy-fns";
-import { TCodeSigningRequestData, TCodeSigningScope } from "../approval-policy/code-signing/code-signing-policy-types";
+import {
+ TCodeSigningRequestData,
+ TCodeSigningRequestScopeInput,
+ TCodeSigningScope
+} from "../approval-policy/code-signing/code-signing-policy-types";
import { ActorType } from "../auth/auth-type";
import { TIdentityDALFactory } from "../identity/identity-dal";
import { TMembershipDALFactory } from "../membership/membership-dal";
@@ -106,6 +110,22 @@ const $loadSignerOrThrow = async (signerDAL: TSignerPolicyServiceFactoryDep["sig
return signer;
};
+const $resolveRequestedScope = (
+ scope: TCodeSigningRequestScopeInput | undefined,
+ actor: ActorType,
+ requestIpAddress: string | undefined
+): TCodeSigningScope | undefined => {
+ if (!scope) return undefined;
+
+ const { [CodeSigningScopeField.IpAddress]: declaredIpAddress, ...rest } = scope;
+ if (declaredIpAddress === null) return rest;
+ if (declaredIpAddress !== undefined) return { ...rest, [CodeSigningScopeField.IpAddress]: declaredIpAddress };
+ if (actor === ActorType.IDENTITY && requestIpAddress) {
+ return { ...rest, [CodeSigningScopeField.IpAddress]: requestIpAddress };
+ }
+ return rest;
+};
+
export const signerPolicyServiceFactory = ({
signerDAL,
approvalPolicyDAL,
@@ -593,7 +613,7 @@ export const signerPolicyServiceFactory = ({
requestedSignings: dto.requestedSignings,
requestedWindowDuration: dto.requestedWindowDuration
});
- const scope = normalizeCodeSigningScope(dto.scope);
+ const scope = normalizeCodeSigningScope($resolveRequestedScope(dto.scope, dto.actor, dto.ipAddress));
if (scope) {
const duplicate = await $findDuplicatePendingRequest({
diff --git a/backend/src/services/signer/signer-types.ts b/backend/src/services/signer/signer-types.ts
index c960e8360e..2ffdb442f9 100644
--- a/backend/src/services/signer/signer-types.ts
+++ b/backend/src/services/signer/signer-types.ts
@@ -4,7 +4,10 @@ import { z } from "zod";
import { SigningAlgorithm } from "@app/lib/crypto/sign/types";
import { TProjectPermission } from "@app/lib/types";
-import { TCodeSigningScope } from "../approval-policy/code-signing/code-signing-policy-types";
+import {
+ TCodeSigningRequestScopeInput,
+ TCodeSigningScope
+} from "../approval-policy/code-signing/code-signing-policy-types";
import { CertKeyAlgorithm } from "../certificate/certificate-types";
import { CaType } from "../certificate-authority/certificate-authority-enums";
import { CertKeySource, SignerStatus, SigningOperationStatus } from "./signer-enums";
@@ -182,7 +185,8 @@ export type TRequestToSignDTO = {
justification: string;
requestedSignings?: number;
requestedWindowDuration?: string;
- scope?: TCodeSigningScope;
+ scope?: TCodeSigningRequestScopeInput;
+ ipAddress?: string;
} & TActorPermission;
export type TPreApproveSigningDTO = {
diff --git a/docs/documentation/platform/pki/code-signing/approvals.mdx b/docs/documentation/platform/pki/code-signing/approvals.mdx
index 7df1a89c78..53e2b25c3d 100644
--- a/docs/documentation/platform/pki/code-signing/approvals.mdx
+++ b/docs/documentation/platform/pki/code-signing/approvals.mdx
@@ -136,7 +136,7 @@ The [PKCS#11 module](/documentation/platform/pki/code-signing/pkcs11-module) and
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.
-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.
+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, dropping 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 9350d6ce79..9c2ee7ea75 100644
--- a/docs/documentation/platform/pki/code-signing/pkcs11-module.mdx
+++ b/docs/documentation/platform/pki/code-signing/pkcs11-module.mdx
@@ -119,7 +119,8 @@ 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. |
+| `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`, `ip_address`, `data_hash`. An unknown name is rejected at startup. |
+| `approval.ip_address` | No | None | Pin the requests the module opens to this address instead of the one Infisical sees them arrive from, which is what it uses when this is unset. It does not have to be this machine's, so you can name a build agent's egress address. |
| `log_level` | No | `info` | One of `trace`, `debug`, `info`, `warn`, `error`. |
| `log_file` | No | stderr | Optional path to a log file. |
@@ -212,7 +213,7 @@ The request is [scoped](/documentation/platform/pki/code-signing/approvals#scopi
### 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:
+Every parameter on a request has to match at signing time, so a request that names the artifact digest covers exactly one artifact. To have one approval cover a series of builds, name the parameters that vary in `approval.exclude_scope_fields` and the module leaves them off every request it opens:
```json
{
@@ -224,7 +225,7 @@ Every parameter on a request has to match at signing time, so a request that nam
}
```
-`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`.
+`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`, `os_username` and `ip_address`.
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.
@@ -234,6 +235,25 @@ Leave out only what genuinely varies, and be aware that dropping a parameter wid
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.
+### Scoping by address
+
+The address is the one parameter the module cannot observe, because what counts is the address Infisical receives the sign call from, after any NAT or proxy in between. Infisical fills it in from the request itself, the same value it records in the audit log, so requests are scoped by address without any configuration.
+
+Two settings change that:
+
+```json
+{
+ "approval": {
+ "ip_address": "203.0.113.10",
+ "exclude_scope_fields": ["ip_address"]
+ }
+}
+```
+
+`ip_address` pins a different address than the request came from, which is how you tie an approval to a build agent's egress address from elsewhere. Excluding `ip_address` leaves signing unrestricted by address, which is what a fleet behind a rotating NAT pool needs, since a pinned address would stop matching between runs. Setting both leaves the address unscoped, because excluding wins.
+
+Infisical always compares against the address it sees, never one a caller reports, so neither setting can widen access beyond what the approval already allows.
+
### Example CI workflow
1. Pipeline calls `jarsigner` (or any PKCS#11 tool) against the Infisical module.
@@ -247,7 +267,9 @@ For fully unattended CI, have an Administrator **pre-approve** signing access vi
## Troubleshooting
-Turn on debug logging in the config first. It'll usually tell you exactly what went wrong:
+If the module fails before it can log anything, it prints the reason to stderr prefixed `infisical-pkcs11:`. That covers a config file it cannot read, since the log path lives in the file that just failed, and PKCS#11 gives the calling tool nothing but a generic `CKR_GENERAL_ERROR`.
+
+For everything else, turn on debug logging in the config first. It'll usually tell you exactly what went wrong:
```json
{
diff --git a/docs/documentation/platform/pki/code-signing/windows-ksp.mdx b/docs/documentation/platform/pki/code-signing/windows-ksp.mdx
index fa86754366..6fbb00a22e 100644
--- a/docs/documentation/platform/pki/code-signing/windows-ksp.mdx
+++ b/docs/documentation/platform/pki/code-signing/windows-ksp.mdx
@@ -125,7 +125,8 @@ $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. |
+| `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`, `ip_address`, `data_hash`. An unknown name is rejected at startup. |
+| `approval.ip_address` | No | None | Pin the requests the provider opens to this address instead of the one Infisical sees them arrive from, which is what it uses when this is unset. It does not have to be this machine's, so you can name a build agent's egress address. |
| `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. |
@@ -214,7 +215,7 @@ The request is [scoped](/documentation/platform/pki/code-signing/approvals#scopi
### 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:
+Every parameter on a request has to match at signing time, so a request that names the artifact digest covers exactly one artifact. To have one approval cover a series of builds, name the parameters that vary in `approval.exclude_scope_fields` and the provider leaves them off every request it opens:
```json
{
@@ -226,7 +227,7 @@ Every parameter on a request has to match at signing time, so a request that nam
}
```
-`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`.
+`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`, `os_username` and `ip_address`.
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.
@@ -236,6 +237,25 @@ Leave out only what genuinely varies, and be aware that dropping a parameter wid
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.
+### Scoping by address
+
+The address is the one parameter the provider cannot observe, because what counts is the address Infisical receives the sign call from, after any NAT or proxy in between. Infisical fills it in from the request itself, the same value it records in the audit log, so requests are scoped by address without any configuration.
+
+Two settings change that:
+
+```json
+{
+ "approval": {
+ "ip_address": "203.0.113.10",
+ "exclude_scope_fields": ["ip_address"]
+ }
+}
+```
+
+`ip_address` pins a different address than the request came from, which is how you tie an approval to a build agent's egress address from elsewhere. Excluding `ip_address` leaves signing unrestricted by address, which is what a fleet behind a rotating NAT pool needs, since a pinned address would stop matching between runs. Setting both leaves the address unscoped, because excluding wins.
+
+Infisical always compares against the address it sees, never one a caller reports, so neither setting can widen access beyond what the approval already allows.
+
### Example CI workflow
1. The pipeline runs `signtool sign ... /csp "Infisical Key Storage Provider" /kc <signer>`.
@@ -252,6 +272,9 @@ For fully unattended CI, have an Administrator [pre-approve signing](/documentat
The plug-in writes a log to `%ProgramData%\Infisical\ksp.log`. `signtool` itself only shows a short error code, so this log is the best place to see what actually went wrong and how to fix it. For more detail, set `log_level` to `debug`.
<AccordionGroup>
+ <Accordion title="signtool fails immediately and the log you configured is empty">
+ The config file could not be read, so the log path named inside it is unknown too. The reason is written to the default log at `%ProgramData%\Infisical\ksp.log` instead, and it names the setting at fault: an `exclude_scope_fields` entry that is not a signing parameter, an `ip_address` that is not an address, or invalid JSON. A UTF-8 byte order mark counts as invalid JSON, so write the file with `[IO.File]::WriteAllText` rather than `Set-Content -Encoding utf8`.
+ </Accordion>
<Accordion title="signtool says 'Invalid provider specified' right after setup">
Windows has not picked up the new plug-in yet. **Restart the computer once** and try again.
</Accordion>