Skip to content

fix(responses_id_security): decrypt response ids for input_items follow-ups - #32269

Merged
mateo-berri merged 1 commit into
litellm_internal_stagingfrom
litellm_fix_responses_input_items_decrypt
Jul 6, 2026
Merged

mateo-berri merged 1 commit into
litellm_internal_stagingfrom
litellm_fix_responses_input_items_decrypt

Conversation

@mateo-berri

Copy link
Copy Markdown
Contributor

Relevant issues

Linear ticket

Part of LIT-4111

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • My PR passes all CI/CD checks (e.g., lint, format, unit tests)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

Screenshots / Proof of Fix

Live proxy against the real OpenAI API (openai/gpt-4o-mini), DB-less, responses id security on by default:

model_list:
  - model_name: openai-responses-test
    litellm_params:
      model: openai/gpt-4o-mini
      api_key: os.environ/OPENAI_API_KEY

general_settings:
  master_key: os.environ/LITELLM_MASTER_KEY

Before (proxy on litellm_internal_staging at f628b41400, port 53798): create a response, then list its input items with the encrypted id the proxy returned

$ curl -s http://127.0.0.1:53798/v1/responses -H "Authorization: Bearer sk-****" -H "Content-Type: application/json" \
    -d '{"model":"openai-responses-test","input":"Say hello in five words"}'
{"id":"resp_ffXLBRNh5TbUew3Z4BzpUdWDX9JSFTHyhg5aSuezhmpe1n5EOqQwHFW...","created_at":1783369547,...,"output":[{...,"text":"Hello! How are you today?",...}],...}

$ curl -s -w '\nHTTP %{http_code}\n' "http://127.0.0.1:53798/v1/responses/resp_ffXLBRNh5TbUew3Z4BzpUdWDX9JSFTHyhg5aSuezhmpe1n5EOqQwHFW.../input_items" \
    -H "Authorization: Bearer sk-****"
{"error":{"message":"litellm.BadRequestError: You passed in model=None. There are no healthy deployments for this model","type":null,"param":null,"code":"400"}}
HTTP 400

For contrast, GET /v1/responses/{id} on the same encrypted id returns HTTP 200 on the same unpatched proxy, since aget_responses is already in the hook's decrypt list

After (proxy on this branch, same config and port): identical commands, and input_items now returns the real item list from OpenAI

$ curl -s http://127.0.0.1:53798/v1/responses -H "Authorization: Bearer sk-****" -H "Content-Type: application/json" \
    -d '{"model":"openai-responses-test","input":"Say hello in five words"}'
{"id":"resp_JzWHWd230cj_Ebm7DMjhM3sBpOoWFVdMnEOCGNSqVsXJ8_RyJgCwkR1...",...}

$ curl -s -w '\nHTTP %{http_code}\n' "http://127.0.0.1:53798/v1/responses/resp_JzWHWd230cj_Ebm7DMjhM3sBpOoWFVdMnEOCGNSqVsXJ8_RyJgCwkR1.../input_items" \
    -H "Authorization: Bearer sk-****"
{"object":"list","data":[{"id":"msg_0935ac0038198c91006a4c101feb98819983674218e12a92d6","type":"message","status":"completed","content":[{"type":"input_text","text":"Say hello in five words"}],"role":"user"}],"first_id":"msg_0935ac0038198c91006a4c101feb98819983674218e12a92d6","has_more":false,"last_id":"msg_0935ac0038198c91006a4c101feb98819983674218e12a92d6"}
HTTP 200

Type

🐛 Bug Fix

Changes

The ResponsesIDSecurity hook (on by default) encrypts the id returned by POST /v1/responses and decrypts it again in async_pre_call_hook, but only for the call types listed in its responses_api_call_types set. alist_input_items was missing from that set, so GET /v1/responses/{response_id}/input_items forwarded the still-encrypted id to the router; the router could not decode the provider and model from it and failed with a 400 "You passed in model=None. There are no healthy deployments for this model". Every follow-up route that got its call type added to the set works (get, delete, cancel), which made input_items the odd one out. Reported by a customer; reproduced against both openai/gpt-4o-mini and azure/gpt-4o, so it is provider-agnostic

The fix adds alist_input_items to the set and to the branch that decrypts data["response_id"], which is exactly the key get_response_input_items in litellm/proxy/response_api_endpoints/endpoints.py populates from the path parameter. This also means the hook's user/team access check now runs for input_items follow-ups, closing the gap where the route skipped check_user_access_to_response_id entirely

Two regression tests were added to the existing tests/test_litellm/test_responses_id_security.py: one asserts async_pre_call_hook with call_type="alist_input_items" decrypts response_id, the other asserts a key from team A gets a 403 when listing input items of a response owned by team B. Both fail on the unpatched hook

Note: there is a separate Azure-specific bug in how the upstream input_items URL is built (path segment appended after the query string), being fixed in another PR. On Azure deployments, input_items needs both fixes to work end to end

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@greptile-apps

greptile-apps Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a missing entry in the ResponsesIDSecurity hook so that GET /v1/responses/{id}/input_items correctly decrypts the encrypted response ID before forwarding it to the router, and applies the same user/team access guard that already covers the get, delete, and cancel routes.

  • Hook fix: "alist_input_items" is added to both the responses_api_call_types set and the elif branch that reads and decrypts data["response_id"], making alist_input_items consistent with the other follow-up call types.
  • Tests: Two new unit tests (no network calls) cover the decrypt path and the cross-team 403 guard for alist_input_items.

Confidence Score: 5/5

The change is a two-line addition to an existing set/branch pattern already proven for identical follow-up routes; risk of regression is minimal.

The code path for alist_input_items is now exactly parallel to aget_responses, adelete_responses, and acancel_responses — no new logic is introduced, only a string value is added to an existing set and an existing elif condition. The endpoint already sets data["response_id"] from the path parameter unconditionally, so the hook reads a value that is always present. The two new mock tests directly exercise the decrypt and the team-403 paths. No pre-existing issues are worsened, and no new behavioral surface is introduced beyond what the other call types already expose.

No files require special attention.

Important Files Changed

Filename Overview
litellm/proxy/hooks/responses_id_security.py Adds alist_input_items to the responses API call type set and to the elif branch that decrypts data["response_id"], closing the gap that caused input-item follow-ups to fail with a model-not-found 400.
tests/test_litellm/test_responses_id_security.py Adds two focused mock tests: one verifying response_id is decrypted for alist_input_items, the other asserting a cross-team access attempt raises HTTP 403 — both tests use no real network calls.

Reviews (1): Last reviewed commit: "fix(responses_id_security): decrypt resp..." | Re-trigger Greptile

@greptile-apps

greptile-apps Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a missing entry in the ResponsesIDSecurity hook so that GET /v1/responses/{id}/input_items decrypts the encrypted response ID before forwarding it to the router, mirroring what the hook already does for get, delete, and cancel response routes.

  • alist_input_items is added to responses_api_call_types and to the elif branch that decrypts data[\"response_id\"], bringing it in line with the existing aget_responses/adelete_responses/acancel_responses pattern.
  • Two new mock-only regression tests cover the happy-path decryption and the cross-team 403 case for alist_input_items; no real network calls are made.

Confidence Score: 5/5

The change is a two-line addition that closes a gap in the hook's call-type allowlist; it has no effect on any other code path.

Both changed files are small and self-contained. The hook fix correctly mirrors the established pattern for the other response follow-up routes, the new tests use mocks (no live network calls), cover both the success and the 403 path, and confirm the exact data mutation that was previously broken.

No files require special attention.

Important Files Changed

Filename Overview
litellm/proxy/hooks/responses_id_security.py Adds "alist_input_items" to the responses_api_call_types set and to the elif branch that decrypts data["response_id"], correctly mirroring the existing pattern for aget_responses/adelete_responses/acancel_responses.
tests/test_litellm/test_responses_id_security.py Adds two focused mock-only tests for alist_input_items: one for the happy-path decryption and one for the team-mismatch 403 case. No real network calls; all external dependencies are patched.

Reviews (1): Last reviewed commit: "fix(responses_id_security): decrypt resp..." | Re-trigger Greptile

@codecov

codecov Bot commented Jul 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@mateo-berri
mateo-berri enabled auto-merge (squash) July 6, 2026 20:59
@mateo-berri
mateo-berri merged commit fab4a9c into litellm_internal_staging Jul 6, 2026
75 checks passed
@mateo-berri
mateo-berri deleted the litellm_fix_responses_input_items_decrypt branch July 6, 2026 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants