fix(core): Refuse default superadmin credentials in production#4718
fix(core): Refuse default superadmin credentials in production#4718grolmus wants to merge 1 commit into
Conversation
Vendure shipped with hardcoded default `superadmin` / `superadmin` credentials and no built-in guard against using them in production. Add a bootstrap-time check in `AdministratorService.ensureSuperAdminExists` that inspects `authOptions.superadminCredentials` against the well-known defaults from `@vendure/common`. The check: - throws (refusing to start) when `NODE_ENV === 'production'` and either the identifier or the password matches the default; - logs a `Logger.warn` with remediation hints in development / staging / any other non-test environment; - stays silent in `NODE_ENV === 'test'` to keep the test runner output clean (the e2e suite uses the defaults by design). The check function is extracted to `helpers/utils/check-superadmin-credentials.ts` and covered by unit tests. Existing 819 core unit tests still pass; no schema or public-API change. Reported privately via responsible disclosure (Linear OSS-490).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis pull request adds a security validation utility to detect and prevent usage of well-known default superadmin credentials at application bootstrap. The utility function 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Vendure ships with the well-known defaults
superadmin/superadminfor the initial admin user and has no built-in guard against running with them in production. This is a hard-coded-credentials issue (CWE-798): anyone with network access to a vanilla 3.6.x deployment can log in as superadmin if the operator did not overrideauthOptions.superadminCredentials.This PR adds a bootstrap-time check that:
NODE_ENV === 'production'and either the identifier or the password matches the default constants from@vendure/common.Logger.warnwith remediation hints in development / staging / any other non-test environment.NODE_ENV === 'test'so the existing e2e suite (which uses the defaults by design) keeps a clean output.The remediation hint points operators at wiring
superadminCredentialsfrom environment variables, which is the same pattern most starters already use.Scope
@vendure/commonare kept as-is — they are still exported because plugins and the e2e/testing layer rely on them.minor/majorchange. This PR is the minimum-blast-radius patch that closes the critical concern.Changes
packages/core/src/service/helpers/utils/check-superadmin-credentials.tscontaining the pure check (testable, no DI).AdministratorService.ensureSuperAdminExistsnow calls the helper before creating / reconciling the superadmin user.Test plan
vitest run service/helpers/utils/check-superadmin-credentials.spec.ts— 7/7 pass@vendure/coreunit suite (vitest run) — 819/819 pass; no existing tests regressedLogger.warnline about default credentials, server starts normallyNODE_ENV=productionand default config → expect bootstrap to throw[Vendure] Refusing to start: Default superadmin credentials are configured…NODE_ENV=productionand explicit override → silent, server starts normallyNotes
superadmin / weak-but-not-defaultthrough, which still keeps a well-known username paired with a weak password — same exploit class.Need help on this PR? Tag
@codesmithwith what you need.