Repository navigation
fix(dev): refuse bad dev auth origins early and constrain the dev CA - #2461
Merged
Merged
Conversation
Development OCC_AUTH_BASE_URL is now checked in server.mjs configuration() with the same rule createFastifyApp applies to the development browser origin (one shared validator in auth/configuration.ts): loopback HTTP(S) or an HTTPS .localhost subdomain, written as an origin. http://x.localhost, https://.localhost and http://localhost:3000/auth now fail at startup as AUTH_BASE_URL_INVALID instead of later with an unrelated error. The development CA written by writeDevelopmentTLS (browser and repository) is now name-constrained to the leaf's DNS names, path length zero, lives as long as the leaf (three months), and its private key is never written: it signs the leaf in memory and is dropped.
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. |
freeqaz
had a problem deploying
to
integration-qa-pr
October 14, 2026 20:54 — with
GitHub Actions
Failure
freeqaz
had a problem deploying
to
integration-qa-pr
October 14, 2026 20:54 — with
GitHub Actions
Failure
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Two low-severity, development-only gaps from a review of the Compose browser proxy (#1750):
docs/reference/settings/development.mdsays a developmentOCC_AUTH_BASE_URLmust be an HTTP(S) origin onlocalhost,127.0.0.1or[::1], or HTTPS on a.localhostsubdomain, with no path, query, fragment or user info.apps/controller/src/server.mjschecked only the hostname, sohttp://x.localhost,https://.localhostandhttp://localhost:3000/authpassedconfiguration()and startup failed later increateFastifyApp(logged as an unrelated startup code). Its message also still said "must identify a loopback host".internal/occdevwriteDevelopmentTLS(browser proxy for Compose and k3d, and the repository broker) had no name constraints, was valid for a year, and left<prefix>-ca.keyon disk although nothing reads it after the leaf is signed. The docs tell developers to trust the browser CA in their browser.Change
apps/controller/src/auth/configuration.ts: one validator,isDevelopmentBrowserOrigin, and the rule textDEVELOPMENT_BROWSER_ORIGIN_RULE. The value must equal its ownURL.origin(so no path, trailing slash, query, fragment, user info or default port), use HTTP(S), and be loopback or HTTPS on a.localhostsubdomain with no empty labels.server.mjsconfiguration()applies it to the normalized developmentOCC_AUTH_BASE_URL, and the error names the setting and the rule. Startup now logsAUTH_BASE_URL_INVALIDbefore reading the Installation.index.tsdevelopmentBrowserOriginuses the same validator.writeDevelopmentTLSnow usesgenerateDevelopmentTLS. The CA carries critical DNS name constraints equal to the leaf's names (a leading*.is stripped), uses path length zero and expires with the leaf after three months. Its private key signs the leaf in memory and is never written. A state directory from an earlierocc dev upkeeps its old key untilocc dev downremoves the directory. A freshocc dev upalways creates a new state directory, so it gets the new CA.Verification
node --test tests/integration/configuration-startup.test.mjs(new test,development OCC_AUTH_BASE_URL must be a loopback origin or an HTTPS localhost subdomain): acceptshttp://127.0.0.1:3000,http://[::1]:3000,http://localhost:3000andhttps://console.occ-dev-example.oce.localhost:8443, and refuses each bad spelling. A realserver.mjswith each of the three reported spellings exits withAUTH_BASE_URL_INVALID. With the oldserver.mjsthe same test fails withDATABASE_CONFIGURATION_INVALID.node --test tests/conformance/occ-api-security.test.mjs: 39/39. The refused browser-origin list now includes the three spellings.go test ./internal/occdev/: pass. The newTestDevelopmentBrowserCAIsNameConstrainedToTheInstallationchecks the constraints, path length and lifetime, that the leaf verifies, and that leaves signed by the same CA key forexample.com, another installation's console, and a sibling host fail withCANotAuthorizedForThisName. The browser and repository tests assert that no CA key file is written.tsc --build(controller), eslint and prettier on the touched files: clean.Risks
Development only. Production startup and the Helm chart are unchanged. A development
OCC_AUTH_BASE_URLwith a path, or HTTP on a.localhostsubdomain, used to fail later anyway; it now fails earlier. The repository broker CA also gets name constraints. Its only name is the exact broker host, and Go, Node, OpenSSL and git all honor critical DNS name constraints.