-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Use LDAP_SERVER_SD_FLAGS_OID flag to prevent retrieving SACL as a non-admin user #17342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use LDAP_SERVER_SD_FLAGS_OID flag to prevent retrieving SACL as a non-admin user #17342
Conversation
…en retrieving entries so that we don't retrieve the SACL, which cannot be retrieved by nonadmin users.
a77fdb2
to
fd8bdf4
Compare
Added in a PR to upstream to try fix the library issue at ruby-ldap/ruby-net-ldap#411. Hopefully this might help us avoid having to hot patch this but in the event that we do need to this will open up the opportunity to remove the hotfix should this be merged in upstream. |
Some time ago, i PRd a bunch of my |
…allow us to use controls when search whilst we await an upstream patch in Net::LDAP
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good to me. I reviewed the changes to the net-ldap lib in the dedicated PR, and the rest is existing code.
I was able to reproduce the original issue and verify this fixed it.
I also tested running the module with a domain admin and ran a couple of queries with the dedicated gather/ldap_query
module to ensure that is still working as well.
The only thing I'd suggest and I can do this while I land it is adding references to the original issue and net-ldap PR into the comment you have here for the patch.
Use LDAP_SERVER_SD_FLAGS_OID flag to prevent retrieving SACL as a non-admin user
Release NotesThis adds the necessary control to the search queries used to find vulnerable certificate templates in an ADCS environment. Prior to this, non-privileged users would not be able to read the security descriptor field. |
Fixes #17324
The SACL part of the ntSecurityDescriptor object in LDAP cannot be retrieved by non-admin users as noted at https://twitter.com/tifkin_/status/1372628611677753344/photo/1. Also noted in this same photo is that it is possible to get around this by using the 1.2.840.113556.1.4.801 control, aka LDAP_SERVER_SD_FLAGS_OID, with a value of 0x7, we remove bit 8, aka 0x8, or the SACL_SECURITY_INFORMATION bit, so that we no longer retrieve the SACL from our requests. More technical details on this can be found at https://ldapwiki.com/wiki/LDAP_SERVER_SD_FLAGS_OID.
This adjustment requires some changes to the way that
net-ldap
works though. A monkey patch has been made and is applied in this code whilst I await the fix I pushed up to upstream at https://github.com/ruby-ldap/ruby-net-ldap/pull/411/files to be landed.This will allow us specify our own controls to the search requests via an additional
control
keyword attribute, whereas currently the Net-LDAP code does not presently support doing this.Verification
msfconsole
use auxiliary/gather/ldap_esc_vulnerable_cert_finder
set BIND_DN <low-priv domain-joined user>
set BIND_PW <low-priv domain-joined user password>
set RHOST <IP address of ADCS server that is part of the same domain as the domain-joined user>
run
ntSecurityDescriptor
attributes being available to the low privileged user, but now the module works fine.