INCIDENT MAP

Browse / AI Framework and Platform Flaws / CVE-2025-69207

Khoj has an IDOR in Notion OAuth Flow that Enables Index Poisoning

CVE-2025-69207 ยท 2026-02-02 moderate

Class
AI Framework and Platform Flaws (filed by a model that read the advisory)
Technique
Authentication and access control
Also involves
RAG and Vector Store Weaknesses, Sensitive Data Disclosure
Affected
khoj (PyPI)
Gets past
Authorisation check
CVSS
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:L
EPSS
0.4% chance of exploitation in 30 days

How it works, in short

The Notion OAuth callback trusts an attacker-supplied state value as the target user ID, binding the attacker's integration to a victim's account. (Our summary, written by a model. The source text is below.)

Details

Summary

An IDOR in the Notion OAuth callback allows an attacker to hijack any user's Notion integration by manipulating the state parameter. The callback endpoint accepts any user UUID without verifying the OAuth flow was initiated by that user, allowing attackers to replace victims' Notion configurations with their own, resulting in data poisoning and unauthorized access to the victim's Khoj search index.

This attack requires knowing the user's UUID which can be leaked through shared conversations where an AI generated image is present.

Details

When users share conversations which contain AI generated images, the file path for the image is constructed using the user's UUID. Knowing this UUID, an attacker is able to intercept the OAuth callback for Notion and replace the state parameter with the other user's UUID and sync notion onto their account.

PoC

The vulnerable line of code exists in src/khoj/routers/notion.py on the callback endpoint.

@notion_router.get("/auth/callback")
async def notion_auth_callback(request: Request, background_tasks: BackgroundTasks):
    code = request.query_params.get("code")
    state = request.query_params.get("state")  # <-- Attacker controlled
    if not code or not state:
        return Response("Missing code or state", status_code=400)

    user: KhojUser = await aget_user_by_uuid(state)  # <-- No verification!

    await NotionConfig.objects.filter(user=user).adelete()  # <-- Deletes victim's config
    
    # ... OAuth token exchange ...
    
    access_token = final_response.get("access_token")
    await NotionConfig.objects.acreate(token=access_token, user=user)  # <-- Stores attacker's token

To exploit is relatively easy. Once we know the victim's UUID, we simply initiate the Notion sync process on our own account and intercept the callback, replacing the state parameter with the victim's UUID.

Impact

Deletes user's existing Notion sync and replaces it with attacker-controlled Notion. Could allow for index poisoning. I'm not entirely sure what Khoj does with synced files but if it's being passed as context to an LLM then I can imagine there's potential here.

References

Source: GitHub Advisory Database, used under CC BY 4.0.