diff --git a/backend/bdd/features/pki/acme/order.feature b/backend/bdd/features/pki/acme/order.feature index e923b17e7..aed647e47 100644 --- a/backend/bdd/features/pki/acme/order.feature +++ b/backend/bdd/features/pki/acme/order.feature @@ -130,8 +130,9 @@ Feature: Order Examples: Bad Identifier Vluaes | identifier_value | - | 127.0.0.1 | - | 192.168.123.111 | + | 127.0.0.1 | + | 192.168.123.111 | + | 169.254.169.254 | | ../../etc/passwd | Then the value response.status_code should be equal to 400 diff --git a/backend/src/ee/services/pki-acme/pki-acme-schemas.ts b/backend/src/ee/services/pki-acme/pki-acme-schemas.ts index 4c7d6c3c1..baa686e59 100644 --- a/backend/src/ee/services/pki-acme/pki-acme-schemas.ts +++ b/backend/src/ee/services/pki-acme/pki-acme-schemas.ts @@ -84,6 +84,8 @@ export const CreateAcmeAccountResponseSchema = z.object({ orders: z.string().optional() }); +export const ValidDNSIdentifierRegex = /^(?!-)[A-Za-z0-9-]{1,63}(? identifier.type !== AcmeIdentifierType.DNS)) { + throw new AcmeUnsupportedIdentifierError({ message: "Only DNS identifiers are supported" }); + } + if ( + payload.identifiers.some( + (identifier) => + !ValidDNSIdentifierRegex.test(identifier.value) || + isPrivateIp(identifier.value) || + (!getConfig().isDevelopmentMode && identifier.value.toLowerCase() === "localhost") + ) + ) { + throw new AcmeUnsupportedIdentifierError({ message: "Invalid DNS identifier" }); + } + const order = await acmeOrderDAL.transaction(async (tx) => { const account = (await acmeAccountDAL.findByProjectIdAndAccountId(profileId, accountId))!; const createdOrder = await acmeOrderDAL.create(