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
docs
Daniel87987d645f42
diff --git a/docs/documentation/platform/secret-validation-rules.mdx b/docs/documentation/platform/secret-validation-rules.mdxindex 3075d46468..a1fb81392f 100644--- a/docs/documentation/platform/secret-validation-rules.mdx+++ b/docs/documentation/platform/secret-validation-rules.mdx@@ -4,34 +4,66 @@ sidebarTitle: "Secret Validation Rules"description: "Enforce naming conventions, format requirements, and content policies on secrets."----Secret Validation Rules let you define constraints that secrets must satisfy before they can be created or updated. This helps teams enforce consistent naming conventions, prevent weak or malformed values, and maintain compliance standards across environments — all automatically at write time.+Secret Validation Rules let you define constraints that secrets must satisfy before they can be created, updated, or generated. This helps teams enforce consistent naming conventions, prevent weak or malformed values, and maintain compliance standards across environments — all automatically at write time.-For example, you can require that all secret keys in production follow `UPPER_SNAKE_CASE`, that values meet a minimum length, or that database connection strings always start with a specific prefix.+For example, you can require that all secret keys in production follow `UPPER_SNAKE_CASE`, that values meet a minimum length, that database connection strings always start with a specific prefix, or that passwords generated by a dynamic secret or rotation always match a particular pattern.+## Rule Types++Infisical supports three rule types, each targeting a different kind of secret:++- **Static Secrets** — applied when a user-managed secret is created or updated.+- **Dynamic Secrets** — applied to the credentials generated when a dynamic secret lease is issued, for selected dynamic secret providers.+- **Secret Rotations** — applied to the credentials generated on each rotation, for selected rotation providers.++For dynamic-secret and rotation rules, you must select one or more **providers** the rule applies to. Currently supported providers:++| Rule Type | Supported Providers |+|---|---|+| Dynamic Secrets | SQL Database (PostgreSQL, MySQL, Oracle, Microsoft SQL Server), Milvus |+| Secret Rotations | PostgreSQL Credentials |++<Note>+ When a dynamic-secret or rotation rule covers a provider, any user-configured **password configuration / password requirements** on that dynamic secret or rotation are ignored — the rule's constraints take precedence. The UI surfaces a warning in the affected forms when this is the case.+</Note>+## How It Works-When a secret is created or updated, Infisical checks it against all active validation rules whose scope (environment and folder path) matches the secret's location. If any constraint is violated, the secret is rejected and an error is thrown. When a secret is rejected, the actor will see an error describing which rule and constraint was violated.+### Static Secrets++When a static secret is created or updated, Infisical checks it against all active validation rules whose scope (environment and folder path) matches the secret's location. If any constraint is violated, the secret is rejected and an error is thrown describing which rule and constraint was violated.<Note>- Validation rules are enforced on mutations only (such as create or update events). Existing secrets that were created before a rule was added are not retroactively validated.+ Static-secret validation rules are enforced on mutations only (create or update). Existing secrets that were created before a rule was added are not retroactively validated.</Note>+### Dynamic Secrets and Secret Rotations++For dynamic secrets and secret rotations, validation rules drive the **generation** of credentials rather than rejecting input. When a lease is issued (dynamic secret) or credentials are rotated (rotation), Infisical generates a password that satisfies the matching rule's constraints, replacing the default password generation logic.++If the rule has a **Regex Pattern** constraint, the password is generated directly from that pattern, and **min/max length constraints are ignored** for that rule. To enforce length when using a regex, express it inside the pattern itself (e.g. `[A-Z0-9]{16,24}`).++If the rule's constraints are statically infeasible (e.g. an invalid regex, or a min length larger than the max), the rule is rejected at save time so the issue surfaces immediately rather than at lease/rotation time.+### Constraint Types-Each rule contains one or more constraints. A constraint specifies what to check (the secret key or value) and how to check it.+Each rule contains one or more constraints. A constraint specifies what to check and how to check it.++| Constraint | Description | Example | Static Secrets | Dynamic Secrets | Secret Rotations |+|---|---|---|---|---|---|+| **Min Length** | Target must be at least N characters | At least 8 characters | ✓ | ✓ | ✓ |+| **Max Length** | Target must be at most N characters | At most 64 characters | ✓ | ✓ | ✓ |+| **Regex Pattern** | Target must match a regular expression | `^[A-Z][A-Z0-9_]*$` | ✓ | ✓ | ✓ |+| **Required Prefix** | Target must start with specific text | `https://` | ✓ | ✓ | ✓ |+| **Required Suffix** | Target must end with specific text | `_SECRET` | ✓ | ✓ | ✓ |+| **Prevent Value Reuse** | New value must not match any of the last N versions | Last 10 versions | ✓ | — | — |-| Constraint | Description | Example |-|---|---|---|-| **Min Length** | The target must be at least N characters long | Value must be at least 8 characters |-| **Max Length** | The target must be at most N characters long | Key must be at most 64 characters |-| **Regex Pattern** | The target must match a regular expression | Key must match `^[A-Z][A-Z0-9_]*$` |-| **Required Prefix** | The target must start with specific text | Value must start with `https://` |-| **Required Suffix** | The target must end with specific text | Key must end with `_SECRET` |-| **Prevent Value Reuse** | The new value must not match any of the last N versions | Value must not match the last 10 versions |+**Applies To** target by rule type:-Each constraint _(except Prevent Value Reuse)_ can be applied to either the secret key or the secret value. **Prevent Value Reuse** applies only to the secret value.+- **Static Secrets** — each constraint applies to the secret **key** or **value**. *Prevent Value Reuse* only applies to the value.+- **Dynamic Secrets** and **Secret Rotations** — constraints apply to the **generated password**.### Scoping Rules@@ -39,8 +71,9 @@ Every rule is scoped to control where it applies:- **Environment**: Restrict the rule to a specific environment (e.g., `production`), or apply it to all environments.- **Folder Path**: Restrict the rule to a specific folder path. Supports glob patterns (e.g., `/**` for all paths, `/services/*` for immediate subfolders of `/services`).+- **Providers** (dynamic-secret and rotation rules only): One or more providers the rule applies to. A rule fires only when the dynamic secret / rotation in scope also matches one of the selected providers.-This means you can have different validation standards for different parts of your project. For instance, you might enforce stricter naming in production while keeping development more flexible.+This means you can have different validation standards for different parts of your project. For instance, you might enforce stricter naming in production while keeping development more flexible, or require longer generated passwords for rotations on production databases.## Creating a Rule@@ -62,15 +95,16 @@ This means you can have different validation standards for different parts of yo- **Name** — A descriptive name (e.g., "Production key naming convention").- **Description** (optional) — A brief explanation of what the rule enforces and why.- - **Rule Type** — Currently supports **Static Secrets**.+ - **Rule Type** — **Static Secrets**, **Dynamic Secrets**, or **Secret Rotations**.+ - **Providers** (dynamic-secret and rotation rules only) — Select one or more providers the rule applies to.- **Environment** — Choose a specific environment or "All Environments".- **Folder Path** — The path scope, supporting glob patterns (e.g., `/**`).**Constraints**- Click **Add Constraint** and choose from the available constraint types. For each constraint, select whether it applies to the secret **key** or **value**, then provide the constraint parameter (length, pattern, prefix, suffix, or number of previous versions).- You can add multiple constraints to a single rule. All constraints must pass for a secret to be accepted.+ Click **Add Constraint** and choose from the available constraint types. For static-secret rules, select whether each constraint applies to the secret **key** or **value**. For dynamic-secret and rotation rules, constraints apply to the **generated password**, then provide the constraint parameter (length, pattern, prefix, or suffix).+ You can add multiple constraints to a single rule. All constraints must be satisfied — for static secrets the value/key must satisfy them, and for dynamic/rotation rules the generated password is built to satisfy them.@@ -83,10 +117,12 @@ This means you can have different validation standards for different parts of yo## Overlapping Rules-Infisical prevents you from creating rules that would conflict with each other. If two rules apply to the same scope (overlapping environment and folder path) and share a constraint of the same type targeting the same field (key or value), the second rule will be rejected.+Infisical prevents you from creating rules that would conflict with each other. If two rules apply to the same scope (overlapping environment and folder path) and share a constraint of the same type targeting the same field, the second rule will be rejected.For example, you cannot have two separate "Regex Pattern on key" constraints in overlapping scopes, as they could contradict each other. Instead, combine the patterns into a single rule.+For dynamic-secret and rotation rules, two rules also conflict only if their selected **provider sets intersect**. For example, a Postgres-only rotation rule on `/db/*` and a separate Postgres rotation rule on `/**` overlap on Postgres + the path glob, and the second one would be rejected. A Milvus-only rule on the same path would not conflict with a Postgres rule, because the providers don't overlap.+## Example Use Cases<AccordionGroup>@@ -129,4 +165,21 @@ For example, you cannot have two separate "Regex Pattern on key" constraints inWhen a secret is updated, its new value is validated against the specified number of prior versions. This is useful for enforcing rotation policies and ensuring that secrets are not recycled.</Accordion>++ <Accordion title="Generate strong passwords for SQL dynamic secrets">+ Create a **Dynamic Secrets** rule scoped to all environments and `/**`, with `SQL Database` selected as a provider:++ - **Min Length**: `24`+ - **Required Prefix**: `INF_`++ Every SQL dynamic-secret lease issued in the project will now produce a password that is at least 24 characters long and starts with `INF_`. The password configuration on individual SQL dynamic secrets is ignored while the rule is active.+ </Accordion>++ <Accordion title="Pattern-based passwords for Postgres rotations">+ Create a **Secret Rotations** rule scoped to the `production` environment, with `PostgreSQL Credentials` selected as a provider:++ - **Regex Pattern**: `^[A-Z][A-Za-z0-9]{19,29}$`++ Postgres rotations in production will now produce passwords that start with an uppercase letter and are 20–30 characters of mixed-case alphanumerics. Because a regex is set, separate min/max length constraints would be ignored — express the length window inside the pattern instead.+ </Accordion></AccordionGroup>