Ecosyste.ms: Advisories

An open API service providing security vulnerability metadata for many open source software ecosystems.

Security Advisories: GSA_kwCzR0hTQS1ocTRoLXc5MzMtam02Y84ABC09

khoj has an IDOR in subscription management allows unauthorized subscription modifications

Summary

An 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.

Details

The 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.

Vulnerable code in /api/subscription:

@subscription_router.patch("")
@requires(["authenticated"])
async def update_subscription(request: Request, email: str, operation: str):
    # IDOR: email parameter directly references user subscriptions without ownership verification
    customers = stripe.Customer.list(email=email).auto_paging_iter()
    customer = next(customers, None)
    
    if operation == "cancel":
        # Any authenticated user can modify any subscription referenced by email
        customer_id = customer.id
        for subscription in stripe.Subscription.list(customer=customer_id):
            stripe.Subscription.modify(subscription.id, cancel_at_period_end=True)

PoC

  1. Create a customer account in stripe:

  2. Log in as any user.

  3. Send this request:

PATCH /api/[email protected]&operation=cancel HTTP/1.1
  1. The subscription for Customer A is successfully set to cancel.

Impact

High:
Revenue loss via mass cancellation of subscriptions.
Loss of customer trust by re-enabling subscriptions they had set to cancel.

Resolution

This 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.

Permalink: https://github.com/advisories/GHSA-hq4h-w933-jm6c
JSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS1ocTRoLXc5MzMtam02Y84ABC09
Source: GitHub Advisory Database
Origin: Unspecified
Severity: Moderate
Classification: General
Published: 10 days ago
Updated: 9 days ago


CVSS Score: 4.3
CVSS vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N

EPSS Percentage: 0.00043
EPSS Percentile: 0.10957

Identifiers: GHSA-hq4h-w933-jm6c, CVE-2024-52294
References: Repository: https://github.com/khoj-ai/khoj
Blast Radius: 1.3

Affected Packages

pypi:khoj
Dependent packages: 0
Dependent repositories: 2
Downloads: 15,700 last month
Affected Version Ranges: < 1.29.0
Fixed in: 1.29.0
All affected versions: 1.17.0, 1.20.0, 1.20.2, 1.20.3, 1.20.4, 1.21.0, 1.21.1, 1.21.2, 1.21.3, 1.21.4, 1.21.5, 1.21.6, 1.22.0, 1.22.1, 1.22.2, 1.22.3, 1.23.0, 1.23.1, 1.23.2, 1.23.3, 1.24.0, 1.24.1, 1.25.0, 1.26.0, 1.26.1, 1.26.2, 1.26.3, 1.26.4, 1.27.0, 1.27.1, 1.28.0, 1.28.1, 1.28.2, 1.28.3
All unaffected versions: 1.29.0, 1.29.1, 1.30.0, 1.30.1, 1.30.2, 1.30.3, 1.30.4, 1.30.5, 1.30.6, 1.30.7, 1.30.8, 1.30.9, 1.30.10, 1.31.0, 1.32.0, 1.32.1, 1.32.2, 1.33.0, 1.33.1