fix: bind prompt history/version ops to the authorized prompt (#25056)

The history diff, delete, and version-restore routes authorize the URL
prompt_id but then act on a caller-supplied history/version id without
checking it belongs to that prompt (IDOR). Filter by prompt_id in
compute_diff and delete_history_entry, and reject a cross-prompt version_id
in update_prompt_version.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Classic298
2026-06-01 12:07:52 -07:00
committed by GitHub
co-authored by Claude Opus 4.7
parent e623081b2b
commit 9a3eea6448
3 changed files with 15 additions and 6 deletions
+2 -2
View File
@@ -653,7 +653,7 @@ async def delete_prompt_history_entry(
detail='Cannot delete the active production version',
)
success = await PromptHistories.delete_history_entry(history_id, db=db)
success = await PromptHistories.delete_history_entry(history_id, prompt.id, db=db)
if not success:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
@@ -697,7 +697,7 @@ async def get_prompt_diff(
detail=ERROR_MESSAGES.ACCESS_PROHIBITED,
)
diff = await PromptHistories.compute_diff(from_id, to_id, db=db)
diff = await PromptHistories.compute_diff(from_id, to_id, prompt.id, db=db)
if not diff:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,