fix(proxy): add same-origin check to /v1/retrieve/tool_call

/v1/retrieve already rejects cross-origin requests; its sibling /v1/retrieve/tool_call did not. Add the same guard and cover it in the CSRF tests.
This commit is contained in:
Program2113
2026-10-03 19:46:54 +05:30
parent 2bc9419467
commit fc6ebf82df
2 changed files with 5 additions and 1 deletions
+4 -1
View File
@@ -5778,7 +5778,10 @@ def create_app(config: ProxyConfig | None = None) -> FastAPI:
)
# CCR Tool Call Handler - for agent frameworks to call when LLM uses headroom_retrieve
@app.post("/v1/retrieve/tool_call", dependencies=[Depends(_require_loopback)])
@app.post(
"/v1/retrieve/tool_call",
dependencies=[Depends(_require_loopback), Depends(_require_same_origin)],
)
async def ccr_handle_tool_call(request: Request):
"""Handle a CCR tool call from an LLM response.
+1
View File
@@ -134,6 +134,7 @@ CSRF_GUARDED = [
"/stats/reset",
"/cache/clear",
"/v1/retrieve",
"/v1/retrieve/tool_call",
"/v1/telemetry/import",
"/admin/runtime-env",
]