# Improper Neutralization of Special Elements used in an LDAP Query ('LDAP Injection') (CWE-90) The product constructs all or part of an LDAP query using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended LDAP query. **Stack:** JavaScript - Prevalence: उच्च बार-बार शोषित - Impact: उच्च 3 उच्च गंभीरता वाले नियम - Prevention: प्रलेखित 3 फिक्स उदाहरण **OWASP:** Injection (A03:2021-Injection) - #3 ## Description If user input is incorporated into an LDAP query without proper sanitization, an attacker can inject LDAP commands that could read or modify sensitive directory information. ## Prevention 1 Shoulder डिटेक्शन नियमों पर आधारित LDAP Injection के लिए रोकथाम रणनीतियाँ। ### JavaScript Escape LDAP special characters in user input before constructing LDAP queries ## Warning Signs - [HIGH] user input flowing to LDAP queries without escaping special characters ## Consequences - एप्लिकेशन डेटा पढ़ना - एप्लिकेशन डेटा संशोधित करना - सुरक्षा तंत्र को बायपास करना ## Mitigations - जहां संभव हो, पैरामीटराइज़्ड LDAP क्वेरीज़ का उपयोग करें - LDAP क्वेरीज़ में उपयोग किए जाने वाले सभी उपयोगकर्ता इनपुट को escape या encode करें - स्वीकार्य वर्णों की allowlist के विरुद्ध इनपुट को सत्यापित करें ## Detection - Total rules: 3 - Languages: go, javascript, typescript, python ## Rules by Language ### Javascript (1 rules) - **LDAP Injection** [HIGH]: Detects user input flowing to LDAP queries without escaping special characters. - Remediation: Escape LDAP special characters before including user input in queries. ```javascript const safe = input.replace(/[\\*()]/g, c => '\\' + c.charCodeAt(0).toString(16)); ldap.search(`cn=${safe},dc=example,dc=com`, opts); ``` Learn more: https://shoulder.dev/learn/javascript/cwe-90/ldap-injection ### Typescript (1 rules) - **LDAP Injection** [HIGH]: Detects user input flowing to LDAP queries without escaping special characters. - Remediation: Escape LDAP special characters before including user input in queries. ```javascript const safe = input.replace(/[\\*()]/g, c => '\\' + c.charCodeAt(0).toString(16)); ldap.search(`cn=${safe},dc=example,dc=com`, opts); ``` Learn more: https://shoulder.dev/learn/javascript/cwe-90/ldap-injection