Skip to content

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

fix(kmip): use RE2 for serial number regex validation

bernie-gd7067ec12ba5
diff --git a/backend/src/ee/services/kmip/kmip-service.ts b/backend/src/ee/services/kmip/kmip-service.ts
index a424033da5..d40ca41e32 100644
--- a/backend/src/ee/services/kmip/kmip-service.ts
+++ b/backend/src/ee/services/kmip/kmip-service.ts
@@ -1,5 +1,6 @@
import { ForbiddenError } from "@casl/ability";
import * as x509 from "@peculiar/x509";
+import RE2 from "re2";
import { ActionProjectType, OrganizationActionScope } from "@app/db/schemas";
import { PgSqlLock } from "@app/keystore/keystore";
@@ -46,14 +47,14 @@ const normalizeSerialNumberCandidates = (raw: string): string[] => {
const candidates = new Set<string>();
const toCanonical = (n: bigint) => n.toString(16).padStart(40, "0");
- if (/^[0-9a-fA-F]+$/.test(value)) {
+ if (new RE2(/^[0-9a-fA-F]+$/).test(value)) {
try {
candidates.add(toCanonical(BigInt(`0x${value}`)));
} catch {
// not a valid hex serial
}
}
- if (/^[0-9]+$/.test(value)) {
+ if (new RE2(/^[0-9]+$/).test(value)) {
try {
candidates.add(toCanonical(BigInt(value)));
} catch {