Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions packages/desktop/src-tauri/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,28 @@ pub fn spawn_command(
state_dir.to_string_lossy().to_string(),
),
];

// Pass through token compression proxy URL to the sidecar process.
// When ADAL_APP_URL is set, the sidecar routes LLM requests through
// the specified proxy for transparent compression or middleware.
// Only localhost/loopback URLs are accepted to prevent unintended
// traffic routing to external endpoints.
if let Some(app_url) = std::env::var_os("ADAL_APP_URL") {
if let Some(url_str) = app_url.to_str() {
if url_str.starts_with("http://localhost")
|| url_str.starts_with("http://127.0.0.1")
|| url_str.starts_with("http://[::1]")
{
envs.push(("ADAL_APP_URL".to_string(), url_str.to_string()));
} else {
tracing::warn!(
url = %url_str,
"Ignoring ADAL_APP_URL: only localhost URLs are permitted"
);
}
}
}
Comment on lines +392 to +411
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed in force-push. Now validates that only localhost/loopback URLs are accepted:

if url_str.starts_with("http://localhost")
    || url_str.starts_with("http://127.0.0.1")
    || url_str.starts_with("http://[::1]")

Non-local URLs are rejected with tracing::warn. This prevents any env injection from routing sensitive traffic externally.

HTTPS enforcement was considered but intentionally omitted — localhost proxies typically run plain HTTP (TLS adds complexity for loopback with no security benefit since traffic never leaves the machine).


envs.extend(
extra_env
.iter()
Expand Down
Loading