rules:
- id: ldap-bind-without-password
  patterns:
  - pattern-either:
    - pattern: ldap_bind($LDAP, $DN, NULL)
    - pattern: ldap_bind($LDAP, $DN, '')
    - patterns:
      - pattern: ldap_bind(...)
      - pattern-not: ldap_bind($LDAP, $DN, $PASSWORD)
  message: >-
    Detected anonymous LDAP bind.
    This permits anonymous users to execute LDAP statements.
    Consider enforcing authentication for LDAP.
  metadata:
    references:
    - https://www.php.net/manual/en/function.ldap-bind.php
    cwe:
    - 'CWE-287: Improper Authentication'
    owasp:
    - A02:2017 - Broken Authentication
    - A07:2021 - Identification and Authentication Failures
    - A07:2025 - Authentication Failures
    category: security
    technology:
    - php
    cwe2022-top25: true
    cwe2021-top25: true
    subcategory:
    - audit
    likelihood: LOW
    impact: LOW
    confidence: LOW
  languages: [php]
  severity: WARNING
