Proof Portal

Project overview

litellm

BerriAI117 findings · 107 requirements

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

Back to findings
Known issueKI-rust-ocr-response-shape-omits-null-fields

Python->Rust OCR response shape divergence: Rust into_json omits the always-serialized null OCRResponse fields (content/tables/keyValuePairs and nested images/dimensions/credits/doc_size_bytes)

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

  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.

Differentially-confirmed cross-language shape parity gap on the OCR response path, uniform across mistral/vertex/azure. The Python OCRResponse pydantic model (litellm/llms/base_llm/ocr/transformation.py) declares content, tables and keyValuePairs (all default None) alongside pages/model/document_annotation/usage_info/object, and its page and usage_info sub-models declare images/dimensions and credits/doc_size_bytes; model_dump() therefore ALWAYS serializes those optional fields as null when the provider did not supply them. The Rust OcrResponseData::into_json (litellm-rust/crates/core/src/ocr/transformation.rs:20) hard-codes a five-key object {pages, model, document_annotation, usage_info, object} and its pages/usage_info are pass-through Value clones, so it never emits content/tables/keyValuePairs at the top level and never fills the nested images/dimensions/credits/doc_size_bytes null keys. vertex and azure both delegate their response transform to MISTRAL_OCR_CONFIG.transform_ocr_response, so the gap is one root cause across all three. Concrete py-vs-rust for an empty response ({"response":{}}, model=""): python={"pages":[],"model":"","document_annotation":null,"usage_info":null,"content":null,"tables":null,"keyValuePairs":null,"object":"ocr"} vs rust={"pages":[],"model":"","document_annotation":null,"usage_info":null,"object":"ocr"} (three top-level keys missing). With a populated page {"index":0,"markdown":"x"} and usage_info {"pages_processed":1} the python page also carries images:null/dimensions:null and usage_info carries credits:null/doc_size_bytes:null, which the Rust pass-through drops. Impact is compat only: the extra fields are always null when absent, so a lenient client is unaffected, but a client that validates the standardized OCRResponse against an exact key set sees different shapes between the two implementations. Note the formal requirement SW-REQ-260701-DEP5 mandates only the five core fields, all of which Rust does emit; this divergence is a superset the Python pydantic model always serializes, not a DEP5 violation. Per the baseline rule (Python is source of truth, Rust must reproduce Python behavior) the fix direction is Rust: OcrResponseData should serialize the same field set Python does. AUDIT-ONLY: no code changed.

Reachability

The divergent side is the Rust target (litellm-rust/crates/core/src/ocr/transformation.rs), which sits outside the Python verification_scope in proof.yaml, so no in-scope Python evidence row is stamped and no evidence hash is fabricated. The divergence is nonetheless mechanically reproducible: both differential shims run and disagree (proof/shims/mistral_ocr_shim.py returns OCRResponse.model_dump(); the Rust proof_shim example returns OcrResponseData::into_json()). Folds in the differential-fuzzer candidates KI-FUZZ-9a27268ba4c4 (mistral_ocr.response), KI-FUZZ-69fb3fbf82b4 (vertex_ocr.response) and KI-FUZZ-4c88ccd736a3 (azure_ocr.response), which each recorded exactly this value-mismatch.

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
    Defect in the Rust port itselfPython → 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
Reproducer-confirmed
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.

  • core::ocr::transformation::OcrResponseData::into_json (Rust) vs OCRResponse.model_dump (Python, mistral/vertex/azure OCR response transforms)

Reproduction steps

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

proof differential fuzz mistral_ocr.response --seed 1 --iterations 15 (also vertex_ocr.response and azure_ocr.response; value-mismatch where python emits content/tables/keyValuePairs null and rust omits them)

What protects you, and the fix

What limits your exposure today, and the planned remediation.

What protects you now

Treat the Python OCRResponse.model_dump() field set as the reference response shape; a client that key-set-validates the standardized response should tolerate the missing optional keys until Rust is brought into line.

The fix

Serialize content/tables/keyValuePairs at the top level of OcrResponseData::into_json, and emit the nested images/dimensions (page) and credits/doc_size_bytes (usage_info) null keys, matching the Python pydantic serialization; then add a Rust test asserting an empty response serializes the full key set.

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 1 requirements · 2 code files · 1 tests.

Requirements (1)
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 (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