The vulnerability exists in the notion_auth_callback function located in src/khoj/routers/notion.py. The function directly uses the state parameter from the query string to retrieve a user object via aget_user_by_uuid(state). This state parameter is attacker-controllable. The vulnerability description and the provided proof-of-concept code clearly demonstrate that there is no validation to ensure the state parameter corresponds to the user who initiated the authentication flow. An attacker, knowing a victim's UUID, can initiate their own Notion authentication and then intercept the callback to replace the state parameter with the victim's UUID. This action causes the system to delete the victim's existing Notion configuration and create a new one with the attacker's Notion access token, effectively poisoning the victim's search index. The fix, visible in the current version of the file, involves retrieving the user from the authenticated session (request.user.object) and then validating the state parameter against the authenticated user's UUID, thus preventing the IDOR.