Skip to content

Commit 3806b1d

Browse files
committed
Fix user veto to check collection and db
1 parent 3fe5d1f commit 3806b1d

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

accounts/src/main/java/org/restheart/accounts/AccountsInitializer.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,17 @@ public void init() {
6969
// edits — see PROFILE_ONLY_WHITELIST above for why this is safe to enforce
7070
// unconditionally.
7171
aclRegistry.registerVeto(r -> {
72-
if (!r.getPath().startsWith("/users")) return false;
7372
if (!(r instanceof MongoRequest mr)) return false;
7473

74+
// Match on the *resolved* db/collection (post mongo-mounts), not the request
75+
// path: the users collection can be reachable through more than one URL —
76+
// e.g. the conventional /users mount alias AND the raw /{db}/users path if a
77+
// wildcard mount also exposes it. A path-prefix check on "/users" would miss
78+
// the second one entirely, letting a client bypass this restriction just by
79+
// using a different (but equally valid) URL for the same collection.
80+
if (!"users".equals(mr.getCollectionName())) return false;
81+
if (!RequestOverrides.db(mr, conf).equals(mr.getDBName())) return false;
82+
7583
// Roles configured via `users-unrestricted-roles` (e.g. an admin console
7684
// role) bypass this restriction entirely — see AccountsConfigData. Reads
7785
// the per-team override first (set by e.g. TeamConfigInterceptor), falling

0 commit comments

Comments
 (0)