PAC4J is vulnerable to LDAP Injection in multiple methods. A low-privileged remote attacker can inject crafted LDAP syntax into ID-based search parameters, potentially resulting in unauthorized LDAP queries and arbitrary directory operations.
This issue was fixed in PAC4J versions 4.5.10, 5.7.10 and 6.4.1
PAC4J versions prior to 4.5.10, 5.7.10, and 6.4.1 contain an LDAP injection vulnerability (CVE-2026-40459) with CVSS 8.8 that allows low-privileged remote attackers to inject malicious LDAP syntax through ID-based search parameters. This enables unauthorized LDAP queries and arbitrary directory operations, potentially compromising authentication systems and directory services. Organizations using PAC4J for authentication must prioritize immediate patching to prevent unauthorized access to critical systems.
IMMEDIATE ACTIONS:
1. Identify all systems running PAC4J versions < 4.5.10, < 5.7.10, or < 6.4.1 using software inventory tools
2. Isolate or restrict network access to affected PAC4J instances pending patching
3. Review LDAP query logs for suspicious patterns (unusual characters, wildcard injections, filter manipulation)
4. Monitor authentication failures and successful logins from unusual sources
PATCHING GUIDANCE:
1. Upgrade PAC4J to version 4.5.10, 5.7.10, or 6.4.1 immediately (patch available)
2. Test patches in non-production environments first
3. Coordinate patching with dependent applications (Spring Security, Shiro integrations)
4. Verify LDAP connectivity post-patch
COMPENSATING CONTROLS (if patching delayed):
1. Implement WAF rules to block LDAP injection patterns: *, (, ), &, |, !, =, ~, <, >, /, \
2. Apply input validation/sanitization at application layer for all LDAP search parameters
3. Use LDAP query parameterization/prepared statements exclusively
4. Restrict LDAP service account permissions to minimum required operations
5. Enable LDAP query logging and alerting
6. Implement network segmentation isolating LDAP servers
7. Enforce strong authentication for LDAP service accounts
DETECTION RULES:
1. Monitor for LDAP filter syntax in HTTP parameters: regex patterns containing *, (, ), &, |
2. Alert on LDAP queries with unexpected complexity or length
3. Track failed LDAP bind attempts followed by successful authentication
4. Monitor for directory enumeration patterns (wildcard searches, recursive queries)
5. Log all LDAP operations with source IP and user context
الإجراءات الفورية:
1. تحديد جميع الأنظمة التي تقوم بتشغيل إصدارات PAC4J < 4.5.10 أو < 5.7.10 أو < 6.4.1 باستخدام أدوات جرد البرامج
2. عزل أو تقييد الوصول إلى الشبكة لمثيلات PAC4J المتأثرة في انتظار التصحيح
3. مراجعة سجلات استعلامات LDAP للأنماط المريبة (أحرف غير عادية، حقن البدل، معالجة المرشحات)
4. مراقبة فشل المصادقة والتسجيلات الناجحة من مصادر غير عادية
إرشادات التصحيح:
1. ترقية PAC4J إلى الإصدار 4.5.10 أو 5.7.10 أو 6.4.1 فوراً
2. اختبار التصحيحات في بيئات غير الإنتاج أولاً
3. تنسيق التصحيح مع التطبيقات التابعة (تكاملات Spring Security و Shiro)
4. التحقق من اتصال LDAP بعد التصحيح
الضوابط البديلة (إذا تأخر التصحيح):
1. تطبيق قواعد WAF لحجب أنماط حقن LDAP: *, (, ), &, |, !, =, ~, <, >, /, \
2. تطبيق التحقق من الإدخال/التطهير على مستوى التطبيق لجميع معاملات بحث LDAP
3. استخدام معاملات استعلام LDAP/البيانات المحضرة حصراً
4. تقييد أذونات حساب خدمة LDAP للعمليات المطلوبة بحد أدنى
5. تفعيل تسجيل استعلامات LDAP والتنبيهات
6. تطبيق تقسيم الشبكة لعزل خوادم LDAP
7. فرض المصادقة القوية لحسابات خدمة LDAP
قواعد الكشف:
1. مراقبة بناء جملة مرشح LDAP في معاملات HTTP: أنماط regex تحتوي على *, (, ), &, |
2. التنبيه على استعلامات LDAP ذات التعقيد أو الطول غير المتوقع
3. تتبع محاولات ربط LDAP الفاشلة متبوعة بمصادقة ناجحة
4. مراقبة أنماط تعداد الدليل (البحث عن البدل، الاستعلامات العودية)
5. تسجيل جميع عمليات LDAP مع عنوان IP المصدر وسياق المستخدم