Repository navigation
Description
Summary
documentdb_api.create_user() accepts user names longer than PostgreSQL's 63-byte identifier limit. PostgreSQL silently truncates the backing role name, while DocumentDB continues to report setup or user creation as successful.
As a result, authentication with the requested full user name fails, while authentication with the first 63 bytes succeeds.
This focused backend issue is also needed as the OSS changelog reference for the fix.
Tested revision and environment
- Commit:
9765074529b9f09ba05fc86a3cf7c5bb5caaa6eb - Architecture: AMD64
- OS: Ubuntu 24.04
- PostgreSQL: 18
- DocumentDB package version used by the E2E environment:
0.116.0 - Reproduced through the native installer and the authoritative
documentdb_api.create_user()path
Reproduction
Create a 64-byte ASCII user directly through the backend API:
user64="$(printf 'a%.0s' $(seq 1 64))"
psql -d postgres -v user64="$user64" <<'SQL'
SELECT documentdb_api.create_user(
format(
'{"createUser":"%s","pwd":"test_password","roles":[{"role":"readAnyDatabase","db":"admin"}],"$db":"admin"}',
:'user64'
)::documentdb_core.bson
);
SQLInspect the resulting PostgreSQL role:
SELECT rolname, octet_length(rolname)
FROM pg_roles
WHERE rolname LIKE 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa%';The same result can be observed through the native installer by supplying 64- or 100-byte alphabetic values as --admin-user.
Actual behavior
create_user()reports success.- Setup completes and services are reported healthy.
- The underlying PostgreSQL role contains only the first 63 bytes.
- Authentication with the requested 64-byte value fails with
AuthenticationFailed. - Authentication with the first 63 bytes succeeds.
- No error or warning identifies the truncation.
Expected behavior
create_user() should reject user names whose UTF-8 byte length is greater than 63 before attempting PostgreSQL role creation.
A rejected request must not leave a truncated role or other partial user state.
Impact
This is silent identity corruption:
- successful setup produces credentials that do not work as displayed;
- a different, truncated identity unexpectedly becomes valid;
- all callers are affected, including direct SQL/API callers and administrative scripts;
- shell-only validation cannot protect callers that invoke
create_user()directly.
Acceptance criteria
- A 63-byte ASCII user name remains accepted.
- A 64-byte or longer user name is rejected by
documentdb_api.create_user()with a stable bad-value/invalid-name error. - The check uses UTF-8 byte length, matching PostgreSQL identifier semantics.
- Rejection occurs before
CREATE ROLEor other persistent mutation. - No truncated PostgreSQL role remains after rejection.
- Direct API callers and all shell entry points receive consistent behavior.
- Backend regression coverage verifies 63-byte acceptance, 64-byte rejection, and absence of the truncated role.
- The regression is validated on supported PostgreSQL 15, 16, 17, and 18 builds.
Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fieldsDone
Activity
documentdb-triage-tool commentedon Sep 2, 2026
🤖 Auto-triaged by documentdb-triage-tool.
Applied:
write-operations,bug,performanceProject fields suggested: Component
commands· PriorityP0· EffortS· StatusTriageConfidence: 0.85 (mixed)
Reasoning
P0 keyword "corruption" in body; LLM: Silent identity corruption in create_user when names exceed PostgreSQL's 63-byte limit — a functional bug with security/auth impact, but no data loss or service crash; fix is a straightforward input-validation guard in one command handler.
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.DeepakSPemmaraju commentedon Oct 29, 2026
Fix was checked in 217648a