Vulnerabilities in pkg:pypi/khoj-assistant

PACKAGE
Advisory Summary

GHSA-564j-v29w-rqr6 is a MODERATE (CVSS 6.5) khoj open redirect vulnerability vulnerability (CWE-601: URL Redirection to Untrusted Site ('Open Redirect')) affecting Khoj assistant libraries in the PyPI ecosystem. The issue involves khoj open redirect vulnerability in login page. Remediation is available by upgrading affected packages to version 1.14.0.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:pypi/khoj-assistant

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:pypi/khoj-assistant. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-564j-v29w-rqr6 - MODERATE Khoj Open Redirect Vulnerability in Login Page

GHSA-564j-v29w-rqr6 at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-564j-v29w-rqr6
Severity MODERATE
CVSS v3.1 Base Score 6.5
CWE Classification CWE-601: URL Redirection to Untrusted Site ('Open Redirect')
Affected Product Khoj assistant
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 6.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity High (I:H)
Availability None (A:N)

How to Fix GHSA-564j-v29w-rqr6

To remediate this vulnerability, upgrade all affected Khoj assistant dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

khoj-assistant fixed: 1.14.0
pip install khoj-assistant>=1.14.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show khoj-assistant

How to Check if You Are Affected

To determine whether your Python environment is affected by GHSA-564j-v29w-rqr6, inspect your installed packages using pip:

pip show khoj-assistant

Analyze the terminal output to locate any version of Khoj assistant in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.14.0), your application is affected.

Note: The pip show khoj-assistant command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-601: URL Redirection to Untrusted Site ('Open Redirect'), where the web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a redirect. In Khoj assistant, 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

### Summary An attacker can use the `next` parameter on the login page to redirect a victim to a malicious page, while masking this using a legit-looking `app.khoj.dev` url. For example, `https://app.khoj.dev/login?next=//example.com` will redirect to the https://example.com page. ### Details The problem seems to be in this method: https://github.com/khoj-ai/khoj/blob/2667ef45449eb408ce1d7c393be04845be31e15f/src/khoj/routers/auth.py#L95 ### PoC Open the `https://app.khoj.dev/login?next=//example.com` url in a Gecko-based browser (Firefox). ### Impact The impact is low, and this could only be used in phishing attempts, but it's still a problem nonetheless.

GHSA-564j-v29w-rqr6 Affected Khoj assistant Versions

1 component(s)
Fixed Versions:
1.14.0
Product / Package Ecosystem Affected Versions Fixed Version
khoj-assistant
PyPI
< 1.14.0
1.14.0

References

Frequently Asked Questions

What is GHSA-564j-v29w-rqr6?
GHSA-564j-v29w-rqr6 is a security vulnerability in Khoj assistant involving Khoj Open Redirect Vulnerability in Login Page under CWE-601: URL Redirection to Untrusted Site ('Open Redirect').
Which Khoj assistant versions are affected?
Affected versions include releases prior to 1.14.0 across affected packages: khoj-assistant.
What version fixes GHSA-564j-v29w-rqr6?
Upgrading to 1.14.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is khoj-assistant affected?
Yes, khoj-assistant is affected in releases prior to 1.14.0. Upgrade your dependency to 1.14.0 or later.
What is the CVSS score of GHSA-564j-v29w-rqr6?
GHSA-564j-v29w-rqr6 has a CVSS v3.1 base score of 6.5 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N.
What CWE is associated with GHSA-564j-v29w-rqr6?
GHSA-564j-v29w-rqr6 is classified under CWE-601: URL Redirection to Untrusted Site ('Open Redirect') (The web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a redirect.).
How can I check PyPI dependencies for GHSA-564j-v29w-rqr6?
Run the dependency tree command: 'pip show khoj-assistant'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-564j-v29w-rqr6",
  "modified" : "2024-07-08T14:57:43Z",
  "published" : "2024-07-08T14:57:43Z",
  "aliases" : [ ],
  "summary" : "Khoj Open Redirect Vulnerability in Login Page",
  "details" : "### Summary\nAn attacker can use the `next` parameter on the login page to redirect a victim to a malicious page, while masking this using a legit-looking `app.khoj.dev` url.\nFor example, `https://app.khoj.dev/login?next=//example.com` will redirect to the https://example.com page.\n\n### Details\nThe problem seems to be in this method: https://github.com/khoj-ai/khoj/blob/2667ef45449eb408ce1d7c393be04845be31e15f/src/khoj/routers/auth.py#L95\n\n### PoC\nOpen the `https://app.khoj.dev/login?next=//example.com` url in a Gecko-based browser (Firefox).\n\n### Impact\nThe impact is low, and this could only be used in phishing attempts, but it's still a problem nonetheless.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:N/SC:N/SI:H/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "khoj-assistant"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.14.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/khoj-ai/khoj/security/advisories/GHSA-564j-v29w-rqr6"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/khoj-ai/khoj/commit/4daf16e5f916641304e11d56a6071ad365c21a18"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/khoj-ai/khoj"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/khoj-ai/khoj/blob/2667ef45449eb408ce1d7c393be04845be31e15f/src/khoj/routers/auth.py#L95"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-601" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-07-08T14:57:43Z",
    "nvd_published_at" : null
  }
}