security: [BUG] unable to Hide unmapped backend roles
What is the bug? I have linked opensearch to our active directory domain. I also mapped some AD groups to the proper roles…
everything works but i noticed that Dashboards exposes too much information to the users… specifically when a user clicks on “view roles and identities” the user can see every Active Directory group the user name is linked to (as backend roles) even if that group is never used in OpenSearch…
this is information i would like to hide as it shows details the user shouldn’t know. Everything i tried doesn’t seem to work
this is the closest thing i found https://opensearch.org/docs/latest/security-plugin/configuration/ldap/#advanced-exclude-roles-from-nested-role-lookups
my steps in configuration are:
- Reducing the scope by looking for roles/AD Groups in a “sub” OU.
{
"enable_ssl": false,
"hosts": [
"192.168.0.20:389",
"192.168.0.21:389"
],
"bind_dn": "CN=binduser,OU=Bind Users,OU=UsersOU,DC=customer,DC=company,DC=com",
"password": "xxxxxx",
"userbase": "OU=UsersOU,DC=customer,DC=company,DC=com",
"usersearch": "(sAMAccountName={0})",
"username_attribute": "sAMAccountName",
"rolebase": "OU=OpenSearch,OU=User Groups - Customer,DC=customer,DC=company,DC=com",
"rolesearch": "(uniqueMember={0})"
}
this doesn’t work as i see the roles also from
OU=User Groups - Customer,DC=customer,DC=company,DC=com
- configured nested role filter
i added the following configuration
resolve_nested_roles: true
nested_role_filter:
- '^(?!.*OpenSearch.*$)'
that should match (and therefore filterout) everything except groups which have “OpenSearch” in them

but also doesn’t work as i still see all the roles.
What is the expected behavior? Only roles used by OpenSearch should be visible to the user as backend-roles Also, filtering of roles, should work as expected
What is your host/environment?
- OS: Azure AKS
- Version - 2.3.0
- Plugins - nothing manually installed, only default plugins installed by the k8s operator
Do you have any screenshots?

About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (11 by maintainers)
@anubisg1 I took a cursory glance and based on the codepath. It doesn’t appear like
nested_role_filteris filtering on the high level roles.See: https://github.com/opensearch-project/security/blob/main/src/main/java/com/amazon/dlic/auth/ldap/backend/LDAPAuthorizationBackend.java#L879-L885
On the last line highlighted it is adding all of the roles to a set and later returning.
Judging by the tests: https://github.com/opensearch-project/security/blob/main/src/test/java/com/amazon/dlic/auth/ldap/LdapBackendTest.java#L537-L609 it looks like this is expected behavior and the nested filter prevents OpenSearch from recursively resolving roles by excluding roles that match the filter.
The
test.ldiffile insrc/test/resourcesshows the test setup: https://github.com/opensearch-project/security/blob/main/src/test/resources/ldap.ldif#L45-L53Based on the current documentation and code, I am not finding a configuration to support this. This sounds like a nice feature and would make for a good contribution!
@opensearch-project/transfer-request Can this be moved to the
securityrepo?Hi @cwperks Decided on this version of configuration:
I think that implementing “include_roles” might change how cluster works, admins would need to change configuration after upgrading. Excluding roles seems to be better, if there is no change to the config cluster will behave the same without interaction. Here’s the PR: https://github.com/opensearch-project/security/pull/3809