langchain - 💡(How to fix) Fix Bug: path traversal in Chroma.add_images() via unsanitized URI [1 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Fix Action

Fixed

Code Example

import chromadb
from langchain_chroma import Chroma

store = Chroma(client=chromadb.Client(), embedding_function=None)
store.add_images(uris=["../../../../etc/passwd"])  # reads arbitrary file, returns content base64-encoded
RAW_BUFFERClick to expand / collapse

Package: langchain-chroma

Description

Chroma.add_images(uris=[...]) passes caller-supplied URIs directly to Path(uri).open("rb") with no validation. Any caller with access to the public API can read arbitrary files from the filesystem.

Reproducer

import chromadb
from langchain_chroma import Chroma

store = Chroma(client=chromadb.Client(), embedding_function=None)
store.add_images(uris=["../../../../etc/passwd"])  # reads arbitrary file, returns content base64-encoded

Expected behavior

ValueError raised before the file is opened.

Proposed fix

Add a _validate_image_uri instance method called before encode_image opens the file:

  • Default (no config): reject absolute paths and any .. path component
  • With allowed_image_dir (new keyword-only __init__ param): resolve path canonically and enforce containment within the allowed directory (symlinks followed via Path.resolve())

I have a working fix + unit tests ready. Happy to submit a PR once assigned.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

langchain - 💡(How to fix) Fix Bug: path traversal in Chroma.add_images() via unsanitized URI [1 pull requests]