Self-hosted Docker image uses hardcoded captcha-site-key in frontend despite CAPTCHA_SITE_KEY environment variable
Product
Platform/Access controls/Other
Describe the bug
When running the self-hosted Infisical Docker image, configuring CAPTCHA_SITE_KEY at runtime does not configure the hCaptcha site key used by the frontend.
The Infisical container correctly receives the configured environment variable. For example:
CAPTCHA_SITE_KEY=<valid-hcaptcha-site-key>However, the frontend continues to initialise hCaptcha using the literal placeholder value:
captcha-site-keyThis causes hCaptcha to display:
ERROR for site owner: Invalid site key
Inspecting the network request from the browser confirms that the placeholder is being sent to hCaptcha:
https://api.hcaptcha.com/checksiteconfig?...&host=<infisical-host>&sitekey=captcha-site-key&...Inspecting the running container confirms that the placeholder is embedded inside the compiled frontend JavaScript bundle:
/backend/frontend-build/assets/index-v0-165-6-BXoyH3V2.js:captcha-site-keyAt the same time, inspecting the container environment confirms that the real site key is correctly configured:
CAPTCHA_SITE_KEY=<valid-hcaptcha-site-key>It therefore appears that the frontend's hCaptcha site key is being injected at Docker image build time rather than being configurable at container runtime.
This prevents features requiring hCaptcha, such as password recovery, from working correctly with the standard self-hosted Docker image even when CAPTCHA_SITE_KEY and CAPTCHA_SECRET are correctly supplied to the container.
To Reproduce
Deploy the official self-hosted Infisical Docker image.
Configure valid hCaptcha credentials as environment variables on the Infisical container:
CAPTCHA_SITE_KEY=<valid-hcaptcha-site-key> CAPTCHA_SECRET=<valid-hcaptcha-secret>Confirm that the site key is present inside the running container:
docker inspect infisical \ --format '{{range .Config.Env}}{{println .}}{{end}}' \ | grep -Ei 'CAPTCHA|HCAPTCHA'This correctly returns:
CAPTCHA_SITE_KEY=<valid-hcaptcha-site-key>Navigate to a feature which uses hCaptcha, such as the password recovery page.
The hCaptcha widget displays:
ERROR for site owner: Invalid site keyInspect the hCaptcha
checksiteconfigrequest in the browser's developer tools.Despite the container having a valid
CAPTCHA_SITE_KEY, the request contains:sitekey=captcha-site-keySearch the compiled frontend assets inside the running container:
docker exec infisical sh -c \ 'grep -R -l "captcha-site-key" /backend/frontend-build 2>/dev/null | head'On v0.165.6 this returns:
/backend/frontend-build/assets/index-v0-165-6-BXoyH3V2.jsConfirm the placeholder is embedded in the bundle:
docker exec infisical sh -c \ 'grep -R -o "captcha-site-key" /backend/frontend-build 2>/dev/null | head'This returns:
/backend/frontend-build/assets/index-v0-165-6-BXoyH3V2.js:captcha-site-key
The frontend therefore appears to be using a site key compiled into the Docker image rather than the CAPTCHA_SITE_KEY supplied to the running container.
Expected behavior
When CAPTCHA_SITE_KEY is supplied to the self-hosted Infisical container, the frontend should use that value when initialising hCaptcha.
For example, given:
CAPTCHA_SITE_KEY=<valid-hcaptcha-site-key>the hCaptcha checksiteconfig request should contain:
sitekey=<valid-hcaptcha-site-key>rather than:
sitekey=captcha-site-keyA self-hosted deployment should be able to configure both the hCaptcha site key and secret through runtime configuration/environment variables without requiring a custom build of the Infisical Docker image or modification of the compiled frontend assets.
If CAPTCHA_SITE_KEY is intentionally a build-time-only setting, this should at minimum be clearly documented for self-hosted deployments. However, runtime configuration would be preferable because users of the official pre-built Docker image cannot otherwise provide their own hCaptcha site key.
Screenshots
Deployment Type
Self-hosted
Additional context
Infisical version:
v0.165.6Docker image:
infisical/infisical:v0.165.6Deployment type:
Self-hosted using the official Infisical Docker image.Host OS:
Linux (Ubuntu server)Source: Infisical/infisical