Repository navigation
Description
Summary
The native installer and companion administrative tools currently have several inconsistent input and credential semantics:
publicpasses public username prevalidation but fails later during PostgreSQL role creation.- Passwords containing characters prohibited by client SCRAM/SASL preparation are accepted during setup, producing unusable credentials.
- Password files have surprising and inconsistent line-ending behavior:
- a final LF is silently removed;
- CRLF leaves an unusable credential;
- embedded newlines produce unusable credentials;
- an LF-only file reaches setup and fails as an empty password.
- The reserved-role policy is not represented consistently across every public username validator.
Tested revision and environment
- Commit:
9765074529b9f09ba05fc86a3cf7c5bb5caaa6eb - Architecture: AMD64
- OS: Ubuntu 24.04
- PostgreSQL: 18
- Package manager: APT
- Privileged systemd-as-PID-1 E2E environment
- Authentication client: Python 3.12 with PyMongo
Reproduction
1. Reserved PostgreSQL role passes prevalidation
printf '%s' 'ValidPass123!' >/root/pw
chmod 0600 /root/pw
sh install.sh \
--yes \
--admin-user public \
--admin-password-file /root/pw \
--accept-external-listen2. Client-prohibited password character
Create a password file containing a Unicode code point rejected by the client's SASLprep implementation, for example an emoji together with otherwise valid password characters:
printf '%s' 'Valid🧪Pass123!' >/root/pw
chmod 0600 /root/pw
sh install.sh \
--yes \
--admin-user admin \
--admin-password-file /root/pw \
--accept-external-listenThen authenticate with PyMongo using the exact same Unicode string.
3. Password-file line endings
Run clean installations using these fixtures:
printf 'ValidPass123!\n' >/root/trailing-lf
printf 'ValidPass123!\r\n' >/root/crlf
printf 'ValidPass123!\nsecond' >/root/multiline
printf '\n' >/root/lf-only
chmod 0600 /root/trailing-lf /root/crlf /root/multiline /root/lf-onlyActual behavior
-
publicpasses installer validation, proceeds through cluster initialization and extension creation, and then fails at:ERROR: role name "public" is reserved -
A subsequent attempt with another user can conflict with the interrupted setup state.
-
The Unicode password installation completes successfully, but PyMongo authentication fails before reaching the server:
ValueError: SASLprep: failed prohibited character check -
A file ending in LF installs successfully, but the exact file bytes do not authenticate; authentication succeeds only after removing the LF.
-
CRLF and multi-line files install successfully but produce credentials unusable by the client.
-
An LF-only file proceeds to setup and then fails because the resulting password is empty.
Expected behavior
All public entry points should enforce one deterministic username and password-file contract before performing persistent setup work.
Recommended password-file contract:
- one logical password line;
- at most one optional terminal LF, which is removed;
- CR characters and embedded LF characters are rejected;
- an empty value after normalization is rejected;
- passwords incompatible with the supported SCRAM/SASL preparation rules are rejected before user creation.
Impact
- Invalid input can fail only after expensive and partially mutating setup.
- Users can receive a successful installation with credentials that standard clients cannot use.
- Password bytes may differ from what the operator supplied without an explicit contract.
- Different entry points can accept and reject different reserved identities.
- Recovery after late username failure is more complicated than a normal validation error.
Acceptance criteria
-
publicand other PostgreSQL-reserved role names are rejected during prevalidation. - Dry-run and live setup apply the same side-effect-free username validation.
-
install.sh,documentdb-setup,documentdb-gateway-admin, and the container username validator use the same case-insensitive reserved-name/prefix policy. - Passwords that supported clients cannot pass through SCRAM/SASL preparation are rejected before mutation with an actionable error.
- The password-file line-ending contract is explicitly documented.
- A single optional terminal LF is handled consistently.
- CRLF, embedded newlines, and LF-only/empty values are rejected before setup begins.
- Regression tests cover every public username validator and every listed password fixture.
- Failed validation leaves no cluster, user, listener, or misleading completed receipt state.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTodo
Activity
documentdb-triage-tool commentedon Sep 2, 2026
🤖 Auto-triaged by documentdb-triage-tool.
Applied:
packaging,bugProject fields suggested: Component
packaging· PriorityP2· EffortM· StatusTriageConfidence: 0.82 (llm)
Reasoning
LLM: Multiple input/credential validation inconsistencies in the native installer (reserved usernames, prohibited password characters, line-ending handling) that result in unusable credentials or failed setups, but no data loss or security exposure.
If a label is wrong, remove it manually and ping
@patty-chowso the rules can be tuned. The bot will not re-label items that already have component labels.guanzhousongmicrosoft commentedon Oct 5, 2026
One more installer-side gap in the same area, not covered above:
Problem. The interactive username prompt enforces
^[A-Za-z_][A-Za-z0-9_-]*$(documentdb-local/scripts/documentdb-setup.sh:4440). The--admin-userflag path only runs the reserved-prefix check (documentdb-setup.sh:1908-1921,documentdb-gateway-admin.sh:551-556,documentdb-tools-lib.sh:775). No shape or length check, so:postgres,select,foo.bar, names with spaces,caféand-rfare accepted as admin roles. A leading-is a footgun for any downstreamcmd $USER.--admin-user --yestakes--yesas the name (documentdb-setup.sh:3878-3881);--pg-version abcis only rejected late (:3914-3916) as "PostgreSQL abc not found".Fix. One shared helper in
documentdb-tools-lib.sh: apply the prompt's regex plus a 63-byte cap (LC_ALL=C), call it fromvalidate_required_argumentsandcreate-user, before any dry-run early return. Reject option-lookalike values (leading-) for--admin-user/--pg-versionand require digits for--pg-versionat parse time. Add cases todocumentdb_local_tests.guanzhousongmicrosoft commentedon Oct 5, 2026
Follow-up from review: the built-in role names are now listed in four places.
pg_documentdb/include/utils/role_utils.h(IS_NATIVE_BUILTIN_ROLE) is the source of truth;documentdb-local/scripts/documentdb-tools-lib.shandpackaging/install.shcarry copies kept in sync by a test;pg_documentdb_gw/documentdb_tests/src/utils/rbac_utils.rshas another.Longer term, generate them from one source instead: a shared definitions file that the C code includes, plus a build step that writes the shell lists. install.sh can embed the generated list, since it runs before any package exists. This touches the backend, the deb/rpm builds and the gateway tests, so it is not part of the packaging fix for this issue.
guanzhousongmicrosoft commentedon Oct 6, 2026
1.0 blocker. The fix is in review.
Merged PR 2345110: Ensure passwords pass SASL prep before creating a …
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
Most of this is on main: a92856b rejects reserved names such as
publicand applies the 63-byte, name-shape and one-line password-file rules, and d7637dd makes the backend reject passwords that fail SASLprep. #833 relaxes the tools' password rule to UTF-8 (#765). Still open:documentdb-register-gatewaydoesn't pre-validate the admin name, and the built-in role list lives in several places.