← PHP / Laravel · Contents

PHP-095 / Intermediate

LDAP injection: concatenating filter strings

A03:2021 Injection · CWE-90 LDAP Injection

Why is this a problem?

A crafted filter such as *)(uid=*))(|(uid=* enables authentication bypass or information enumeration.

How to fix it

php
$user = ldap_escape($request->user, '', LDAP_ESCAPE_FILTER);
ldap_search($conn, $base, "(uid={$user})");

Further reading