Skip to content

fix(core): Refuse default superadmin credentials in production - #4718

Merged
michaelbromley merged 2 commits into
vendurehq:minorfrom
grolmus:fix/oss-490-default-superadmin-credentials-guard
Jun 29, 2026
Merged

fix(core): Refuse default superadmin credentials in production#4718
michaelbromley merged 2 commits into
vendurehq:minorfrom
grolmus:fix/oss-490-default-superadmin-credentials-guard

Conversation

@grolmus

@grolmus grolmus commented May 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

Vendure ships with the well-known defaults superadmin / superadmin for 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 override authOptions.superadminCredentials.

This PR adds a bootstrap-time check that:

  • Refuses to start the server when NODE_ENV === 'production' and the password matches the default constant from @vendure/common. The default superadmin identifier is intentionally allowed — only a default password is treated as insecure.
  • Logs a prominent Logger.warn with remediation hints in development / staging / any other non-test environment.
  • Stays silent in 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 superadminCredentials from environment variables, which is the same pattern most starters already use.

Scope

  • No schema migration, no public API change.
  • The well-known constants in @vendure/common are kept as-is — they are still exported because plugins and the e2e/testing layer rely on them.
  • A more invasive follow-up (auto-generated random password on first init, forced password change on first login) is intentionally left for a future major change. This PR is the minimum-blast-radius patch that closes the critical concern.
  • Targets minor: refusing to start in production on a default password is a behavioural change, so it ships in a minor release rather than a patch.

Changes

  • New helper packages/core/src/service/helpers/utils/check-superadmin-credentials.ts containing the pure check (testable, no DI).
  • AdministratorService.ensureSuperAdminExists now calls the helper before creating / reconciling the superadmin user.
  • 7 new unit tests in the paired spec file covering production / development / staging / test / safe-credentials paths.

Test plan

  • vitest run service/helpers/utils/check-superadmin-credentials.spec.ts — 7/7 pass
  • Full @vendure/core unit suite (vitest run) — 819/819 pass; no existing tests regressed
  • Manual smoke: boot dev server with default config (NODE_ENV unset) → expect a single Logger.warn line about the default password, server starts normally
  • Manual smoke: boot with NODE_ENV=production and default password → expect bootstrap to throw [Vendure] Refusing to start: Default superadmin password is configured…
  • Manual smoke: boot with NODE_ENV=production and explicit override → silent, server starts normally

Notes

  • Reported privately via responsible disclosure (internal Linear OSS-490 — Pratik Karan, 2026-04-03). No public GitHub issue exists.
  • Only the default password is treated as insecure. Using the well-known superadmin identifier with a strong, non-default password is fully supported (per maintainer review). The guard cannot detect weak-but-custom passwords — enforcing "non-default" is the enforceable boundary; "strong" remains the operator's responsibility.

View in Codesmith
Need help on this PR? Tag @codesmith with what you need.

  • Let Codesmith autofix CI failures and bot reviews

@vercel

vercel Bot commented May 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
vendure-storybook Ready Ready Preview, Comment Jun 25, 2026 12:54pm

Request Review

@coderabbitai

coderabbitai Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

This pull request adds a security validation utility to detect and prevent usage of well-known default superadmin credentials at application bootstrap. The utility function checkSuperadminCredentials compares provided identifier and password against shipped defaults, then either throws an error in production (halting startup), logs a warning in development/staging, or remains silent in test environments. The check is integrated into AdministratorService.ensureSuperAdminExists() and includes remediation guidance to configure credentials via authOptions.superadminCredentials. A comprehensive test suite validates the environment-specific behavior across all code paths.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding a production-time guard against default superadmin credentials.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description covers the summary, issue context, scope, and test plan, though it doesn’t follow the template sections exactly.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@michaelbromley michaelbromley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Martin, this is generally a good idea but a couple of changes needed:

  1. We should not disallow the superadmin identifier. It’s totally fine to use that, as long as there’s a non-default, strong password.
  2. This must target the minor branch. It is a breaking change in behaviour.

grolmus added 2 commits June 25, 2026 14:37
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).
…sword

Address review feedback: the well-known superadmin identifier is fine to
use as long as the password is non-default, so the bootstrap guard now
checks only the password against the default. Refusing to start in
production on a default password is a behavioural change, hence targeted
at the minor branch.

Relates to OSS-490
@grolmus
grolmus force-pushed the fix/oss-490-default-superadmin-credentials-guard branch from e4eaad6 to d56c118 Compare June 25, 2026 12:52
@vendure-developer-hub

vendure-developer-hub Bot commented Jun 25, 2026

Copy link
Copy Markdown

Docs previewPR merged

@grolmus
grolmus changed the base branch from master to minor June 25, 2026 12:52
@grolmus

grolmus commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator Author

all done

@grolmus
grolmus requested a review from michaelbromley June 25, 2026 13:01
@michaelbromley
michaelbromley merged commit f7aa6af into vendurehq:minor Jun 29, 2026
27 of 28 checks passed
@vendure-ci-automation-bot vendure-ci-automation-bot Bot locked and limited conversation to collaborators Jun 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants