apache / apache/druid

druid-basic-security - LDAPRoleProvider breaks if groupMapping with invalid groupPattern is created

Open
#13,322 1 comment 0 reactions 0 assignees View on GitHub
Security
Dominant language
Java
Stars
14.1k
Forks
3.8k
Avg merge
2d 58m
Merged PRs (30d)
233

Description

### Affected Version

0.23.X (likely exists in all prior releases, but I haven't validated)

### Description

Nothing stops me from creating a groupMapping with an arbitrary and always invalid groupPattern, such as - `fajfkdjaf`. The `POST` to create the pattern will work just fine. However, the `LDAP` authorizer is now broken at this point. `LDAPRoleProvider#getRoles` will throw a `RuntimeException`. And worse yet, I cannot correct my mistake by executing `DELETE` on the groupMapping. Doing so just says the mapping doesn't exist. This leaves me with the option of doing manual surgery on the metastore entry for the groupMappings, or using a sledgehammer and just deleting the row in the druid_config table and re-building my mappings (both very unfriendly to the operator and cluster users).

### Fix Ideas

#### operator specified groupPattern regex

Allow the operator to specify a regex for the authorizer that restricts what kinds of groupPatterns can be used. This can help prevent us from getting to this point in the first place.

#### less punitive behavior in `LDAPRoleProvider#getRoles`

I think it makes much more sense to log and skip a mapping that results in an `InvalidNameException`. Completely breaking the authorizer over what was likely a mistake by the operator seems like an unnecessary reaction to the problem that will cause the cluster to be degraded or down depending on who is using the authorizer (internal user or just clients, etc.)

Contributor guide

Open the contributing guide

Research direction

Start with LDAPRoleProvider#getRoles and trace how groupMappings are stored and removed through the POST and DELETE operations. Reproduce an invalid groupPattern, then verify that the LDAP authorizer remains usable and that the problematic mapping can be removed or corrected without manual druid_config surgery.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
authorization, backend, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.