Repository navigation
fix(js): respect network policy before dialing ldap - #7494
Conversation
LDAP was the only JS protocol client that reached the dialer without an `IsHostAllowed` check. Validate ldap, ldaps, and cldap hosts before connecting, and treat ldapi as loopback so restricted local network access rejects Unix socket LDAP before the socket path is opened. Signed-off-by: Dwi Siswanto <git@dw1.io>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
Walkthrough
ChangesLDAP Client Network Policy Enforcement
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai create an issue for this. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
gh issue create \
--repo "projectdiscovery/nuclei" \
--title "LDAP JS client missing IsHostAllowed check — network policy bypass" \
--assignee "dwisiswant0" \
--body "## Summary
The LDAP JavaScript protocol client in \`pkg/js/libs/ldap/ldap.go\` was the only JS protocol client that could reach the dialer without an \`IsHostAllowed\` check. This meant network access restrictions (\`RestrictLocalNetworkAccess\` and similar policies) could be bypassed when a template used the LDAP client.
## Details
- **Affected schemes:** \`ldap://\`, \`ldaps://\` (LDAP over TLS), \`cldap://\` (connectionless LDAP), \`ldapi://\` (LDAP over Unix sockets)
- **Root cause:** \`NewClient\` in \`pkg/js/libs/ldap/ldap.go\` did not call \`protocolstate.IsHostAllowed\` before dialing, unlike all other JS protocol clients.
- **Impact:** A nuclei template using the LDAP client could establish connections to hosts that should be blocked by the configured network policy.
## Expected behaviour
Connections to restricted hosts/networks via the LDAP client should be denied with a network-policy error before any dialing attempt, consistent with other protocol clients.
## Fix (implemented in `#7494`)
- For \`ldap\`, \`ldaps\`, and \`cldap\`: derive the target host and call \`protocolstate.IsHostAllowed\` before dialing.
- For \`ldapi\` (Unix sockets): treat the connection as loopback (\`127.0.0.1\`) so that \`RestrictLocalNetworkAccess\` policies correctly reject it before the socket path is opened.
## References
- PR: https://github.com/projectdiscovery/nuclei/pull/7494
- Reported by: `@dwisiswant0`"Length of output: 1828
|
nuclei 3.10.0 Created-by: HarmonybrewBot Commit-by: HarmonybrewBot Merged-by: HarmonybrewBot Description: Created by `brew bump` --- Created with `brew bump-formula-pr`.<details> <summary>release notes</summary> <pre>## What's Changed ### 🎉 New Features * Added per-host HTTP client pooling by @Mzack9999 in projectdiscovery/nuclei#7301 ### 🐞 Bug Fixes * Fixed handling in hosterrorscache to automatically skip hosts that consistently time out by @knakul853 in projectdiscovery/nuclei#7455 * Fixed preservation of explicit target port in network templates (fixes #7323) by @XananasX7 in projectdiscovery/nuclei#7465 * Fixed connection reuse and improved port pre-flight handling by @Mzack9999 in projectdiscovery/nuclei#6715 * Fixed code template signature validation before DAST loading by @dogancanbakir in projectdiscovery/nuclei#7472 * Fixed gating of MySQL allowAllFiles option to require `-lfa` flag by @dogancanbakir in projectdiscovery/nuclei#7473 * Fixed ASCII-section regex to properly escape literal `.` by @snicket2100 in projectdiscovery/nuclei#7476 * Fixed recording of decoded bytes for debug dumps by @snicket2100 in projectdiscovery/nuclei#7478 * Fixed proper escaping of dbname in lib/pq URLs by @dwisiswant0 in projectdiscovery/nuclei#7479 * Fixed network policy enforcement prior to LDAP dialing by @dwisiswant0 in projectdiscovery/nuclei#7494 * Fixed normalization and rejection of trace file DSN options in Oracle by @dwisiswant0 in projectdiscovery/nuclei#7480 * Fixed proper escaping of MSSQL database names in connection URLs by @dwisiswant0 in projectdiscovery/nuclei#7481 * Fixed krbforge to reject unsandboxed ccache writes by @dwisiswant0 in projectdiscovery/nuclei#7482 * Fixed rejection of request-condition(s) during fuzzing by @dwisiswant0 in projectdiscovery/nuclei#7466 * Fixed: YAML now correctly rejects recursive include chains by @dwisiswant0 in projectdiscovery/nuclei#7492 * Fixed resource leaks by @Mzack9999 in projectdiscovery/nuclei#7502 ### Other Changes * Updated govaluate dependency to prevent slice-bounds panic on invalid UTF-8 input by @XananasX7 in projectdiscovery/nuclei#7464 * Updated goja dependency by @Mzack9999 in projectdiscovery/nuclei#7467 * Updated dependencies to remove unused packages by @dwisiswant0 in projectdiscovery/nuclei#7457 * Refactored templates to centralize opt-in capability gating by @dwisiswant0 in projectdiscovery/nuclei#7489 * Added fuzzing parser harnesses for raw requests and templates by @dwisiswant0 in projectdiscovery/nuclei#7459 * Refactored template rendering boundary by @dwisiswant0 in projectdiscovery/nuclei#7499 ## New Contributors * @XananasX7 made their first contribution in projectdiscovery/nuclei#7465 * @snicket2100 made their first contribution in projectdiscovery/nuclei#7476 **Full Changelog**: https://github.com/projectdiscovery/nuclei/compare/v3.9.0...v3.10.0</pre> <p>View the full release notes at <a href="https://github.com/projectdiscovery/nuclei/releases/tag/v3.10.0">https://github.com/projectdiscovery/nuclei/releases/tag/v3.10.0</a>.</p> </details> <hr> See merge request: Harmonybrew/homebrew-core!13187
Proposed changes
LDAP was the only JS protocol client that reached
the dialer without an
IsHostAllowedcheck.Validate ldap, ldaps, and cldap hosts before
connecting, and treat ldapi as loopback so
restricted local network access rejects Unix
socket LDAP before the socket path is opened.
Proof
Checklist
Summary by CodeRabbit
Bug Fixes
Tests