Skip to content

Reduce dependency attack surface: evaluate removing LiteLLM and Pillow #1806

Closed

Description

@phernandez

Problem

Track reducing Basic Memory's dependency attack surface by removing, replacing, or making optional LiteLLM and/or Pillow. This is separate from the immediate dependency updates and image-decoder restriction in #1805.

Pillow remains locked at 12.3.0 because fastembed constrains Pillow below 13. The GIF allowlist mitigation in #1805 initially left GHSA-74r2-7ff9-mjj2 reachable: quadratic CPU consumption occurs inside Image.open(), before resizing. Follow-up on that PR removes GIF from the allowed decoders, including GIF files disguised with a .png extension. This is a targeted mitigation, not a claim that every Pillow advisory is resolved.

LiteLLM has a documented supply-chain compromise affecting PyPI versions 1.82.7 and 1.82.8. The maintainer report is dated March 24, 2026; this issue does not assert that the current 1.91.5 lock is compromised or that Basic Memory installed an affected release. SDK-only use does not by itself protect against malicious package initialization code.

Work

  • Inventory LiteLLM embedding/reranking usage and Pillow decoding, including transitive requirements from fastembed and document ingestion.
  • Evaluate direct provider SDKs or smaller adapters in place of LiteLLM, preserving configured provider behavior, cancellation, retries and errors.
  • Evaluate removing Pillow-based image transformation, making it optional, or decoding in a resource-limited subprocess. Preserve a clear user-facing unsupported-format response.
  • Identify whether removing the direct dependency actually removes it from default and optional dependency graphs.
  • Resolve the fastembed/Pillow constraint before claiming a Pillow upgrade is available to PyPI consumers; a local uv override alone is insufficient.
  • Review release/lock history against confirmed compromised LiteLLM versions. Escalate any evidence of installation separately; do not assume exposure from package presence alone.
  • Refresh the advisory inventory and classify actual reachable paths, especially still-allowed image formats. Do not rely on a fixed advisory count.

Acceptance criteria

  • Document the keep/remove/replace decision for each dependency, with compatibility and maintenance costs.
  • Ship the selected changes with provider and image behavior regression tests.
  • Verify published package metadata, default installation and supported extras, not only uv.lock.
  • Ensure blocked formats are rejected before invoking their decoders; test file content independently of extension/MIME.
  • Record remaining reachable security risks and owners; do not close this issue solely because fix(deps): update security dependencies and container trust stores #1805 merges.

References

Activity

  1. claude commented on Oct 22, 2026

    @claude
    Contributor

    Claude finished @phernandez's task in 21s —— View job


    Triage

    • Type: Enhancement (security hardening / dependency reduction). Labeled enhancement.
    • Priority: High. This is a security-driven supply-chain and attack-surface item. It isn't an active breakage, and the immediate mitigation is already in fix(deps): update security dependencies and container trust stores #1805.
    • Component: Core dependencies and packaging. The areas involved are embedding/reranking providers (LiteLLM), image/document ingestion (Pillow), and the fastembed transitive constraint. It is not Cloud-specific, so no cloud label.
    • Complexity: Complex.
      • Replacing LiteLLM means re-implementing provider behavior, cancellation, retries and errors.
      • Pillow can't be upgraded for PyPI consumers until the fastembed <13 constraint is resolved. A local uv override isn't enough.
      • The work also includes verifying published metadata and extras, not just uv.lock.
    • Duplicates: A search found none. fix(deps): update security dependencies and container trust stores #1805 is the related mitigation PR, not a duplicate.

    Suggested split

    The issue bundles several separable tracks. Splitting them could make progress easier to track:

    1. Inventory and decision doc: keep, remove or replace for each of LiteLLM and Pillow, including the transitive graph for default install and extras.
    2. LiteLLM replacement or making it optional, with provider regression tests.
    3. Pillow: remove it, make it optional, or decode in a resource-limited subprocess. Rejection of blocked formats must be tested by content, independent of extension and MIME.
    4. Upstream fastembed/Pillow constraint resolution.
    5. Review of release and lock history against the compromised LiteLLM versions, with any evidence of installation escalated separately.

    I haven't made any code changes. This pass was triage only.

  2. Flynn-Kawolsky commented on Oct 30, 2026

    @Flynn-Kawolsky

    Thank you for tracking this. One data point from a user of the LiteLLM path: I use Voyage for both embeddings (voyage-4-large, with document and query input types) and reranking (rerank-3), through semantic_embedding_provider = "litellm" and reranker_provider = "litellm". In 1.0 the rerank factory offers only fastembed and litellm, so LiteLLM is currently the only way to use a hosted reranker. If LiteLLM is replaced with direct adapters, could Voyage embeddings (with input types and output dimensions) and Voyage reranking stay covered? I'd be happy to test a branch on Windows.

  3. phernandez commented on Nov 3, 2026

    @phernandez
    MemberAuthor

    litellm is an optional dep now fyi

  4. added this to the nextup milestone on Nov 3, 2026
  5. phernandez commented on Nov 12, 2026

    @phernandez
    MemberAuthor

    Decision

    LiteLLM: keep it as an optional extra. No replacement with direct provider SDKs.
    Pillow: keep it as a direct dependency, upgraded to 13.0.0 (#2100).

    LiteLLM

    • Since 4411661 (2026-10-27, shipped in v1.0.0), LiteLLM is only in the litellm extra (litellm>=1.91.5,<1.92.0). A default install, from PyPI or Homebrew, doesn't pull it in. Local FastEmbed and OpenAI embeddings don't need it.
    • Configuring semantic_embedding_provider = "litellm" or reranker_provider = "litellm" without the extra raises SemanticDependenciesMissingError. The error says how to install basic-memory[litellm] with uv, pip, or uvx for Homebrew installs.
    • We are keeping LiteLLM rather than writing direct adapters. It is still the only route to hosted rerankers and to providers such as Voyage, the embeddings and reranking setup described in the comment above. Replacing it would mean writing and maintaining provider adapters with their own retry, cancellation and error handling. Users who want the smaller footprint already have it by not installing the extra.
    • Lock history: the compromised releases 1.82.7 and 1.82.8 never appear in this repository. LiteLLM first entered uv.lock on 2026-06-07 (feat(core): add LiteLLM embedding provider #809, 1.85.0), after the March 24 incident. Every uv.lock revision on main has locked 1.85.0, 1.91.3 or 1.91.5. Releases: v0.22.0–v0.22.1 locked 1.85.0, v0.23.0–v0.23.2 locked 1.91.3, and v0.24.0, v0.24.1 and v1.0.0 locked 1.91.5. v0.24.x listed LiteLLM as a default dependency, and v1.0.0 made it optional.

    Pillow

    • Our code uses it directly: bm_read decodes an image and re-encodes it as a JPEG under the inline size budget (src/basic_memory/mcp/file_content.py). Dropping it would mean returning raw image bytes with no resizing. fastembed (required) and python-pptx (documents extra) also depend on it, so removing our own use wouldn't take it out of the install.
    • Upgrade path: fastembed 0.9.1 allows pillow<14, so fix(deps): upgrade Pillow to 13.0.0 and fastembed to 0.9.1 #2100 raises the minimums to fastembed>=0.9.1 and pillow>=13.0.0. Pillow 13.0.0 fixes the October/November advisories, including GHSA-74r2-7ff9-mjj2. The higher minimums apply to PyPI installs, not just our lock.
    • Embeddings unchanged: bge-small-en-v1.5 vectors from fastembed 0.8.0 and 0.9.1 are identical (max abs diff 0.0), so no reindex is needed. The model cache folder was renamed (models--Qdrant--bge-small-en-v1.5-onnx-Q), so a Linux install downloads the model once more. Cloud's image downloads the model at build time and is unaffected; that check is in fix(deps): upgrade Pillow to 13.0.0 and fastembed to 0.9.1 #2100.
    • Blocked formats: bm_read still decodes only PNG, JPEG and WEBP. Pillow chooses the decoder from the file's bytes, not its extension or MIME type, and the allowlist is passed to Image.open(formats=...), so other decoders never run. A GIF named .png is refused. Tests are in tests/mcp/test_tool_bm_read.py.

    Remaining risk

    • The PNG, JPEG and WEBP decoders still parse user-supplied bytes. Owner: core. We keep pillow>=13 and take Pillow security releases as they ship.
    • LiteLLM's supply-chain exposure now applies only to users who install the extra. The <1.92.0 cap stays until 1.92's Rust bridge works on Python 3.14.
    • After Cloud re-pins core, it can remove its pillow>=13.0.0 override.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions