Summary
A server-side request forgery (SSRF) vulnerability in LangChain Community's SitemapLoader allows nested sitemap URLs to bypass the configured same-domain restriction. If an attacker can control or influence an ingested sitemap, the server may request internal or otherwise restricted destinations and return their responses in the resulting Documents.
Affected context
The issue occurs when SitemapLoader.parse_sitemap processes nested sitemap elements while restrict_to_same_domain is enabled. Leaf URL entries are subject to domain filtering, but nested sitemap locations are passed to the scraping workflow without equivalent domain validation or checks against private, loopback, and link-local destinations. Deployments that ingest attacker-controlled or insufficiently trusted sitemap content are most exposed.
Exploit preconditions
- Attack surface: Sitemap ingestion through LangChain Community's SitemapLoader
- Required access: Ability to publish, modify, or cause the application to ingest a sitemap containing a nested sitemap reference
- Trigger point: Processing of a nested sitemap element during sitemap parsing
- Why exploitation is possible: The nested sitemap location reaches the asynchronous HTTP client without the configured same-domain restriction or private-network destination checks
- Data condition: The requesting server must have network access to the targeted destination, and the response must be returned through the document-loading workflow
Why this happens
The vulnerability results from inconsistent application of URL trust policies across two parsing paths. Although direct leaf URLs are filtered against the configured domain, nested sitemap locations bypass that check and are sent to the HTTP fetcher as trusted destinations. This is a server-side request forgery condition mapped to CWE-918, where attacker-influenced URLs cause a server to make requests to internal or unintended network resources.
Potential impact
- The server may access internal services that are not publicly reachable
- Sensitive responses, metadata, or credentials may be disclosed to the caller
- Cloud instance metadata or management endpoints could be queried
- Network segmentation controls may be bypassed from the application's network position
- Retrieved internal content could be incorporated into downstream documents or processing workflows
General mitigation guidance
Mitigation generally focuses on treating every externally influenced URL, including nested sitemap locations, as untrusted.
Common defensive patterns include:
- Applying consistent domain and destination validation to all sitemap references
- Blocking loopback, private, link-local, multicast, and other reserved address ranges
- Resolving hostnames carefully and validating the resulting addresses before connecting
- Restricting outbound traffic with network egress policies, proxies, and allowlists
- Separating document-fetching workloads from sensitive internal networks
- Returning only the minimum fetched content required by the application
- Running fetchers with least-privilege network and identity permissions
How teams detect issues like this
Organizations can look for SSRF exposure through:
- Static analysis of URL flows from sitemap, feed, or document inputs into HTTP client calls
- Code review checks ensuring security controls cover recursive and alternate parsing branches
- Tests using private, loopback, link-local, and redirected destinations
- Runtime monitoring for outbound requests to internal address ranges and unexpected hostnames
- Egress policy enforcement that denies unauthorized network destinations
- Automated security review tools that flag attacker-controlled URLs passed to network libraries

