CVE-2024-52294: Khoj Khoj Has An IDOR Vulnerability
MODERATECVE-2024-52294 is a MODERATE (CVSS 4.3) khoj has an idor vulnerability (CWE-639: Authorization Bypass Through User-Controlled Key) affecting Khoj libraries in the PyPI ecosystem. The issue involves khoj has an idor in subscription management allows unauthorized subscription modifications. Remediation is available by upgrading affected packages to version 1.29.0.
CVE-2024-52294 at a Glance
Security Impact
CVSS: 4.3
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N).
How to Fix CVE-2024-52294
To remediate this vulnerability, upgrade all affected Khoj dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install khoj>=1.29.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show khoj
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2024-52294, inspect your installed packages using pip:
pip show khoj
Analyze the terminal output to locate any version of Khoj in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.29.0), your application is affected.
Note: The pip show khoj command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-639: Authorization Bypass Through User-Controlled Key, where the system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data. In Khoj, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2024-52294 Affected Khoj Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
khoj
|
PyPI |
< 1.29.0
|
1.29.0
|
References
Frequently Asked Questions
What is CVE-2024-52294?
Which Khoj versions are affected?
What version fixes CVE-2024-52294?
Is khoj affected?
What is the CVSS score of CVE-2024-52294?
What CWE is associated with CVE-2024-52294?
How can I check PyPI dependencies for CVE-2024-52294?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-hq4h-w933-jm6c",
"modified" : "2024-12-30T18:43:16Z",
"published" : "2024-12-30T16:12:40Z",
"aliases" : [ "CVE-2024-52294" ],
"summary" : "khoj has an IDOR in subscription management allows unauthorized subscription modifications",
"details" : "### Summary\nAn Insecure Direct Object Reference (IDOR) vulnerability in the update_subscription endpoint allows any authenticated user to manipulate other users' Stripe subscriptions by simply modifying the email parameter in the request.\n\n### Details\nThe vulnerability exists in the subscription endpoint at `/api/subscription`. The endpoint uses an email parameter as a direct reference to user subscriptions without verifying object ownership. While authentication is required, there is no authorization check to verify if the authenticated user owns the referenced subscription.\n\nVulnerable code in `/api/subscription`:\n```python\n@subscription_router.patch(\"\")\n@requires([\"authenticated\"])\nasync def update_subscription(request: Request, email: str, operation: str):\n # IDOR: email parameter directly references user subscriptions without ownership verification\n customers = stripe.Customer.list(email=email).auto_paging_iter()\n customer = next(customers, None)\n \n if operation == \"cancel\":\n # Any authenticated user can modify any subscription referenced by email\n customer_id = customer.id\n for subscription in stripe.Subscription.list(customer=customer_id):\n stripe.Subscription.modify(subscription.id, cancel_at_period_end=True)\n```\n\n### PoC\n1. Create a customer account in stripe:\n - Customer A: `adventure8812@zeropath.com` (attacker)\n\n2. Log in as any user.\n\n3. Send this request:\n```http\nPATCH /api/subscription?email=adventure8812@zeropath.com&operation=cancel HTTP/1.1\n```\n\n4. The subscription for Customer A is successfully set to cancel.\n\n### Impact\nHigh:\nRevenue loss via mass cancellation of subscriptions.\nLoss of customer trust by re-enabling subscriptions they had set to cancel.\n\n### Resolution\n\nThis was fixed in the following commit which limited subscription update operations to the authenticated user: https://github.com/khoj-ai/khoj/commit/47d3c8c23597900af708bdc60aced3ae5d2064c1. Support for arbitrarily presenting an email for update has been deprecated.\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "khoj"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.29.0"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/khoj-ai/khoj/security/advisories/GHSA-hq4h-w933-jm6c"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-52294"
}, {
"type" : "WEB",
"url" : "https://github.com/khoj-ai/khoj/commit/47d3c8c23597900af708bdc60aced3ae5d2064c1"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/khoj-ai/khoj"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-639" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2024-12-30T16:12:40Z",
"nvd_published_at" : "2024-12-30T17:15:09Z"
}
}