The vulnerability, a Server-Side Request Forgery (SSRF) bypass, is located in the @langchain/community package, specifically within the RecursiveUrlLoader component. The root cause was that the loader's fetch operation would automatically follow HTTP redirects without re-validating the destination URL. This created a "check-then-act" flaw where an attacker could supply a valid public URL that, upon being fetched, would redirect the server to an internal or sensitive address like a cloud metadata service.
The analysis of the provided commits confirms this. Commit d5e3db0d01ab321ec70a875805b2f74aefdadf9d introduced initial SSRF protection by adding a validateSafeUrl function and applying it to the initial URL. However, it did not account for redirects.
The subsequent commit, 2812d2b2b9fd9343c4850e2ab906b8cf440975ee, directly patches the redirect vulnerability. The changes are concentrated in the RecursiveUrlLoader.fetchWithTimeout method. The patch modifies the fetch call to disable automatic redirects (redirect: "manual") and introduces a loop. Within this loop, each redirect URL, extracted from the Location header, is explicitly validated using validateSafeUrl before the next request is made. This ensures that all URLs in a redirect chain are checked for safety, effectively closing the SSRF bypass.