[GH-ISSUE #2478] [Issue]: sidecar embeddings endpoint performs request-controlled outbound fetches without SSRF screen or admin gate (server mode) #1222

Closed
opened 2026-10-21 05:29:16 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @Romuromylus on GitHub (Jun 6, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2478

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Severity: Low — security (SSRF), server runtime only. The sidecar_embeddings HTTP endpoint accepts a fully request-supplied connection/provider object (including baseUrl) and performs server-side embedding fetches with no admin-secret gate and no SSRF/private-IP screen, so a request can drive an outbound fetch to an internal/metadata host (e.g. 169.254.169.254).

Expected behavior

Request-supplied embedding connections should be treated like other privileged provider operations: require admin access (as the privileged remote commands do), and/or run the resolved base URL through the same private-IP/SSRF screen the LLM and load_url_binary paths use.

Actual behavior

// src-tauri/src/http_server.rs:1111 (sidecar_embeddings_inner; handler :1084, route :155)
// accepts request-supplied connection/provider (1113-1117), passes straight to prompts::embed_text
  • No admin gate: sidecar_embeddings is not in is_privileged_remote_command (:1023-1042) and never calls require_admin_access_for_command.
  • Weak/disabled SSRF screen: embed_text → batch embedders call ensure_embedding_url_allowed (prompts.rs:858), which delegates to is_allowed_outbound_url(url, /*allow_local=*/true). In crates/security/src/lib.rs:90-92, allow_local short-circuits to true after only a scheme check — it blocks file:// but not private/link-local/metadata hosts. The crate has the proper screen (is_local_or_reserved_ipv4) and the LLM path uses the strict is_allowed_provider_url(false), but the embedding path opts into allow_local = true.

So a request with baseUrl: http://169.254.169.254/... reaches the outbound client. Reachable on desktop loopback (by-design no-auth) and, in opt-in server mode, by any caller that passes the existing CSRF/basic-auth/IP-allowlist middleware.

Steps to reproduce

  1. Run the opt-in Axum server (or hit the localhost endpoint).
  2. POST /api/sidecar/v1/embeddings with {"input":"x","connection":{"provider":"openai","baseUrl":"http://169.254.169.254/..."}} from a context that passes the middleware.
  3. The server issues the outbound request to the request-specified host.

Impact area

  • Shared API wrapper or remote runtime routing
  • Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime

Environment

  • Branch or commit: refactor @ 1fae2c42
  • Run mode: remote / Docker runtime (opt-in Axum server); also localhost
  • OS + version: found via static source audit (not runtime-reproduced)
  • Node + pnpm versions: n/a (static audit)
  • Rust version, if relevant: n/a (static audit)
  • Remote Runtime URL configured? yes (server mode)
  • Provider, model, or integration, if relevant: embeddings

Logs, screenshots, or video

Static trace: http_server.rs:1084/1111 (handler/inner, no admin gate, not in is_privileged_remote_command :1023-1042); prompts.rs:858 ensure_embedding_url_allowed → is_allowed_outbound_url(url, true); crates/security/src/lib.rs:90-92 (allow_local short-circuit). Contrast strict screen used by llm.rs:1539 and http.rs.

Regression notes

Not a regression — http_server.rs / the Rust embedding transport are refactor-only surfaces with no main (web) equivalent. Filing as a refactor bug. Server-mode-only and behind the existing middleware for remote callers, so Low. Distinct from the previously-filed SSRF on load_url_binary / the provider-transport cluster (different sink).

Additional context

Fix: pass allow_local = false for embedding base URLs (use the strict is_allowed_provider_url), and/or require admin access for request-supplied embedding connections like the other privileged provider operations. Strongest-class fix-pattern-already-in-repo inconsistency — the sibling load_url_binary/LLM paths already screen private hosts.

Template check

Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Romuromylus on GitHub (Jun 6, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2478 Originally assigned to: @SpicyMarinara on GitHub. ## Summary **Severity: Low — security (SSRF), server runtime only.** The `sidecar_embeddings` HTTP endpoint accepts a fully request-supplied connection/provider object (including `baseUrl`) and performs server-side embedding fetches with no admin-secret gate and no SSRF/private-IP screen, so a request can drive an outbound fetch to an internal/metadata host (e.g. `169.254.169.254`). ## Expected behavior Request-supplied embedding connections should be treated like other privileged provider operations: require admin access (as the privileged remote commands do), and/or run the resolved base URL through the same private-IP/SSRF screen the LLM and `load_url_binary` paths use. ## Actual behavior ```rust // src-tauri/src/http_server.rs:1111 (sidecar_embeddings_inner; handler :1084, route :155) // accepts request-supplied connection/provider (1113-1117), passes straight to prompts::embed_text ``` - No admin gate: `sidecar_embeddings` is not in `is_privileged_remote_command` (`:1023-1042`) and never calls `require_admin_access_for_command`. - Weak/disabled SSRF screen: `embed_text` → batch embedders call `ensure_embedding_url_allowed` (`prompts.rs:858`), which delegates to `is_allowed_outbound_url(url, /*allow_local=*/true)`. In `crates/security/src/lib.rs:90-92`, `allow_local` short-circuits to `true` after only a scheme check — it blocks `file://` but **not** private/link-local/metadata hosts. The crate has the proper screen (`is_local_or_reserved_ipv4`) and the LLM path uses the strict `is_allowed_provider_url(false)`, but the embedding path opts into `allow_local = true`. So a request with `baseUrl: http://169.254.169.254/...` reaches the outbound client. Reachable on desktop loopback (by-design no-auth) and, in opt-in server mode, by any caller that passes the existing CSRF/basic-auth/IP-allowlist middleware. ## Steps to reproduce 1. Run the opt-in Axum server (or hit the localhost endpoint). 2. `POST /api/sidecar/v1/embeddings` with `{"input":"x","connection":{"provider":"openai","baseUrl":"http://169.254.169.254/..."}}` from a context that passes the middleware. 3. The server issues the outbound request to the request-specified host. ## Impact area - [x] Shared API wrapper or remote runtime routing - [x] Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime ## Environment - Branch or commit: refactor @ 1fae2c42 - Run mode: remote / Docker runtime (opt-in Axum server); also localhost - OS + version: found via static source audit (not runtime-reproduced) - Node + pnpm versions: n/a (static audit) - Rust version, if relevant: n/a (static audit) - Remote Runtime URL configured? yes (server mode) - Provider, model, or integration, if relevant: embeddings ## Logs, screenshots, or video Static trace: `http_server.rs:1084/1111` (handler/inner, no admin gate, not in `is_privileged_remote_command` `:1023-1042`); `prompts.rs:858` `ensure_embedding_url_allowed` → `is_allowed_outbound_url(url, true)`; `crates/security/src/lib.rs:90-92` (allow_local short-circuit). Contrast strict screen used by `llm.rs:1539` and `http.rs`. ## Regression notes Not a regression — `http_server.rs` / the Rust embedding transport are refactor-only surfaces with no main (web) equivalent. Filing as a refactor `bug`. Server-mode-only and behind the existing middleware for remote callers, so Low. Distinct from the previously-filed SSRF on `load_url_binary` / the provider-transport cluster (different sink). ## Additional context Fix: pass `allow_local = false` for embedding base URLs (use the strict `is_allowed_provider_url`), and/or require admin access for request-supplied embedding connections like the other privileged provider operations. Strongest-class fix-pattern-already-in-repo inconsistency — the sibling `load_url_binary`/LLM paths already screen private hosts. ## Template check Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:29:16 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Jun 6, 2026):

Fixed on refactor in 038b7220.

Embedding endpoints now use the provider URL SSRF allow-list instead of the broad outbound sidecar allowance, so request-controlled local/admin targets are rejected.

Verification: pnpm typecheck; pnpm build; pnpm check:architecture; cargo check --manifest-path src-tauri/Cargo.toml --workspace; focused Rust backup/profile tests; git diff --check; no .test.ts/.test.tsx files present.

<!-- gh-comment-id:4638719210 --> @SpicyMarinara commented on GitHub (Jun 6, 2026): Fixed on refactor in 038b7220. Embedding endpoints now use the provider URL SSRF allow-list instead of the broad outbound sidecar allowance, so request-controlled local/admin targets are rejected. Verification: pnpm typecheck; pnpm build; pnpm check:architecture; cargo check --manifest-path src-tauri/Cargo.toml --workspace; focused Rust backup/profile tests; git diff --check; no .test.ts/.test.tsx files present.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#1222
No description provided.