GHSA-3hjh-jh2h-vrg6 CVE-2024-2965 PYSEC-2024-118 PYSEC-2026-2561
Denial of service in langchain-community
- Severity
- 4.2 / 10
- Medium · CVSS 3.0
- Exploit chance (EPSS)
- 0.30%
- Chance of exploitation in the next 30 days. Higher than 23.20% of scored vulnerabilities.
- Known exploited
- No
- Not in CISA's catalog
- Fix
- Available
- 2 packages have a fixed version
Description
Denial of service in SitemapLoader Document Loader in the langchain-community package, affecting versions below 0.2.5. The parse_sitemap method, responsible for parsing sitemaps and extracting URLs, lacks a mechanism to prevent infinite recursion when a sitemap URL refers to the current sitemap itself. This oversight allows for the possibility of an infinite loop, leading to a crash by exceeding the maximum recursion depth in Python. This vulnerability can be exploited to occupy server socket/port resources and crash the Python process, impacting the availability of services relying on this functionality.
Affected versions
PyPI
| Package | Vulnerable | Fixed in |
|---|---|---|
| langchain | < 0.2.5 |
0.2.5 |
| langchain | < 0.2.5 |
0.2.5 |
| langchain-community | < 0.2.5 |
0.2.5 |
How to fix
Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.
langchain PyPI → 0.2.5
- pip
pip install --upgrade "langchain>=0.2.5"- poetry
poetry add "langchain>=0.2.5"- uv
uv add "langchain>=0.2.5"
langchain-community PyPI → 0.2.5
- pip
pip install --upgrade "langchain-community>=0.2.5"- poetry
poetry add "langchain-community>=0.2.5"- uv
uv add "langchain-community>=0.2.5"
Severity breakdown
CVSS 3.0 4.2
CVSS:3.0/AV:P/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H
- Attack vector
- Physical
- Attack complexity
- High
- Privileges required
- None
- User interaction
- None
- Scope
- Unchanged
- Confidentiality
- None
- Integrity
- None
- Availability
- High
Weakness
CWE-400: Uncontrolled Resource Consumption
The product does not properly control the allocation and maintenance of a limited resource.
How to prevent it
- Architecture and Design: Design throttling mechanisms into the system architecture. The best protection is to limit the amount of resources that an unauthorized user can cause to be expended. A strong authentication and access control model will help prevent such attacks from occurring in the first place. The login application should be protected against DoS attacks as much as possible. Limiting the database access, perhaps by caching result sets, can help minimize the resources expended. To further limit the potential for a DoS attack, consider tracking the rate of requests received from users and blocking requests that exceed a defined rate threshold.
- Architecture and Design: Mitigation of resource exhaustion attacks requires that the target system either: recognizes the attack and denies that user further access for a given amount of time, or uniformly throttles all requests in order to make it more difficult to consume resources more quickly than they can again be freed. The first of these solutions is an issue in itself though, since it may allow attackers to prevent the use of the system by a particular valid user. If the attacker impersonates the valid user, they may be able to prevent the user from accessing the server in question. The second solution is simply difficult to effectively institute -- and even when properly done, it does not provide a full solution. It simply makes the attack require more resources on the part of the attacker.
- Architecture and Design: Ensure that protocols have specific limits of scale placed on them.
- Implementation: Ensure that all failures in resource allocation place the system into a safe posture.
CWE-674: Uncontrolled Recursion
The product does not properly control the amount of recursion that takes place, consuming excessive resources, such as allocated memory or the program stack.
How to prevent it
- Implementation: Ensure that an end condition will be reached under all logic conditions. The end condition may include checking against the depth of recursion and exiting with an error if the recursion goes too deep. The complexity of the end condition contributes to the effectiveness of this action.
- Implementation: Increase the stack size.
References
Advisories
Packages
Other links
- github.com/langchain-ai/langchain/pull/22903
- github.com/langchain-ai/langchain/commit/73c42306745b0831aa6fe7fe4eeb70d2c2d87a82
- github.com/langchain-ai/langchain/commit/9a877c7adbd06f90a2518152f65b562bd90487cc
- github.com/pypa/advisory-database/tree/main/vulns/langchain/PYSEC-2024-118.yaml
- huntr.com/bounties/90b0776d-9fa6-4841-aac4-09fde5918cae
Timeline
- Published
- Last updated by the source
- Latest EPSS score
Related advisories
| Advisory | Severity | Why it's related |
|---|---|---|
| GHSA-gr75-jv2w-4656 LangChain: Path traversal and sandbox escape in LangChain file-search middleware and loaders | Medium | Also affects langchain |
| GHSA-3644-q5cj-c5c7 LangSmith SDK: Public prompt pull deserializes untrusted manifests without trust boundary warning | High | Also affects langchain |
| GHSA-45pg-36p6-83v9 Langchain SQL Injection vulnerability | Critical | Also affects langchain |
| PYSEC-2024-323 LangChain pickle deserialization of untrusted data | High | Also affects langchain |
| GHSA-rgp8-pm28-3759 langchain vulnerable to path traversal | High | Also affects langchain |
| GHSA-h59x-p739-982c LangChain directory traversal vulnerability | High | Also affects langchain |
| GHSA-h9j7-5xvc-qhg5 langchain Server-Side Request Forgery vulnerability | High | Also affects langchain |
| GHSA-6h8p-4hx9-w66c Langchain Server-Side Request Forgery vulnerability | High | Also affects langchain |
MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.
Check your repos with MergeHarbor