Repository navigation
Description
The container's defaults are looser than its docs and warnings suggest. Each item is small on its own; together they mean a no-flags container accepts a well-known password over plaintext, and the runtime user has passwordless root.
Items
- documentdb-local starts with the well-known default password (Admin100) when none is supplied; --help says it is REQUIRED
- documentdb-local: default TLS_MODE=allowTLS silently accepts plaintext authentication
-
documentdb-local: TLS_MODE=disabled still accepts TLS, behaves like allowTLS(won't fix, see comments) - documentdb-local: empty TLS_MODE env var silently becomes allowTLS and accepts plaintext
- documentdb-local: runtime user
documentdbhas passwordless root (NOPASSWD: ALL)
1. documentdb-local starts with the well-known default password (Admin100) when none is supplied; --help says it is REQUIRED
Starting documentdb-local without --password/PASSWORD does not fail. The container comes up healthy and accepts Admin100 for whatever username is in effect (default_user, or a custom --username).
Why
documentdb_local_settings.sh:27gives PASSWORD a table default ofAdmin100; the pass atemulator_entrypoint.sh:343-351applies it to any unset setting.- The
PASSWORD is requiredcheck (emulator_entrypoint.sh:490-493) can therefore never fire. USING_DEFAULT_CREDS(:342-345) only drives a warning (:503-531), andDOCUMENTDB_ALLOW_DEFAULT_PASSWORD=truesuppresses it entirely, so the riskiest configuration is the quietest.--helpstill says--password ... REQUIRED.(:165-166), so docs and behavior disagree.- The warning banner prints both the username and password lines unconditionally (
:510-511), so it claims--usernamewas not set even when it was. In the imageUSERNAMEis always set anyway (Dockerfile_documentdb_local:136), so that line is never accurate.
Repro
docker run -d IMG --username myadmin # no password
#### mongosh with myadmin / Admin100 succeeds
Suggested fix
- If PASSWORD is not explicit, exit 1; keep
DOCUMENTDB_ALLOW_DEFAULT_PASSWORD=trueas the only way to getAdmin100, and still print a one-line warning. - Make the banner list only what actually defaulted.
- Keep
--helpsaying REQUIRED; mention the opt-in there. - Update scripts that rely on the default (e.g.
documentdb-local/functional-tests/scripts/run-functional-tests.sh) and add a test underdocumentdb-local/scripts/documentdb_local_tests/.
The entrypoint comment at :323 already says a future major version will refuse to start; this is a request to schedule that. It's a breaking change for anyone relying on the defaults, so a release-note callout is warranted. Related: #236 (closed, same ask, no fix landed), #685.
2. documentdb-local: default TLS_MODE=allowTLS silently accepts plaintext authentication
The image defaults to TLS_MODE=allowTLS (packaging/gateway/docker/Dockerfile_documentdb_local:143, documentdb-local/scripts/documentdb_local_settings.sh:37). The entrypoint maps every mode except requireTLS to EnforceTls=false (emulator_entrypoint.sh:1226-1232), and the gateway then accepts non-TLS clients (runtime/v2/listener.rs:125-127, runtime/v1.rs:308-311). So a client that omits --tls authenticates over SCRAM in cleartext, with no log line about it. test_image.py:608 and run_documentdb_local_tls_tests.sh:86 assert this behaviour.
Not claiming a bug, since allowTLS does what it says. But the entrypoint already warns loudly for built-in default credentials (emulator_entrypoint.sh:503-531) and for disabled (line 1231), and nothing warns about plaintext acceptance in the default mode. A no-flags container with the published port accepts the well-known Admin100 credential over an unencrypted connection.
Options:
- Default to
requireTLS(breaking: tests, healthcheck, banner, quickstart). - Keep
allowTLS, print a one-time stderr warning at startup whenenforceTls=false, pointing toTLS_MODE=requireTLS. - Keep as-is and document it in the quickstart.
Option 2 is the cheap one; a test next to test_emulator_entrypoint.py:2303 would cover it. Related: #688.
3. documentdb-local: TLS_MODE=disabled still accepts TLS, behaves like allowTLS
--tlsMode disabled / TLS_MODE=disabled doesn't turn TLS off. The entrypoint only writes EnforceTls=false (documentdb-local/scripts/emulator_entrypoint.sh:1226-1232), and with that set the gateway sniffs each connection and accepts both TLS and plaintext (pg_documentdb_gw/documentdb_gateway_core/src/runtime/v2/listener.rs:126-127, runtime/v1.rs:308-311). There is no plain-only path, so disabled is the same as allowTLS. Only requireTLS is distinct.
Main already prints a stderr warning (emulator_entrypoint.sh:1231) and --help says so (:246), but the enum still lists disabled (documentdb_local_settings.sh:37), the container starts and reports ready, and the TLS port stays open. Anyone using disabled to terminate TLS at a sidecar or satisfy a no-in-process-TLS policy doesn't get it.
Suggested fix: reject disabled at startup (non-zero exit, name allowTLS/requireTLS), drop it from the enum and --help, and update the entrypoint test that pins the current behaviour. Or add a real plain-only listener in the gateway, which is a bigger change.
A wrong mode that starts and gets ignored is worse than refusing to start.
4. documentdb-local: empty TLS_MODE env var silently becomes allowTLS and accepts plaintext
An empty TLS_MODE (e.g. -e TLS_MODE=, or a compose/env-file variable that expands to nothing) is treated as unset and replaced with the table default allowTLS. The container starts, exits 0, logs Setting TLS mode to 'allowTLS'..., and accepts plaintext clients. An operator who meant requireTLS gets no signal.
The CLI path is fine: --tlsMode with a missing or empty value fails fast (documentdb-local/scripts/emulator_entrypoint.sh:308-309).
The env path is not:
emulator_entrypoint.sh:327tests[ -n "${!_setting_var:-}" ], so empty falls to theelifand exports the defaultallowTLS(documentdb_local_settings.sh:37).- The enum validator skips empty values (
:371-372) and would see a validallowTLSanyway. docker run -e TLS_MODE=overrides the DockerfileENV TLS_MODE="allowTLS"(packaging/gateway/docker/Dockerfile_documentdb_local:143) with empty.
Repro: docker run -e TLS_MODE= ... <image> --username u --password p, then connect with tls=false: it connects.
Fix: before the default pass, reject a set-but-empty TLS_MODE:
if [ "${TLS_MODE+set}" = set ] && [ -z "$TLS_MODE" ]; then
echo "TLS_MODE must not be empty: disabled, allowTLS, or requireTLS." >&2; exit 1
fiOnly for TLS_MODE: INIT_DATA, CERT_PATH and KEY_FILE are legitimately empty. Add a test next to the --toast-compression missing-value test in test_emulator_entrypoint.py.
5. documentdb-local: runtime user documentdb has passwordless root (NOPASSWD: ALL)
The documentdb-local image adds documentdb to group sudo and ships %sudo ALL=(ALL:ALL) NOPASSWD: ALL, and the final stage runs as USER documentdb. Anything running as that user is container-root with no password.
Defense-in-depth, not a container escape. It matters because the image can't honestly be called unprivileged, and RCE in the gateway or a mounted --init-data-path script gets root for free.
Code (main):
packaging/gateway/docker/Dockerfile_documentdb_local:88-89creates the user and writes the sudoers rule;:182USER documentdb- Build steps use it after
USER(:183-250, e.g.sudo chown,sudo tee /version.txt) - Runtime:
documentdb-local/scripts/emulator_entrypoint.sh:472-474(log dir),:577(mkdir data dir),:603/:607(recursive chown/chmod ofDATA_PATH),:611 scripts/start_oss_server.sh:393-394(/var/run/postgresql)
Repro: docker exec -u documentdb <container> sudo -n id returns uid=0(root).
Fix: a targeted sudoers rule only helps if it wraps a fixed root-owned helper. Allowing raw chown/chmod/bash is still root-equivalent. The cleaner route is the official postgres image pattern: start as root, let the entrypoint do the ownership fix-ups, then exec gosu/runuser to documentdb. Move the build-time RUN sudo ... steps ahead of USER documentdb. Add a test asserting sudo -n id fails as documentdb, and update the entrypoint tests that stub sudo.
Related: #688 (security-posture coverage gaps for the image defaults).
Activity
guanzhousongmicrosoft commentedon Oct 5, 2026
Plan: items 1, 3 and 4 go in 1.0-RC2. Items 2 (warn about the default allowTLS; needs a decision) and 5 (drop passwordless sudo; needs an entrypoint rework) go in 1.0.
guanzhousongmicrosoft commentedon Oct 5, 2026
Closing item 3 as won't fix.
disabledis MongoDB's no-TLS mode and documentdb-local has accepted it since v0.114-0. Plain clients already connect under it; the only difference from MongoDB is that TLS clients get in too. Rejecting it would break working configs without making anything safer, so it stays, with its startup warning and--helpnote.A real plain-only mode (for TLS terminated at a sidecar) would be a gateway listener change. Open a separate issue if someone needs it.
guanzhousongmicrosoft commentedon Oct 6, 2026
1.0 blockers: items 1 and 4. The fix is in review. Items 2 and 5 don't block 1.0.
Merged PR 2342079: documentdb-local: require a password, reject an em…
documentdb-triage-tool commentedon Oct 28, 2026
👋 @guanzhousongmicrosoft — this issue has been assigned for 22 days with no activity. Is it still in progress? If you've made progress, please leave a quick update. Otherwise it'll be flagged for re-assignment at the next triage meeting.
documentdb-triage-tool commentedon Nov 11, 2026
👋 @guanzhousongmicrosoft — this issue has been assigned for 14 days with no activity. Is it still in progress? If you've made progress, please leave a quick update. Otherwise it'll be flagged for re-assignment at the next triage meeting.
guanzhousongmicrosoft commentedon Nov 23, 2026
Items 1 and 4 are fixed on main (cf53d26): documentdb-local refuses to start without a password unless
DOCUMENTDB_ALLOW_DEFAULT_PASSWORD=true, and rejects an emptyTLS_MODE. Items 2 and 5 are still open.