Skip to content

feat(rust): honor --allowed-media-domains and --allowed-local-media-path - #1811

Merged
AlpinDale merged 2 commits into
mainfrom
feat/rust-allowed-media-domains
Nov 14, 2026
Merged

AlpinDale merged 2 commits into
mainfrom
feat/rust-allowed-media-domains

Conversation

@AlpinDale

Copy link
Copy Markdown
Member

Python frontend already has this feature but it wasn't ported to Rust.

sonar-rs now accepts both options from the CLI and from the Python launcher's
JSON args instead of refusing to start.

The domain list goes to the media connector, which checks it on every redirect
hop and still refuses non-public addresses. file:// media URLs are read in the
chat crate under the canonical allowed directory (symlink and `..` escapes,
non-regular files and files over the media input cap are refused with a 400)
and handed to the tracker as data URLs, because the pinned llm-multimodal
tracker fetches every other URL over HTTP. The local path must be an existing
directory at startup, as in Python.

Signed-off-by: AlpinDale <alpindale@gmail.com>
Media the request got wrong or the media policy refuses (disallowed domain,
non-public host, refused redirect, too many redirects, unsupported scheme,
invalid URL, malformed data URL, undecodable image) is now a 400 instead of a
500. As in Python's `_wrap_media_fetch_error`, an origin 4xx other than 408 and
429 and a download over the size cap are a 422 with `param: image_url`.
Connection failures, timeouts, 5xx answers and audio or video decode failures
stay server errors.

Signed-off-by: AlpinDale <alpindale@gmail.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T01:23:05.048466Z ed11f92 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ed11f92dbc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if !fs::metadata(&canonical).map_err(read_error)?.is_file() {
return Err(not_regular());
}
let file = File::open(&canonical).map_err(read_error)?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Prevent symlink swaps when opening local media

If an untrusted local process can modify the allowed media directory while requests are running, it can replace a path component with a symlink after the canonical-path check but before this open. File::open then follows the replacement and can read a file outside the configured root; open relative to a pinned root with beneath/no-follow semantics, or verify the opened file itself remains confined.

Useful? React with 👍 / 👎.

@AlpinDale AlpinDale changed the title feat(rust): honor --allowed-media-domains and --allowed-local-media-path feat(rust): honor --allowed-media-domains and --allowed-local-media-path Nov 14, 2026
@AlpinDale
AlpinDale merged commit 461e453 into main Nov 14, 2026
2 checks passed
@AlpinDale
AlpinDale deleted the feat/rust-allowed-media-domains branch November 14, 2026 14:35
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.

1 participant