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
fix(identity-tls-cert-auth): source the client certificate from the TLS-terminating proxy
Vlad Ligaic29efc3032d4
diff --git a/backend/src/services/identity-tls-cert-auth/identity-tls-cert-auth-service.ts b/backend/src/services/identity-tls-cert-auth/identity-tls-cert-auth-service.tsindex 9b2ccc5c27..1b41681f43 100644--- a/backend/src/services/identity-tls-cert-auth/identity-tls-cert-auth-service.ts+++ b/backend/src/services/identity-tls-cert-auth/identity-tls-cert-auth-service.ts@@ -143,6 +143,22 @@ export const identityTlsCertAuthServiceFactory = ({}});+ // Require an end-entity certificate issued by the configured CA, not the CA certificate+ // itself. `.ca` covers certs marked CA:TRUE; the raw comparison also covers a self-signed CA+ // that omits basic constraints.+ const isClientCertACa = clientCertificateX509.ca || clientCertificateX509.raw.equals(caCertificateX509.raw);+ if (isClientCertACa) {+ throw new UnauthorizedError({+ message: "Access denied: a CA certificate cannot be used as a client certificate.",+ detail: {+ reasonCode: "ca_certificate_not_allowed",+ identityId: identity.id,+ orgId: identity.orgId,+ identityName: identity.name+ }+ });+ }+if (new Date(clientCertificateX509.validTo) < new Date()) {throw new UnauthorizedError({message: "Access denied: Certificate has expired.",diff --git a/nginx/default.conf b/nginx/default.confindex 2ef2ff97eb..540a84fc84 100644--- a/nginx/default.conf+++ b/nginx/default.conf@@ -46,6 +46,25 @@ server {proxy_cookie_path / "/; HttpOnly; SameSite=strict";}+ # Identity TLS-cert auth: the client certificate is provided by the TLS-terminating upstream.+ # Exact-match location takes priority over the regex /api block below.+ location = /api/v1/auth/tls-cert-auth/login {+ proxy_set_header X-Real-IP $remote_addr;+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;++ proxy_set_header Host $http_host;+ proxy_set_header X-NginX-Proxy true;++ # Cloud terminates mTLS at the upstream LB; for self-hosted nginx mTLS termination use+ # $ssl_client_escaped_cert instead.+ proxy_set_header X-Identity-Tls-Cert-Auth-Client-Cert $http_x_amzn_mtls_clientcert;++ proxy_pass http://backend:4000;+ proxy_redirect off;++ proxy_cookie_path / "/; HttpOnly; SameSite=strict";+ }+location ~ ^/(api|secret-scanning/webhooks) {proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;@@ -53,6 +72,9 @@ server {proxy_set_header Host $http_host;proxy_set_header X-NginX-Proxy true;+ # This header is populated only by the dedicated TLS-cert-auth location above.+ proxy_set_header X-Identity-Tls-Cert-Auth-Client-Cert "";+proxy_pass http://backend:4000;proxy_redirect off;@@ -96,7 +118,7 @@ server {proxy_set_header X-NginX-Proxy true;# specific for infisical cloud setup, needed for server-side mTLS- proxy_set_header X-SSL-Client-Cert $http_x_amzn_mtls_clientcert+ proxy_set_header X-SSL-Client-Cert $http_x_amzn_mtls_clientcert;proxy_pass http://backend:4000;proxy_redirect off;diff --git a/nginx/default.dev.conf b/nginx/default.dev.confindex 06729210e1..22ca36ef18 100644--- a/nginx/default.dev.conf+++ b/nginx/default.dev.conf@@ -52,6 +52,23 @@ server {proxy_cookie_path / "/; SameSite=strict";}+ # Identity TLS-cert auth: the client certificate is provided by the TLS-terminating proxy.+ # Exact-match location takes priority over the regex /api block below.+ location = /api/v1/auth/tls-cert-auth/login {+ proxy_set_header X-Real-IP $remote_addr;+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;++ proxy_set_header Host $http_host;+ proxy_set_header X-NginX-Proxy true;++ proxy_set_header X-Identity-Tls-Cert-Auth-Client-Cert $ssl_client_escaped_cert;++ proxy_pass http://api;+ proxy_redirect off;++ proxy_cookie_path / "/; SameSite=strict";+ }+location ~ ^/(api|secret-scanning/webhooks) {proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;@@ -59,6 +76,9 @@ server {proxy_set_header Host $http_host;proxy_set_header X-NginX-Proxy true;+ # This header is populated only by the dedicated TLS-cert-auth location above.+ proxy_set_header X-Identity-Tls-Cert-Auth-Client-Cert "";+proxy_pass http://api;proxy_redirect off;