Proof Portal

Project overview

litellm

BerriAI117 findings · 107 requirements

LiteLLM Python->Rust migration audit (proof mirroring).

Back to findings
Known issueKI-ocr-rust-parse-upstream

Python->Rust divergence: OCR response JSON parse + parse-error re-raise relocated upstream in Rust

OpenOpenLow

Low-severity issue, currently open.

How well is this finding proven?

  1. 1.Reported / candidate

    Complete

  2. 2.Reproducer written

    Complete

    View reproducer
  3. 3.Reproduces (recorded run)

    Not yet established

    View evidence
  4. 4.Independently re-run

    Not yet established

  5. 5.Meets quality standard

    Not assessed

  6. 6.Validated for submission

    Not assessed

Recorded runs show whether the issue reproduces. Independent re-runs are shown separately. A later review does not fill in a missing earlier step.

Description

The issue as recorded.

Cross-language parity finding for MIR-001. The Python MistralOCRConfig.transform_ocr_response parses raw_response.json() inline and re-raises on an unparseable body (SW-REQ-260701-2CEW). The Rust core transform (crates/core/src/providers/mistral/ocr/transformation.rs) receives an already-parsed serde_json::Value, so it has no JSON-parse step and no parse-failure path to re-raise; the whole SW-REQ-260701-2CEW obligation set (error_handling, malformed_input, errors_propagated, malformed_recovers_or_errors_loudly, and both parse_error_raised MC/DC rows) plus the DEP5 ocr_response_returned=F,response_parseable=F MC/DC row have no witness in the core transform. The raw HTTP body decode and its parse-error propagation are structurally relocated upstream to the ai-gateway OCR handler (crates/ai-gateway/src/ocr), which is outside MIR-001 target scope. This is an architectural divergence, not a defect: behavior is preserved end-to-end but its home in the module graph differs. No litellm or Rust behavior is changed.

Reachability

Evidence disposition (issue #392): this finding documents an ABSENCE in the Rust target (litellm-rust/crates/, outside the Python verification_scope in proof.yaml), established by the static grep/read recorded in reproducer_command. There is no runnable Python-scope tripwire that can reproduce a Rust-side absence, so proof evidence refresh cannot stamp a current evidence row. Reviewed and accepted as honest tracked debt below the runnable-reproducer floor; fabricating an evidence hash would be dishonest.

Affected requirements

The requirement(s) this issue violates — click through to the spec.

Port parity

How this finding relates to the port: whether the behaviour diverges, isn't ported yet, was fixed, or matches across both implementations.

  • Mistral OCR: Python -> RustMIR-001
    Diverges on the Rust portPython → Rust
    View in Mirrors

Severity, explained

Why this is rated the way it is — and the scoring signals behind the rating (each ⓘ explains the term).

LowRated severity — the impact if this issue is exploited or hit.
why this rating
Risk-rated
risk area
Correctness
Security classification
Not a security surface
CVE surface
None

Where it is

The code the issue lives in — peek the affected function inline to see it in context.

  • MistralOCRConfig.transform_ocr_response (Python) vs providers::mistral::ocr::transformation::transform_ocr_response (Rust core)

Reproducer and evidence

The recorded reproducer and its evidence-run outcome. Inspect the test and source, or run the command to check the behavior yourself.

Recorded
Reproducer test
from // Reproduces: marker
Run it yourself
read crates/core/src/providers/mistral/ocr/transformation.rs:105-143 (transform_ocr_response takes a pre-parsed Value; no .json() decode); the parse+re-raise live in crates/ai-gateway/src/ocr

Reproduction steps

Technical steps for your engineers to confirm the issue by hand.

read crates/core/src/providers/mistral/ocr/transformation.rs:105-143 (transform_ocr_response takes a pre-parsed Value; no .json() decode); the parse+re-raise live in crates/ai-gateway/src/ocr

What protects you, and the fix

What limits your exposure today, and the planned remediation.

What protects you now

Cover SW-REQ-260701-2CEW parse-error behavior in the ai-gateway OCR handler tests (out of MIR-001 target scope); the core transform correctly has no parse step to witness.

The fix

Audit/divergence finding only. Track the parse-error obligations against the ai-gateway OCR call path; no change to the core transform.

Blast radius

If you touch this issue, what else may need re-checking — the requirements it affects and the code and tests that hang off them. Historical view: authored trace links only — automatically derived links aren't reconstructible for past runs.

Tracing blast radius…

Touch this finding and you re-check 2 requirements · 2 code files · 1 tests.

Code files (2)
  • transformation.rs
  • transformation.py
Tests (1)
  • test_mistral_ocr_transformation.py

Per-requirement evidence

For each requirement this finding touches: the implementing code, verifying tests, and proof obligations that discharge it.

Implementing code (2)
  • litellm-rust/crates/core/src/providers/mistral/ocr/transformation.rs
    MistralOcrConfig.transform_ocr_response
  • litellm/llms/mistral/ocr/transformation.py
    MistralOCRConfig.transform_ocr_response
Tests & evidence (2)
  • docs/requirements/mistral_ocr.md
  • tests/test_litellm/llms/mistral/ocr/test_mistral_ocr_transformation.py
Proof obligations (4)
error_handling

Behavior when operations fail or dependencies are unavailable.

  • ✓negative (required) — tests/test_litellm/llms/mistral/ocr/test_mistral_ocr_transformation.py:350
  • ✓nominal (required) — tests/test_litellm/llms/mistral/ocr/test_mistral_ocr_transformation.py:230
errors_propagated

Errors from called functions shall be propagated to the caller (or transformed into a typed error); they shall not be silently dropped, swallowed, or downgraded to a default value.

  • ✓nominal (required) — tests/test_litellm/llms/mistral/ocr/test_mistral_ocr_transformation.py:352
malformed_input

Behavior when inputs are syntactically or structurally invalid.

  • ✓negative (required) — tests/test_litellm/llms/mistral/ocr/test_mistral_ocr_transformation.py:351
  • ✓nominal (required) — tests/test_litellm/llms/mistral/ocr/test_mistral_ocr_transformation.py:231
malformed_recovers_or_errors_loudly

Parsers shall declare their malformed-input policy: either documented recovery (and what is preserved) or loud error with no partial state.

  • ✓negative (required) — tests/test_litellm/llms/mistral/ocr/test_mistral_ocr_transformation.py:353
  • ✓nominal (required) — tests/test_litellm/llms/mistral/ocr/test_mistral_ocr_transformation.py:232
Implementing code (2)
  • litellm-rust/crates/core/src/providers/mistral/ocr/transformation.rs
    MistralOcrConfig.transform_ocr_response
  • litellm/llms/mistral/ocr/transformation.py
    MistralOCRConfig.transform_ocr_response
Tests & evidence (3)
  • docs/requirements/mistral_ocr.md
  • litellm-rust/crates/core/src/providers/mistral/ocr/transformation.rs
  • tests/test_litellm/llms/mistral/ocr/test_mistral_ocr_transformation.py
Proof obligations (3)
nominal

Happy-path behavior with valid inputs.

  • ✓nominal (required) — litellm-rust/crates/core/src/providers/mistral/ocr/transformation.rs:366, tests/test_litellm/llms/mistral/ocr/test_mistral_ocr_transformation.py:229
pure_function_property_tested

A function declared pure (no I/O, no global state, output is f(input) only) shall carry property-based tests that exercise its declared algebraic properties (determinism, totality, commutativity, monotonicity, idempotency — whichever apply); example-based tests alone shall not be sufficient evidence for a pure-function obligation.

  • ✓nominal (required) — litellm-rust/crates/core/src/providers/mistral/ocr/transformation.rs:367, tests/test_litellm/llms/mistral/ocr/test_mistral_ocr_transformation.py:227
untrusted_input_bounded

Deserialization of untrusted input shall enforce schema, type, and size bounds before any object construction.

  • ✗nominal (required)

Change history

Every recorded revision of this finding's source file — when it was added, edited, or re-classified, with the diff for each change.

Discussions

Discuss this with the proof team. Nothing changes in your audit automatically — you open a request and a staff member records any outcome inside the thread.

Sign in to discuss this with the proof team.Sign in