Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

refactor(network): one relaxed-network switch, on by default

vastsae4b46131fbd5
diff --git a/apps/desktop/electron/main/endpoint-policy.ts b/apps/desktop/electron/main/endpoint-policy.ts
index 2c3e1c809..cbaa61738 100644
--- a/apps/desktop/electron/main/endpoint-policy.ts
+++ b/apps/desktop/electron/main/endpoint-policy.ts
@@ -1,25 +1,115 @@
/**
- * The user's plaintext opt-in for endpoints they enter themselves, as the main
- * process currently holds it.
+ * The network policy in force for the endpoints the user enters themselves, as
+ * the main process currently holds it.
*
- * The judgement of what an address *is* lives in `@pi-desktop/shared`
- * (`public-network.ts`); whether the user accepted a plaintext hop to their own
- * LAN service lives in the stored app settings (`networkPolicy`). The public
- * network client runs synchronously per request, so the settings value is
+ * The policy itself lives in `@pi-desktop/shared` (`network-policy.ts`). The
+ * one mode it defines is `relaxed` — the default — which treats a loopback or
+ * LAN address the user typed as reachable, allows plain `http` to it, and
+ * tolerates a TUN proxy's fake-IP answers; `strict` keeps the public-HTTPS-only
+ * boundary for those endpoints too. Content the app did not receive from the
+ * user keeps the strict public-network rule in either mode. The public network
+ * client runs synchronously per request, so the stored settings value is
* mirrored here whenever the host hands the app its settings, exactly as
* `network-proxy.ts` mirrors the proxy.
*/
-import { allowInsecureUserEndpoints } from "@pi-desktop/shared";
+import {
+ DEFAULT_NETWORK_POLICY,
+ isRelaxedNetworkPolicy,
+ needsInsecureEndpointNotice as policyNeedsInsecureEndpointNotice,
+ normalizeNetworkPolicy,
+ type NetworkPolicySettings,
+} from "@pi-desktop/shared";
-let applied = false;
+let applied: NetworkPolicySettings = { ...DEFAULT_NETWORK_POLICY };
-/** Mirror the stored `networkPolicy` section; returns the effective flag. */
+/**
+ * Whether this process has already told the user that a plaintext hop to their
+ * own LAN is in use. It starts out as the stored answer and moves the moment
+ * the notice is shown; the renderer writes `insecureNoticeAcknowledged` back
+ * through the settings it already saves.
+ */
+let noticeAcknowledged = false;
+
+function networkPolicySection(settings: unknown): unknown {
+ return settings && typeof settings === "object"
+ ? (settings as { networkPolicy?: unknown }).networkPolicy
+ : undefined;
+}
+
+/**
+ * Mirror the stored `networkPolicy` section; returns whether the relaxed mode
+ * is in force. An absent section means the documented default, `relaxed`.
+ */
export function applyUserEndpointPolicyFromAppSettings(settings: unknown): boolean {
- applied = allowInsecureUserEndpoints(settings);
- return applied;
+ applied = normalizeNetworkPolicy(networkPolicySection(settings));
+ noticeAcknowledged = applied.insecureNoticeAcknowledged === true;
+ return relaxedNetworkPolicyEnabled();
}
-/** Whether plain `http` is currently allowed for a user-supplied endpoint. */
+/**
+ * Whether plain `http` is currently allowed for a user-supplied endpoint. This
+ * is the relaxed mode; only `strict` turns it off.
+ */
export function allowInsecureUserEndpointsEnabled(): boolean {
- return applied;
+ return relaxedNetworkPolicyEnabled();
+}
+
+/**
+ * Whether the relaxed mode is in force. The same answer as
+ * {@link allowInsecureUserEndpointsEnabled}, named for the decisions the mode
+ * itself owns (fake-IP tolerance, the one-time plaintext notice) so a call site
+ * never has to guess what the older name meant.
+ */
+export function relaxedNetworkPolicyEnabled(): boolean {
+ return isRelaxedNetworkPolicy({ networkPolicy: applied });
+}
+
+/** Whether the one-time plaintext notice still owes the user an explanation. */
+export function needsInsecureEndpointNotice(): boolean {
+ if (noticeAcknowledged) return false;
+ return policyNeedsInsecureEndpointNotice({ networkPolicy: applied });
+}
+
+/**
+ * Record that the one-time plaintext notice has been shown. Only the in-process
+ * flag moves here; persisting `networkPolicy.insecureNoticeAcknowledged` is the
+ * renderer's settings write.
+ */
+export function acknowledgeInsecureEndpointNotice(): void {
+ noticeAcknowledged = true;
+ applied = { ...applied, insecureNoticeAcknowledged: true };
+}
+
+/** The shell that can show the one-time plaintext notice, once main has one. */
+let noticeSink: ((host: string) => void) | null = null;
+/** Main's own guard against repeating a notice the renderer has not yet saved. */
+let noticeSent = false;
+
+/**
+ * Wire the renderer. `main/index.ts` points this at `sendToRenderer`, so the
+ * notice travels the same channel as every other host-originated event.
+ */
+export function setInsecureEndpointNoticeSink(
+ sink: ((host: string) => void) | null,
+): void {
+ noticeSink = sink;
+}
+
+/**
+ * A hop is about to travel as plain `http` to an endpoint the user typed. Tell
+ * the shell once, and only while the stored settings still owe the notice: the
+ * renderer saves `networkPolicy.insecureNoticeAcknowledged` after showing it.
+ *
+ * This is informational. The relaxed mode is already in force and the request
+ * proceeds; nothing here can block one.
+ */
+export function noteInsecureUserEndpoint(host: string): void {
+ if (!relaxedNetworkPolicyEnabled()) return;
+ if (noticeSent) return;
+ if (!needsInsecureEndpointNotice()) {
+ noticeSent = true;
+ return;
+ }
+ noticeSent = true;
+ noticeSink?.(host);
}
diff --git a/apps/desktop/electron/main/git-clone.ts b/apps/desktop/electron/main/git-clone.ts
index dc267a0d5..5f7d24a4f 100644
--- a/apps/desktop/electron/main/git-clone.ts
+++ b/apps/desktop/electron/main/git-clone.ts
@@ -5,7 +5,10 @@ import {
isGitCloneRepoName,
parseGitCloneUrl,
} from "../../src/lib/git-clone-url.ts";
-import { allowInsecureUserEndpointsEnabled } from "./endpoint-policy.ts";
+import {
+ allowInsecureUserEndpointsEnabled,
+ noteInsecureUserEndpoint,
+} from "./endpoint-policy.ts";
export { parseGitCloneUrl } from "../../src/lib/git-clone-url.ts";
@@ -77,6 +80,18 @@ export async function cloneGitRepository(input: {
if (!target) {
throw codedError("INVALID_ARGUMENT", "Enter a git repository URL");
}
+ if (target) {
+ try {
+ const parsed = new URL(input.url);
+ // A plaintext hop to the user's own git host is worth one notice.
+ if (parsed.protocol === "http:" || parsed.protocol === "git:") {
+ noteInsecureUserEndpoint(parsed.hostname.toLowerCase().replace(/\.+$/, ""));
+ }
+ } catch {
+ // An scp-style remote (`git@host:path`) carries no scheme, hence no
+ // plaintext URL to report.
+ }
+ }
const name = input.name ?? target.name;
if (!isGitCloneRepoName(name)) {
throw codedError("INVALID_ARGUMENT", "Enter a git repository URL");
diff --git a/apps/desktop/electron/main/index.ts b/apps/desktop/electron/main/index.ts
index 472cc63e7..3696802be 100644
--- a/apps/desktop/electron/main/index.ts
+++ b/apps/desktop/electron/main/index.ts
@@ -12,6 +12,7 @@ import {
currentNetworkProxy,
testNetworkProxy,
} from "./network-proxy";
+import { setInsecureEndpointNoticeSink } from "./endpoint-policy";
import {
APP_ID,
APP_NAME,
@@ -837,6 +838,16 @@ function sendToRenderer(channel: string, payload: unknown) {
}
}
+/**
+ * The relaxed network mode may carry one plaintext hop to an endpoint the user
+ * typed. Tell the shell once, through the same channel as every other
+ * host-originated event; the shell owns the wording and records the
+ * acknowledgement in settings (ADR 0304).
+ */
+setInsecureEndpointNoticeSink((host) => {
+ sendToRenderer(IPC.event.insecureEndpointNotice, { host });
+});
+
let appliedMenuSettings: string | null = null;
/**
diff --git a/apps/desktop/electron/main/mcp-registry-catalog.ts b/apps/desktop/electron/main/mcp-registry-catalog.ts
index 23f44993f..5aedc041f 100644
--- a/apps/desktop/electron/main/mcp-registry-catalog.ts
+++ b/apps/desktop/electron/main/mcp-registry-catalog.ts
@@ -37,8 +37,11 @@ import {
type RegistryRecord,
type SourcedCatalogEntry,
} from "@pi-desktop/shared";
-import { currentNetworkProxy } from "./network-proxy";
-import { allowInsecureUserEndpointsEnabled } from "./endpoint-policy";
+import {
+ allowInsecureUserEndpointsEnabled,
+ noteInsecureUserEndpoint,
+ relaxedNetworkPolicyEnabled,
+} from "./endpoint-policy";
const PAGE_SIZE = 100;
/** First browse paints two pages; every "load more" appends this many. */
@@ -123,6 +126,9 @@ async function resolvePublicUrl(
const deadline = Date.now() + timeoutMs;
const parsed = new URL(url);
const host = parsed.hostname.toLowerCase().replace(/\.+$/, "");
+ if (userSupplied && parsed.protocol === "http:") {
+ noteInsecureUserEndpoint(host);
+ }
const literal = host.startsWith("[") ? host.slice(1, -1) : host;
const route = await resolveProxyRoute(url, timeoutMs);
const remaining = deadline - Date.now();
@@ -136,7 +142,9 @@ async function resolvePublicUrl(
remaining,
);
if (!addresses.length) throw new Error(`hostname does not resolve: ${host}`);
- const allowFakeIp = currentNetworkProxy().allowFakeIp === true;
+ // Fake-IP answers are a property of the network policy, not of the proxy
+ // switch: the relaxed mode tolerates a transparent router's placeholders.
+ const allowFakeIp = relaxedNetworkPolicyEnabled();
for (const address of addresses) {
const addressKind = classifyIpLiteral(address.address);
const acceptable = userSupplied
diff --git a/apps/desktop/electron/main/network-proxy.ts b/apps/desktop/electron/main/network-proxy.ts
index b6949cc9d..9aff28871 100644
--- a/apps/desktop/electron/main/network-proxy.ts
+++ b/apps/desktop/electron/main/network-proxy.ts
@@ -79,8 +79,8 @@ export async function applyNetworkProxy(
export async function applyNetworkProxyFromAppSettings(
settings: unknown,
): Promise<NetworkProxySettings> {
- // The plaintext opt-in for user-supplied endpoints rides the same settings
- // write as the proxy, so one call site mirrors both.
+ // The network policy and the proxy ride the same settings write, so one call
+ // site mirrors both.
applyUserEndpointPolicyFromAppSettings(settings);
const record =
settings && typeof settings === "object"
diff --git a/apps/desktop/electron/main/public-https-fetch.ts b/apps/desktop/electron/main/public-https-fetch.ts
index 971ad1244..9d560a76a 100644
--- a/apps/desktop/electron/main/public-https-fetch.ts
+++ b/apps/desktop/electron/main/public-https-fetch.ts
@@ -157,6 +157,11 @@ export function createPublicHttpsClient(options: {
* `networkPolicy`. Never widens the third-party policy.
*/
allowInsecureUserEndpoints?: boolean | (() => boolean);
+ /**
+ * Called when a hop is about to travel as plain `http` to an endpoint the user
+ * typed. Informational: the caller tells the shell, and the request proceeds.
+ */
+ onInsecureUserEndpoint?: (host: string) => void;
timeoutMs?: number;
}): PublicHttpsClient {
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
@@ -204,8 +209,11 @@ export function createPublicHttpsClient(options: {
reason: "url-syntax",
});
}
- const host = new URL(url).hostname.toLowerCase().replace(/\.+$/, "");
- if (host.startsWith("[") || /^\d{1,3}(\.\d{1,3}){3}$/.test(host)) return;
+ const parsed = new URL(url);
+ const host = parsed.hostname.toLowerCase().replace(/\.+$/, "");
+ if (userSupplied && parsed.protocol === "http:") {
+ options.onInsecureUserEndpoint?.(host);
+ }
const route = await hopRoute(url);
let addresses: Array<{ address: string }>;
try {
diff --git a/apps/desktop/electron/main/skill-market-catalog.ts b/apps/desktop/electron/main/skill-market-catalog.ts
index e9c0b1e18..bd285b95d 100644
--- a/apps/desktop/electron/main/skill-market-catalog.ts
+++ b/apps/desktop/electron/main/skill-market-catalog.ts
@@ -9,8 +9,11 @@
import { net, session } from "electron";
import type { SkillCatalogEntry, SkillMarketSource } from "@pi-desktop/shared";
import { createPublicHttpsClient } from "./public-https-fetch";
-import { currentNetworkProxy } from "./network-proxy";
-import { allowInsecureUserEndpointsEnabled } from "./endpoint-policy";
+import {
+ allowInsecureUserEndpointsEnabled,
+ noteInsecureUserEndpoint,
+ relaxedNetworkPolicyEnabled,
+} from "./endpoint-policy";
import {
createSkillMarketAggregator,
type SkillMarketDocument,
@@ -29,10 +32,15 @@ export { guessSkillCategories } from "./skill-market-scan";
const client = createPublicHttpsClient({
fetchImpl: (url, init) => net.fetch(url, init),
routeImpl: (url) => session.defaultSession.resolveProxy(url),
- allowFakeIp: () => currentNetworkProxy().allowFakeIp === true,
+ // Fake-IP answers come from the network policy, not from the proxy switch:
+ // the relaxed mode is what tolerates a transparent router's placeholder
+ // addresses for content the app fetched from a public HTTPS source.
+ allowFakeIp: () => relaxedNetworkPolicyEnabled(),
// A source URL the user typed may be a LAN or loopback catalog; the opt-in
// for a plaintext hop to it is the stored `networkPolicy`.
allowInsecureUserEndpoints: () => allowInsecureUserEndpointsEnabled(),
+ // A plaintext hop to the user's own LAN catalogue is worth one notice.
+ onInsecureUserEndpoint: (host) => noteInsecureUserEndpoint(host),
});
const aggregator = createSkillMarketAggregator(client.request, {
allowInsecureUserEndpoints: () => allowInsecureUserEndpointsEnabled(),
diff --git a/apps/desktop/src/components/settings/ConfigSyncPage.tsx b/apps/desktop/src/components/settings/ConfigSyncPage.tsx
index 5818671ef..809d1b286 100644
--- a/apps/desktop/src/components/settings/ConfigSyncPage.tsx
+++ b/apps/desktop/src/components/settings/ConfigSyncPage.tsx
@@ -91,14 +91,12 @@ export function ConfigSyncPage() {
});
const [selection, setSelection] =
useState<ConfigSyncCategorySelection>(DEFAULT_SELECTION);
- const [allowInsecureHttp, setAllowInsecureHttp] = useState(false);
const [remoteMode, setRemoteMode] = useState<ConfigSyncRemoteMode>("strict");
const refresh = useCallback(async () => {
try {
const next = await api.configSyncGetState();
setState(next);
- setAllowInsecureHttp(next.allowInsecureHttp === true);
setRemoteMode(next.remoteMode ?? "strict");
if (next.configured) {
setForm((current) => ({
@@ -142,7 +140,6 @@ export function ConfigSyncPage() {
void refresh();
return api.onConfigSyncChanged((next) => {
setState(next);
- setAllowInsecureHttp(next.allowInsecureHttp === true);
setRemoteMode(next.remoteMode ?? "strict");
});
}, [refresh]);
@@ -175,7 +172,6 @@ export function ConfigSyncPage() {
appPassword: form.appPassword || undefined,
directory: form.directory,
deviceLabel: form.deviceLabel || t("settings.configSync.defaultDevice"),
- allowInsecureHttp,
categories: selection,
includeSecrets: selection.credentials,
includeMemory: selection.memory,
@@ -199,7 +195,6 @@ export function ConfigSyncPage() {
directory: form.directory,
deviceLabel: form.deviceLabel || t("settings.configSync.defaultDevice"),
backupPassword: form.backupPassword,
- allowInsecureHttp,
categories: selection,
includeSecrets: selection.credentials,
includeMemory: selection.memory,
@@ -217,7 +212,6 @@ export function ConfigSyncPage() {
} else {
setState(await api.configSyncDisconnect());
setHistory([]);
- setAllowInsecureHttp(false);
setRemoteMode("strict");
setForm((current) => ({ ...current, appPassword: "", backupPassword: "" }));
setSelection(DEFAULT_SELECTION);
@@ -379,7 +373,6 @@ export function ConfigSyncPage() {
const configured = state?.configured === true;
const locked = state?.locked === true;
const categories = selection;
- const isHttpEndpoint = /^http:\/\//i.test(form.endpoint.trim());
// The report only exists for a sync this page started: an automatic run stays
// quiet, and no report outlives the request that produced it. Enabling a
// vault runs the same full sync as "sync now", so both operations are watched.
@@ -398,39 +391,13 @@ export function ConfigSyncPage() {
<Field label={t("settings.configSync.endpoint")}>
<Input
value={form.endpoint}
- onChange={(event) => {
- const value = event.target.value;
- updateForm("endpoint", value);
- if (!/^http:\/\//i.test(value.trim())) {
- setAllowInsecureHttp(false);
- }
- }}
+ onChange={(event) => updateForm("endpoint", event.target.value)}
placeholder={t("settings.configSync.endpointPlaceholder")}
aria-label={t("settings.configSync.endpoint")}
autoComplete="url"
disabled={busy !== null}
/>
</Field>
- {isHttpEndpoint ? (
- <div className="settings-config-sync-http-option">
- <label className="settings-config-sync-category">
- <input
- type="checkbox"
- checked={allowInsecureHttp}
- onChange={(event) => setAllowInsecureHttp(event.target.checked)}
- aria-describedby="config-sync-http-warning"
- />
- <span>{t("settings.configSync.allowInsecureHttp")}</span>
- </label>
- <div
- id="config-sync-http-warning"
- className="settings-config-sync-warning"
- role={allowInsecureHttp ? "alert" : undefined}
- >
- {t("settings.configSync.allowInsecureHttpWarning")}
- </div>
- </div>
- ) : null}
<Field
label={t("settings.configSync.remoteMode")}
hint={t("settings.configSync.remoteModeHint")}
diff --git a/apps/desktop/src/components/settings/NetworkProxySection.tsx b/apps/desktop/src/components/settings/NetworkProxySection.tsx
index ac1e14cc4..3917d5d80 100644
--- a/apps/desktop/src/components/settings/NetworkProxySection.tsx
+++ b/apps/desktop/src/components/settings/NetworkProxySection.tsx
@@ -1,8 +1,15 @@
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
-import type { AppSettings, NetworkProxyMode, NetworkProxySettings } from "@pi-desktop/shared";
+import type {
+ AppSettings,
+ NetworkPolicyMode,
+ NetworkPolicySettings,
+ NetworkProxyMode,
+ NetworkProxySettings,
+} from "@pi-desktop/shared";
import {
DEFAULT_NETWORK_PROXY_BYPASS,
+ isRelaxedNetworkPolicy,
parseProxyUrl,
validateNetworkProxy,
} from "@pi-desktop/shared";
@@ -61,7 +68,7 @@ export function NetworkProxySection({
if (mode === saved.mode) return;
setTestState("idle");
if (mode !== "custom") {
- void persist({ mode, allowFakeIp: saved.allowFakeIp });
+ void persist({ mode });
return;
}
const parsed = parseProxyUrl(urlDraft);
@@ -71,7 +78,6 @@ export function NetworkProxySection({
mode: "custom",
url,
bypass: bypassDraft.trim() || undefined,
- allowFakeIp: saved.allowFakeIp,
});
};
@@ -90,7 +96,6 @@ export function NetworkProxySection({
mode: "custom",
url: parsed.value.href,
bypass: bypassDraft.trim() || undefined,
- allowFakeIp: saved.allowFakeIp,
});
};
@@ -100,7 +105,7 @@ export function NetworkProxySection({
setBypassDraft(next);
if (next === (saved.bypass ?? DEFAULT_NETWORK_PROXY_BYPASS)) return;
if (!saved.url) return;
- void persist({ mode: "custom", url: saved.url, bypass: next, allowFakeIp: saved.allowFakeIp });
+ void persist({ mode: "custom", url: saved.url, bypass: next });
};
const runTest = async () => {
@@ -112,9 +117,8 @@ export function NetworkProxySection({
mode: "custom",
url: urlDraft.trim() || saved.url,
bypass: bypassDraft.trim() || undefined,
- allowFakeIp: saved.allowFakeIp,
}
- : { mode: saved.mode, allowFakeIp: saved.allowFakeIp };
+ : { mode: saved.mode };
try {
const result = await api.testNetworkProxy(payload);
if (result.ok) {
@@ -136,18 +140,22 @@ export function NetworkProxySection({
}
};
- const insecureUserEndpoints =
- settings.networkPolicy?.allowInsecureUserEndpoints === true;
+ const relaxed = isRelaxedNetworkPolicy(settings);
/**
* Only the `networkPolicy` field is written: the settings write merges this
* patch into the stored settings, so every other preference is carried over
- * untouched.
+ * untouched. A notice the user already acknowledged stays acknowledged: the
+ * mode is the only thing this switch changes.
*/
- const persistUserEndpointPolicy = async (allowInsecureUserEndpoints: boolean) => {
+ const persistNetworkPolicy = async (mode: NetworkPolicyMode) => {
setSaveError(false);
+ const next: NetworkPolicySettings = { mode };
+ if (settings.networkPolicy?.insecureNoticeAcknowledged === true) {
+ next.insecureNoticeAcknowledged = true;
+ }
try {
- await saveSettings({ networkPolicy: { allowInsecureUserEndpoints } });
+ await saveSettings({ networkPolicy: next });
} catch {
setSaveError(true);
}
@@ -184,17 +192,21 @@ export function NetworkProxySection({
</div>
</SettingsRow>
<SettingsRow
- title={t("settings.proxyFakeIp")}
- description={t("settings.proxyFakeIpDesc")}
+ title={t("settings.networkRelaxedMode")}
+ description={
+ relaxed
+ ? t("settings.networkRelaxedModeDesc")
+ : t("settings.networkRelaxedModeStrictDesc")
+ }
>
<button
type="button"
- className={cx("settings-toggle", saved.allowFakeIp && "on")}
+ className={cx("settings-toggle", relaxed && "on")}
role="switch"
- aria-checked={saved.allowFakeIp === true}
- aria-label={t("settings.proxyFakeIp")}
+ aria-checked={relaxed}
+ aria-label={t("settings.networkRelaxedMode")}
onClick={() =>
- void persist({ ...saved, allowFakeIp: saved.allowFakeIp !== true })
+ void persistNetworkPolicy(relaxed ? "strict" : "relaxed")
}
>
<span className="settings-toggle-thumb" />
@@ -272,33 +284,6 @@ export function NetworkProxySection({
</>
) : null}
- <SettingsRow
- title={t("settings.networkAllowInsecureUserEndpoints")}
- description={t("settings.networkAllowInsecureUserEndpointsDesc")}
- >
- <span className="settings-network-checkbox">
- <input
- type="checkbox"
- checked={insecureUserEndpoints}
- aria-label={t("settings.networkAllowInsecureUserEndpoints")}
- aria-describedby="network-insecure-endpoints-warning"
- onChange={(event) =>
- void persistUserEndpointPolicy(event.target.checked)
- }
- />
- </span>
- </SettingsRow>
-
- {insecureUserEndpoints ? (
- <div
- id="network-insecure-endpoints-warning"
- className="settings-network-warning"
- role="alert"
- >
- {t("settings.networkAllowInsecureUserEndpointsWarning")}
- </div>
- ) : null}
-
{saveError ? (
<span className="settings-command-shell-state error" role="status">
{t("settings.proxySaveError")}
diff --git a/apps/desktop/src/features/app/useAppShellRuntime.tsx b/apps/desktop/src/features/app/useAppShellRuntime.tsx
index 7e49fc158..8eef787c4 100644
--- a/apps/desktop/src/features/app/useAppShellRuntime.tsx
+++ b/apps/desktop/src/features/app/useAppShellRuntime.tsx
@@ -576,6 +576,27 @@ export function useAppShellRuntime() {
const offPlansChanged = api.onPlansChanged(handlePlansChanged);
// Host-pushed toasts (plugin runtime etc.) are informational.
const offToast = api.onToast((message) => showToast(message));
+ // The first plaintext hop to an endpoint the user typed. The shell owns the
+ // wording, and recording `insecureNoticeAcknowledged` keeps it to once; a
+ // failed write only means the notice shows again.
+ const offInsecureEndpoint = api.onInsecureEndpointNotice(() => {
+ showToast(
+ `${t("settings.networkInsecureNoticeTitle")} — ${t("settings.networkInsecureNoticeBody")}`,
+ { variant: "warning", duration: 12_000 },
+ );
+ const current = useAppStore.getState().settings;
+ if (!current) return;
+ void api
+ .setSettings({
+ ...current,
+ networkPolicy: {
+ ...(current.networkPolicy ?? {}),
+ mode: current.networkPolicy?.mode ?? "relaxed",
+ insecureNoticeAcknowledged: true,
+ },
+ })
+ .catch(() => undefined);
+ });
// Agent-driven HTML preview: surface the browser tab when the agent
// opens a workspace file in the embedded browser (BrowserPreview tool).
const offBrowserPreview = api.onBrowserPreview((event) => {
@@ -770,6 +791,7 @@ export function useAppShellRuntime() {
offQueueChanged();
offPlansChanged();
offToast();
+ offInsecureEndpoint();
offBrowserPreview();
offHostStatus();
offNotificationChanged();
diff --git a/apps/desktop/src/lib/api.ts b/apps/desktop/src/lib/api.ts
index c5e3febf9..80c8241a4 100644
--- a/apps/desktop/src/lib/api.ts
+++ b/apps/desktop/src/lib/api.ts
@@ -1462,6 +1462,12 @@ export const api = {
listener((payload as { message: string }).message),
);
},
+ onInsecureEndpointNotice: (listener: (payload: { host: string }) => void) => {
+ if (!window.piDesktop?.on) return () => undefined;
+ return window.piDesktop.on(IPC.event.insecureEndpointNotice, (payload) =>
+ listener(payload as { host: string }),
+ );
+ },
onHostStatus: (listener: (status: HostStatusEvent) => void) => {
if (!window.piDesktop?.on) return () => undefined;
return window.piDesktop.on(IPC.event.hostStatus, (payload) =>
diff --git a/apps/desktop/src/lib/git-clone-url.ts b/apps/desktop/src/lib/git-clone-url.ts
index 7f31687b1..c5cb762ee 100644
--- a/apps/desktop/src/lib/git-clone-url.ts
+++ b/apps/desktop/src/lib/git-clone-url.ts
@@ -30,9 +30,8 @@ function repoNameFromPath(path: string): string | null {
*
* Plain `http`/`git` carries whatever credentials the endpoint accepts over a
* plaintext hop, so — like every other user-supplied endpoint — it needs the
- * user's explicit `networkPolicy.allowInsecureUserEndpoints` opt-in
- * (`allowInsecureHttp`); `https`, `ssh` and `git@host:path` need no opt-in and
- * stay allowed by default.
+ * relaxed `networkPolicy.mode` (`allowInsecureHttp`); `https`, `ssh` and
+ * `git@host:path` need no opt-in and stay allowed by default.
*/
function isAllowedGitHost(host: string): boolean {
return isUserSuppliedHostname(host);
diff --git a/apps/desktop/src/lib/settings-search.ts b/apps/desktop/src/lib/settings-search.ts
index 239a250b1..575f24e23 100644
--- a/apps/desktop/src/lib/settings-search.ts
+++ b/apps/desktop/src/lib/settings-search.ts
@@ -72,9 +72,9 @@ export const SETTINGS_NAV: SettingsNavEntry[] = [
"settings.proxyDirect",
"settings.proxyCustom",
"settings.proxyUrl",
- "settings.proxyFakeIp",
- "settings.networkAllowInsecureUserEndpoints",
- "settings.networkAllowInsecureUserEndpointsDesc",
+ "settings.networkRelaxedMode",
+ "settings.networkRelaxedModeDesc",
+ "settings.networkRelaxedModeStrictDesc",
],
},
{
diff --git a/apps/desktop/test/config-sync-settings.test.mjs b/apps/desktop/test/config-sync-settings.test.mjs
index eb91de857..9d39021df 100644
--- a/apps/desktop/test/config-sync-settings.test.mjs
+++ b/apps/desktop/test/config-sync-settings.test.mjs
@@ -33,8 +33,9 @@ test("cloud sync is a searchable settings destination", () => {
test("cloud sync keeps credentials and vault operations on the host boundary", () => {
assert.match(syncPage, /api\.configSyncConfigure\(/);
assert.match(syncPage, /setState\(await api\.configSyncSyncNow\(\)\)/);
- assert.match(syncPage, /allowInsecureHttp/);
- assert.match(syncPage, /settings\.configSync\.allowInsecureHttpWarning/);
+ // The plaintext opt-in is the network mode now, not a WebDAV switch: the page
+ // carries no per-endpoint HTTP acknowledgement of its own.
+ assert.doesNotMatch(syncPage, /allowInsecureHttp/);
assert.match(syncPage, /settings\.configSync\.remoteMode/);
assert.match(syncPage, /settings\.configSync\.appendOnlyWarning/);
assert.match(syncPage, /settings\.configSync\.appendOnlyConfirm/);
diff --git a/apps/desktop/test/mcp-registry-catalog.test.mjs b/apps/desktop/test/mcp-registry-catalog.test.mjs
index f3f9db420..859c231d7 100644
--- a/apps/desktop/test/mcp-registry-catalog.test.mjs
+++ b/apps/desktop/test/mcp-registry-catalog.test.mjs
@@ -20,7 +20,8 @@ test("fake-IP proxy routes use the session transport without weakening direct pi
assert.match(source, /net\.fetch\(url/);
assert.match(source, /requestPinnedHttps\(current, resolved/);
assert.match(source, /MAX_SOURCE_RESPONSE_BYTES/);
- assert.match(source, /currentNetworkProxy\(\)\.allowFakeIp/);
+ // The fake-IP tolerance is the network policy's, not the proxy's.
+ assert.match(source, /const allowFakeIp = relaxedNetworkPolicyEnabled\(\)/);
assert.match(source, /allowFakeIp && addressKind === "benchmark"/);
// The source URL is an address the user typed, so only the first hop is judged
// for a user-supplied endpoint; every redirect target is third-party content
diff --git a/apps/desktop/test/settings-general.test.mjs b/apps/desktop/test/settings-general.test.mjs
index ca49b480a..18c8eb216 100644
--- a/apps/desktop/test/settings-general.test.mjs
+++ b/apps/desktop/test/settings-general.test.mjs
@@ -173,13 +173,14 @@ test("language persists as part of shared app settings", () => {
assert.match(sharedTypesSource, /networkProxy\?: NetworkProxySettings/);
});
-test("General Network card persists a custom HTTP or SOCKS5 proxy and fake-IP opt-in", () => {
+test("General Network card persists a custom HTTP or SOCKS5 proxy and the relaxed network mode", () => {
assert.match(settingsPageSource, /<NetworkProxySection /);
- assert.match(networkProxySource, /settings\.proxyFakeIp/);
- assert.match(networkProxySource, /allowFakeIp/);
+ assert.match(networkProxySource, /settings\.networkRelaxedMode/);
+ // Fake-IP tolerance belongs to the network mode now, not to the proxy payload.
+ assert.doesNotMatch(networkProxySource, /allowFakeIp/);
assert.match(settingsSearchSource, /settings\.proxy/);
assert.match(settingsSearchSource, /settings\.proxyCustom/);
- assert.match(settingsSearchSource, /settings\.proxyFakeIp/);
+ assert.match(settingsSearchSource, /settings\.networkRelaxedMode/);
assert.match(electronMainSource, /applyNetworkProxyFromAppSettings/);
assert.match(electronMainSource, /IPC\.invoke\.networkProxyTest/);
assert.match(protocolSource, /networkProxyTest: "pi-desktop\/network\/testProxy"/);
@@ -192,8 +193,8 @@ test("General Network card persists a custom HTTP or SOCKS5 proxy and fake-IP op
]) {
assert.match(source, /proxyCustom:/);
assert.match(source, /proxyUrlPlaceholder:/);
- assert.match(source, /proxyFakeIp:/);
- assert.match(source, /proxyFakeIpDesc:/);
+ assert.match(source, /networkRelaxedMode:/);
+ assert.match(source, /networkRelaxedModeDesc:/);
}
});
diff --git a/crates/host-core/src/config_sync/engine.rs b/crates/host-core/src/config_sync/engine.rs
index 6628e8870..d11909529 100644
--- a/crates/host-core/src/config_sync/engine.rs
+++ b/crates/host-core/src/config_sync/engine.rs
@@ -84,7 +84,6 @@ pub struct StoredConfig {
pub username: String,
pub directory: String,
pub device_label: String,
- pub allow_insecure_http: bool,
#[serde(default)]
pub remote_mode: RemoteMode,
#[serde(default = "new_device_id")]
@@ -366,13 +365,20 @@ fn webdav_password(st: &AppState, config: &StoredConfig) -> Result<String> {
.ok_or_else(|| anyhow!("CONFIG_SYNC_LOCKED: WebDAV app password is not available"))
}
+/// Build the WebDAV transport from a stored configuration.
+///
+/// The plaintext hop is no longer the per-endpoint acknowledgement the sync
+/// settings used to carry: `networkPolicy.mode` decides. `relaxed` keeps an
+/// `http` endpoint reachable when it is a loopback, `.local` or private LAN
+/// host, `strict` refuses plaintext outright, and a public `http` host is
+/// refused in both modes.
fn transport_with_password(config: &StoredConfig, password: String) -> Result<WebDavTransport> {
WebDavTransport::new(&WebDavConfig {
endpoint: config.endpoint.clone(),
username: config.username.clone(),
password,
directory: config.directory.clone(),
- allow_insecure_http: config.allow_insecure_http,
+ allow_insecure_http: crate::network_policy::relaxed(),
missing_object_status: config.missing_object_status,
})
}
@@ -647,7 +653,7 @@ pub fn public_state(st: &mut AppState) -> Result<Value> {
username: None,
directory: None,
device_label: None,
- allow_insecure_http: false,
+ allow_insecure_http: crate::network_policy::relaxed(),
remote_mode: RemoteMode::Strict,
categories: default_categories(),
include_secrets: false,
@@ -742,7 +748,7 @@ pub fn public_state(st: &mut AppState) -> Result<Value> {
username: Some(config_ref.username.clone()),
directory: Some(config_ref.directory.clone()),
device_label: Some(config_ref.device_label.clone()),
- allow_insecure_http: config_ref.allow_insecure_http,
+ allow_insecure_http: crate::network_policy::relaxed(),
remote_mode: config_ref.remote_mode,
categories: config_ref.categories.clone(),
include_secrets: config_ref.include_secrets,
@@ -842,11 +848,10 @@ fn config_from_input(
username,
directory,
device_label,
- allow_insecure_http: input
- .get("allowInsecureHttp")
- .and_then(Value::as_bool)
- .or_else(|| existing.map(|value| value.allow_insecure_http))
- .unwrap_or(false),
+ // `allowInsecureHttp` used to live here as a per-endpoint
+ // acknowledgement. The plaintext decision now belongs to
+ // `networkPolicy.mode`, so the key a stored configuration may still
+ // carry is ignored rather than rewritten.
remote_mode,
device_id: existing
.map(|value| value.device_id.clone())
diff --git a/crates/host-core/src/config_sync/handlers.rs b/crates/host-core/src/config_sync/handlers.rs
index 4ba5abd6c..21a4428ee 100644
--- a/crates/host-core/src/config_sync/handlers.rs
+++ b/crates/host-core/src/config_sync/handlers.rs
@@ -52,11 +52,6 @@ pub(crate) async fn test(state: Arc<Mutex<AppState>>, params: Value) -> Result<V
.map(|value| value.directory.as_str())
.unwrap_or_default()
});
- let allow_insecure = params
- .get("allowInsecureHttp")
- .and_then(Value::as_bool)
- .or_else(|| existing.as_ref().map(|value| value.allow_insecure_http))
- .unwrap_or(false);
let remote_mode = params
.get("remoteMode")
.and_then(Value::as_str)
@@ -81,7 +76,6 @@ pub(crate) async fn test(state: Arc<Mutex<AppState>>, params: Value) -> Result<V
username: username.trim().into(),
directory: directory.trim().into(),
device_label: "test".into(),
- allow_insecure_http: allow_insecure,
remote_mode,
device_id: Uuid::new_v4().to_string(),
missing_object_status: None,
diff --git a/crates/host-core/src/config_sync/transport.rs b/crates/host-core/src/config_sync/transport.rs
index 0f8768ce4..b61396471 100644
--- a/crates/host-core/src/config_sync/transport.rs
+++ b/crates/host-core/src/config_sync/transport.rs
@@ -13,6 +13,12 @@ pub struct WebDavConfig {
pub username: String,
pub password: String,
pub directory: String,
+ /// Whether the network policy in force allows a plaintext hop to a WebDAV
+ /// endpoint. This is no longer the per-endpoint acknowledgement the sync
+ /// settings used to carry: callers pass `crate::network_policy::relaxed()`,
+ /// so `strict` refuses `http` outright while `relaxed` keeps it for a
+ /// loopback, `.local` or private LAN host. A public `http` host is refused
+ /// in either mode.
pub allow_insecure_http: bool,
pub missing_object_status: Option<u16>,
}
@@ -86,13 +92,19 @@ fn is_lan_http_host(host: &str) -> bool {
}
}
+/// Validate a WebDAV endpoint and return the base URL to address.
+///
+/// `allow_insecure_http` is the network policy's answer, so a plaintext `http`
+/// endpoint is refused unless the relaxed mode asked for it *and* the host is
+/// the user's own LAN. Public `http` stays refused in every mode: the request
+/// would carry the WebDAV credentials in the clear across the internet.
fn validate_endpoint(raw: &str, allow_insecure_http: bool) -> Result<Url> {
let mut url = Url::parse(raw.trim()).context("parse WebDAV endpoint")?;
if !matches!(url.scheme(), "https" | "http") {
bail!("CONFIG_SYNC_INVALID: WebDAV endpoint must use HTTPS");
}
if url.scheme() == "http" && !allow_insecure_http {
- bail!("CONFIG_SYNC_INVALID: HTTP requires explicit LAN-risk acknowledgement");
+ bail!("CONFIG_SYNC_INVALID: HTTP requires the relaxed network policy");
}
if url.host_str().is_none() || !url.username().is_empty() || url.password().is_some() {
bail!("CONFIG_SYNC_INVALID: endpoint must not contain userinfo");
diff --git a/crates/host-core/src/main.rs b/crates/host-core/src/main.rs
index 2ebcc1a68..bc94a224c 100644
--- a/crates/host-core/src/main.rs
+++ b/crates/host-core/src/main.rs
@@ -6,6 +6,7 @@ mod config_sync;
mod db;
mod keyboard;
mod mcp_servers;
+mod network_policy;
mod network_proxy;
mod notifications;
mod permissions;
diff --git a/crates/host-core/src/network_policy.rs b/crates/host-core/src/network_policy.rs
new file mode 100644
index 000000000..1e4d899c8
--- /dev/null
+++ b/crates/host-core/src/network_policy.rs
@@ -0,0 +1,95 @@
+//! Trust policy for the endpoints the user enters themselves, as host-core
+//! needs it.
+//!
+//! `packages/shared/src/network-policy.ts` holds the whole policy and lives in
+//! the processes that judge an address. The host asks it one question: is the
+//! relaxed mode in force? That is the answer the WebDAV transport needs before
+//! it opens a plaintext hop to a LAN endpoint the user configured. The stored
+//! settings value is mirrored here whenever the app hands the host its
+//! settings, exactly as `network_proxy.rs` mirrors the proxy.
+use serde_json::Value;
+use std::sync::atomic::{AtomicBool, Ordering};
+
+/// Mirrors `DEFAULT_NETWORK_POLICY` in `packages/shared/src/network-policy.ts`:
+/// an absent section means the relaxed mode.
+static RELAXED: AtomicBool = AtomicBool::new(true);
+
+/// Mirror the stored `networkPolicy` section.
+pub fn apply_from_settings(value: Option<&Value>) {
+ RELAXED.store(relaxed_from_settings(value), Ordering::Relaxed);
+}
+
+/// Whether the relaxed mode is in force for `settings`.
+///
+/// An absent section means yes, which is the documented default; a policy
+/// section a build before the mode existed wrote carries
+/// `allowInsecureUserEndpoints: false`, and the user's own `false` survives as
+/// `strict` — the same reading as `isRelaxedNetworkPolicy` in
+/// `packages/shared`.
+pub fn relaxed_from_settings(value: Option<&Value>) -> bool {
+ let policy = value
+ .and_then(Value::as_object)
+ .and_then(|object| object.get("networkPolicy"))
+ .and_then(Value::as_object);
+ match policy
+ .and_then(|policy| policy.get("mode"))
+ .and_then(Value::as_str)
+ {
+ Some("strict") => false,
+ Some("relaxed") => true,
+ _ => {
+ policy
+ .and_then(|policy| policy.get("allowInsecureUserEndpoints"))
+ .and_then(Value::as_bool)
+ != Some(false)
+ }
+ }
+}
+
+/// Whether the relaxed mode is in force right now.
+pub fn relaxed() -> bool {
+ RELAXED.load(Ordering::Relaxed)
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use serde_json::json;
+
+ #[test]
+ fn network_policy_reading_follows_the_stored_mode() {
+ assert!(relaxed_from_settings(None));
+ assert!(relaxed_from_settings(Some(&json!({}))));
+ assert!(relaxed_from_settings(Some(&json!({
+ "networkPolicy": { "mode": "relaxed" }
+ }))));
+ assert!(relaxed_from_settings(Some(&json!({
+ "networkPolicy": { "mode": "relaxed", "insecureNoticeAcknowledged": true }
+ }))));
+ assert!(!relaxed_from_settings(Some(&json!({
+ "networkPolicy": { "mode": "strict" }
+ }))));
+ // An unusable mode falls back to the documented default, exactly as
+ // `normalizeNetworkPolicy` does.
+ assert!(relaxed_from_settings(Some(&json!({
+ "networkPolicy": { "mode": "none" }
+ }))));
+ assert!(relaxed_from_settings(Some(&json!({
+ "networkPolicy": "yes"
+ }))));
+ }
+
+ #[test]
+ fn network_policy_reading_migrates_the_older_plaintext_flag() {
+ assert!(!relaxed_from_settings(Some(&json!({
+ "networkPolicy": { "allowInsecureUserEndpoints": false }
+ }))));
+ assert!(relaxed_from_settings(Some(&json!({
+ "networkPolicy": { "allowInsecureUserEndpoints": true }
+ }))));
+ // An explicit mode outranks the key it replaced.
+ assert!(relaxed_from_settings(Some(&json!({
+ "networkPolicy": { "mode": "relaxed", "allowInsecureUserEndpoints": false }
+ }))));
+ }
+}
diff --git a/crates/host-core/src/rpc/mod.rs b/crates/host-core/src/rpc/mod.rs
index e2bd624e3..d26004e56 100644
--- a/crates/host-core/src/rpc/mod.rs
+++ b/crates/host-core/src/rpc/mod.rs
@@ -679,6 +679,37 @@ fn normalize_settings_value(mut value: Value) -> Value {
Value::Number(DEFAULT_LARGE_PASTE_THRESHOLD.into()),
);
}
+ // The network policy replaced three per-feature switches. A section that
+ // is present is written back in the shape
+ // `packages/shared/src/network-policy.ts` defines: a usable `mode`, plus
+ // the one-time notice flag when it is set. Anything unusable falls back
+ // to the documented default, `relaxed`; the plaintext flag of a build
+ // before the mode existed survives as `strict`, because its `false` was
+ // the user's own answer.
+ let stored_policy = object
+ .get("networkPolicy")
+ .filter(|value| !value.is_null())
+ .cloned();
+ if let Some(stored_policy) = stored_policy {
+ let policy = stored_policy.as_object().cloned().unwrap_or_default();
+ let mode = match policy.get("mode").and_then(Value::as_str) {
+ Some("relaxed") => "relaxed",
+ Some("strict") => "strict",
+ _ => {
+ if policy.get("allowInsecureUserEndpoints") == Some(&Value::Bool(false)) {
+ "strict"
+ } else {
+ "relaxed"
+ }
+ }
+ };
+ let mut next = serde_json::Map::new();
+ next.insert("mode".into(), Value::String(mode.into()));
+ if policy.get("insecureNoticeAcknowledged") == Some(&Value::Bool(true)) {
+ next.insert("insecureNoticeAcknowledged".into(), Value::Bool(true));
+ }
+ object.insert("networkPolicy".into(), Value::Object(next));
+ }
// A blank override means "use the built-in default", and an unusable
// one (wrong type, oversized, or a user template without the draft
// variable) falls back to the default too, rather than leaving a
@@ -735,13 +766,22 @@ fn validate_settings_value(value: &Value) -> Result<(), JsonRpcError> {
"INVALID_PARAMS",
));
};
+ if policy.get("mode").is_some_and(|mode| {
+ !matches!(mode.as_str(), Some("relaxed") | Some("strict"))
+ }) {
+ return Err(rpc_err(
+ 1002,
+ "networkPolicy.mode must be relaxed or strict",
+ "INVALID_PARAMS",
+ ));
+ }
if policy
- .get("allowInsecureUserEndpoints")
+ .get("insecureNoticeAcknowledged")
.is_some_and(|flag| !flag.is_boolean())
{
return Err(rpc_err(
1002,
- "allowInsecureUserEndpoints must be a boolean",
+ "insecureNoticeAcknowledged must be a boolean",
"INVALID_PARAMS",
));
}
@@ -1954,6 +1994,7 @@ async fn handle_request(
}
}
crate::network_proxy::apply_from_settings(Some(&settings));
+ crate::network_policy::apply_from_settings(Some(&settings));
Ok(json!({ "ok": true }))
}
diff --git a/crates/host-core/src/state.rs b/crates/host-core/src/state.rs
index ffe261620..76de5500e 100644
--- a/crates/host-core/src/state.rs
+++ b/crates/host-core/src/state.rs
@@ -107,6 +107,9 @@ impl AppState {
// applies on launch instead of only after a manual refresh.
let app_settings = db.get_setting("app").unwrap_or_default();
crate::network_proxy::apply_from_settings(app_settings.as_ref());
+ // The WebDAV transport reads this before it allows a plaintext hop, so
+ // it has to be in place on launch and not only after a settings write.
+ crate::network_policy::apply_from_settings(app_settings.as_ref());
let (channel, custom_url) =
crate::plugins::market_channel_from_settings(app_settings.as_ref());
let plugins = PluginManager::new(data_dir, channel, custom_url);
diff --git a/docs/adr/0304-user-supplied-endpoint-trust.md b/docs/adr/0304-user-supplied-endpoint-trust.md
index 8cc5466c5..a0483d9b2 100644
--- a/docs/adr/0304-user-supplied-endpoint-trust.md
+++ b/docs/adr/0304-user-supplied-endpoint-trust.md
@@ -34,11 +34,16 @@ result was one boundary with two different meanings in it.
ULA, site-local and `.local` addresses, as well as any public address. It is
an address the person typed: a model base URL, an MCP server, a market source
URL, a git remote, a generated-image URL from a provider they configured.
-2. Plain `http` for such an endpoint requires the stored opt-in
- `settings.networkPolicy.allowInsecureUserEndpoints` (default off) — the shape
- ADR 0300 uses for WebDAV, and the reason ADR 0142 discloses the risk. `https`
- to a private host needs no opt-in: the transport is protected and the address
- is the user's own choice.
+2. One host-owned switch, **Relaxed network mode**
+ (`settings.networkPolicy.mode`, `relaxed` | `strict`), **defaults to
+ `relaxed`**. Relaxed is what lets such an endpoint resolve to loopback or a
+ LAN address, lets it use plain `http`, and tolerates a transparent proxy's
+ fake-IP answers; `strict` keeps the public-HTTPS-only boundary for those
+ endpoints too. The mode is the only switch: the earlier per-surface
+ acknowledgements (the plaintext flag, the WebDAV HTTP checkbox, the fake-IP
+ opt-in) are folded into it, and a stored `allowInsecureUserEndpoints: false`
+ migrates to `strict`. The first plaintext hop to a user endpoint tells the
+ shell once, and the acknowledgement is recorded in the same section.
3. **Third-party content keeps the strict policy.** A registry record, a market
catalog body, a document URL inside a catalog, and every HTTP redirect target
are still judged by the public-only rule, with the resolved address pinned to
@@ -71,8 +76,9 @@ result was one boundary with two different meanings in it.
a source that redirects, a catalog body, a registry record — and those paths
stay on the public-only policy. Refusals still name the address class, so a
proxy fake-IP artifact is told apart from a real private target (issue #419).
-- A plaintext hop to a LAN service is opt-in and warned about; whatever
- credentials that endpoint accepts travel unencrypted across the local network.
+- A plaintext hop to a LAN service is on by default and announced once: whatever
+ credentials that endpoint accepts travel unencrypted across the local network,
+ so the user is told the first time it happens and can turn the mode off.
- ADR 0247's consequence — "clone a private-host repository with an
application-external git remote" — no longer applies. The decision items in
ADR 0243, 0245 and 0247 that cover *user-supplied* URLs are amended here; their
diff --git a/docs/spec/04-ux/06-settings-ia.md b/docs/spec/04-ux/06-settings-ia.md
index 6142e7eb9..e9adf5d3b 100644
--- a/docs/spec/04-ux/06-settings-ia.md
+++ b/docs/spec/04-ux/06-settings-ia.md
@@ -140,12 +140,15 @@ Settings is a **full-window page** that replaces the app sidebar + main chrome (
- The selection persists as optional `AppSettings.networkProxy`
(`mode` / `url` / `bypass`). Absent means System. No host protocol or
storage schema version bump (D340 / ADR 0177).
- - **Plaintext HTTP for your own endpoints**: one checkbox persisting as
- `AppSettings.networkPolicy.allowInsecureUserEndpoints` (default off). It
- lets an endpoint you typed yourself — a model base URL, an MCP server, a
- market source — use `http`. The warning states that the connection is not
- encrypted and that whatever that endpoint accepts can be read on the same
- network segment. `https` to a LAN host needs no checkbox (ADR 0304).
+ - **Relaxed network mode**: one switch persisting as
+ `AppSettings.networkPolicy.mode` (`relaxed` | `strict`), **on by default**.
+ When it is on, an endpoint the user typed themselves — a model base URL, an
+ MCP server, a market source, a git remote — may be a loopback or LAN address,
+ may use plain `http`, and a transparent proxy's fake-IP answers are
+ tolerated. Off returns those endpoints to the public-HTTPS-only boundary.
+ The first plaintext hop to such an endpoint shows one informational notice.
+ The per-surface acknowledgements this replaced (`networkProxy.allowFakeIp`,
+ `configSync.allowInsecureHttp`) are gone (ADR 0304).
- Platform-specific **Close behavior** remains in General because it changes
application-window behavior rather than agent behavior.
- File-open target, menu-bar behavior, and bottom-panel behavior are not
diff --git a/docs/spec/05-security/01-security.md b/docs/spec/05-security/01-security.md
index 697458ae3..284f0fd5b 100644
--- a/docs/spec/05-security/01-security.md
+++ b/docs/spec/05-security/01-security.md
@@ -115,10 +115,10 @@ transparent router/TUN deployment. Install writes markdown only through
is inlined.
A source URL the user typed is judged by ADR 0304 instead: it may be a loopback
-or LAN catalog, and plain `http` to it needs the stored
-`networkPolicy.allowInsecureUserEndpoints` opt-in. Every document URL that
-arrives *inside* a catalog, and every redirect target, keeps the public-only
-policy above.
+or LAN catalog, and plain `http` to it is allowed because the relaxed network
+mode is on by default (`networkPolicy.mode`). Every document URL that arrives
+*inside* a catalog, and every redirect target, keeps the public-only policy
+above, in either mode.
## 4.2 MCP market egress
@@ -142,10 +142,11 @@ explicit local/LAN endpoints; the market path does not widen that policy.
A market source URL the user typed is judged by ADR 0304 as well: it may be a
-loopback or LAN endpoint, with plain `http` behind
-`networkPolicy.allowInsecureUserEndpoints`. Everything a source returns —
+loopback or LAN endpoint, with plain `http` behind the relaxed network mode
+(`networkPolicy.mode`, on by default). Everything a source returns —
registry records, catalog bodies, redirect targets — keeps the public-only
policy above.
+
## 4.3 Portable configuration sync
WebDAV sync is a host-core network boundary. The renderer and Agent Runtime
diff --git a/docs/spec/08-meta/decisions-log.md b/docs/spec/08-meta/decisions-log.md
index 25348c841..6b4a54a73 100644
--- a/docs/spec/08-meta/decisions-log.md
+++ b/docs/spec/08-meta/decisions-log.md
@@ -1299,7 +1299,7 @@ D193, and D194.
| D188 | Replace Chat profile with Plan state | *(superseded by D189)* **PI-Desktop has one pi Agent and one product selector: `Agent | Plan`. Plan is that Agent after entering planning state, never a second Agent, planner model, planner service, or permission mode. Agent remains the default. Persisted sessions, app defaults, and scheduled values stored as `chat` migrate to `plan`; the internal `page = "chat"` route may remain as a conversation-surface detail. Plan exposes `Read`, `Glob`, `Grep`, `BrowserPreview`, `Bash`, `CompactContext`, and `ExitPlanMode`; it denies `Write`, `Edit`, plugin tools, and unknown tools. Plan retains permission-mode selection: Bash prompts under `ask` and `accept-edits`, and runs without confirmation under `auto`, so Plan is planning intent rather than a strict read-only security profile.** | Historical pre-checkpoint Plan contract; retained to explain the supersession chain |
| D189 | Plan checkpoint artifact, approval, and execution epoch | **The same pi Agent uses `Agent | Plan`, with Agent default. Plan calls `SubmitPlan(title, markdown, question)` as the only tool in its assistant batch. Rust host-core writes the submitted Markdown bytes unchanged to a new immutable unique file under `<workspaceRoot>/.pi/plan/*.md`; it stores the relative artifact path, SHA-256, and byte size together with structured title/question fields in the existing `plan_approvals` row. No title/question wrapper is added and no prior artifact is replaced. The approval surface displays title, question, an artifact opener, absolute expiry, and status, and offers only Approve or Reject. Approve requires an explicit `ask`, `accept-edits`, or `auto` permission mode, with Ask selected by default; Reject carries no mode. The approval expires at one absolute 30-minute deadline and uses `PLAN_APPROVAL_TIMEOUT`. The same `plan_approvals` row carries `execution_id` and `execution_state` through `queued → running → completed|interrupted`. A startup transaction marks prior pending approvals and queued/running execution states interrupted before serving RPC; no work is replayed. Pending interruption/rejection/expiry leaves the session Plan; an already-approved queued/running interruption leaves the session Agent. One active turn, idle-only configuration, and one pending approval/queued-or-running execution per session are enforced. Scheduled Plan is rejected before provider, artifact, or queue work with `PLAN_REQUIRES_INTERACTIVE_SESSION`. Protocol v9 and storage schema v10 carry the contract without a serialized process-epoch field.** | Immutable host artifacts preserve the submitted checkpoint while one approval/execution row and a startup process fence prevent restart replay without losing the already-approved Agent state |
| D190 | Selectable command shell catalog and execution identity | **Host-core exposes stable platform-aware catalog IDs: `windows-powershell`, `cmd`, `git-bash`, and `bash`; the platform catalog contains only IDs supported by that platform. `defaultCommandShell` persists in host settings, and settings writes reject unavailable or wrong-platform IDs. If a persisted choice later becomes unavailable, the effective shell intentionally falls back to the first available platform shell. The `Bash` tool and `tools.execute` protocol name remain unchanged; each turn pins the effective shell ID and dialect, and host rejects a stale ID/dialect before spawn with `COMMAND_SHELL_CHANGED`. Shell identity is the catalog selection, not an executable path hash. Bash streams stdout and stderr separately, uses a mandatory 60-second default timeout with a 1–300 second override, and cancellation/timeout shuts down the complete process tree.** | Users can choose the command language without multiplying protocol tools, while platform validation, explicit fallback, and turn-pinned catalog identity keep execution predictable |
-| D604 | Trust the network endpoints the user enters themselves | **Amend ADR 0243 / 0245 / 0247 for user-supplied URLs; follow ADR 0142 / 0257 / 0300. A URL the person typed into a settings field — a market source, a git remote, an MCP OAuth endpoint, a generated-image URL — is judged by the user-endpoint policy: loopback, RFC1918, CGNAT, link-local, ULA, site-local and `.local` are reachable, and plain `http` needs the host-owned `networkPolicy.allowInsecureUserEndpoints` opt-in (default off). Third-party content keeps the public-only rule with the checked address pinned: a registry record, a catalog body, a document URL inside a catalog, and every redirect target. Cloud metadata, `unspecified`, multicast, reserved and documentation addresses stay refused on every input. The default proxy bypass list gains `10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,169.254.0.0/16`. No host protocol or storage schema bump: `networkPolicy.allowInsecureUserEndpoints` is one boolean in the existing app settings, validated on write.** | Refusing a LAN address the user typed did not remove the request — it moved the same work into a shell or a browser next to the app, so the boundary cost the feature without preventing a decision the user had already made. Third-party content is where the SSRF risk lives, so that half of the boundary is unchanged. See ADR 0304. |
+| D604 | Trust the network endpoints the user enters themselves | **Amend ADR 0243 / 0245 / 0247 for user-supplied URLs; follow ADR 0142 / 0257 / 0300. A URL the person typed into a settings field — a market source, a git remote, an MCP OAuth endpoint, a generated-image URL — is judged by the user-endpoint policy: loopback, RFC1918, CGNAT, link-local, ULA, site-local and `.local` are reachable, and plain `http` is usable. ONE switch decides that: `networkPolicy.mode` (`relaxed` | `strict`), **`relaxed` by default**, which folds in the earlier per-surface acknowledgements — the plaintext flag, the WebDAV `allowInsecureHttp` checkbox and the `networkProxy.allowFakeIp` opt-in are gone, and a stored `allowInsecureUserEndpoints: false` migrates to `strict`. The first plaintext hop to a user endpoint tells the shell once (`insecureNoticeAcknowledged`). Third-party content keeps the public-only rule in either mode, with the checked address pinned: a registry record, a catalog body, a document URL inside a catalog, and every redirect target. Cloud metadata, `unspecified`, multicast, reserved and documentation addresses stay refused on every input. The default proxy bypass list gains `10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,169.254.0.0/16`. No host protocol or storage schema bump: `networkPolicy` is one section in the existing app settings, validated on write.** | Refusing a LAN address the user typed did not remove the request — it moved the same work into a shell or a browser next to the app, so the boundary cost the feature without preventing a decision the user had already made. Third-party content is where the SSRF risk lives, so that half of the boundary is unchanged. See ADR 0304. |
## 2026-08-05 — Agent-only mode
@@ -4228,8 +4228,12 @@ D193, and D194.
- An endpoint the user typed themselves — a model base URL, an MCP server, a
market source, a git remote, a generated-image URL — may resolve to loopback,
RFC1918, CGNAT, link-local, ULA, site-local or `.local`. Plain `http` to such
- an endpoint needs the host-owned
- `settings.networkPolicy.allowInsecureUserEndpoints` opt-in (default off);
+ an endpoint is usable. One host-owned switch decides all of it —
+ `settings.networkPolicy.mode` (`relaxed` | `strict`), **`relaxed` by
+ default** — and it replaces the earlier per-surface acknowledgements
+ (`networkProxy.allowFakeIp`, `configSync.allowInsecureHttp`, the plaintext
+ flag); a stored `allowInsecureUserEndpoints: false` migrates to `strict`. The
+ first plaintext hop shows one informational notice.
`https` to a LAN host needs no opt-in.
- Third-party content is unchanged. A registry record, a market catalog body, a
document URL inside a catalog and every HTTP redirect target keep the
diff --git a/docs/zh-CN/spec/04-ux/06-settings-ia.md b/docs/zh-CN/spec/04-ux/06-settings-ia.md
index 67f9db85c..2262badcf 100644
--- a/docs/zh-CN/spec/04-ux/06-settings-ia.md
+++ b/docs/zh-CN/spec/04-ux/06-settings-ia.md
@@ -77,7 +77,7 @@
- **网络**卡:
- **代理**:分段控件 — 系统 / 直连 / 自定义。默认是系统(Chromium 跟随操作系统代理)。直连禁用代理。自定义将一个 HTTP、HTTPS 或 SOCKS5 URL 应用到应用自有出站请求(模型调用、扩展市场、更新、模型目录、插件 `net.fetch`、内置浏览器)。工作区 Bash 和 OAuth 用的系统浏览器不会被改写。
- 自定义显示代理 URL(含 `user:pass@`)、默认 `localhost,127.0.0.1,::1,<local>,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,169.254.0.0/16` 的绕过列表(本机、本地模型与所有局域网服务直连,不被代理吞掉),以及一次走该代理的测试。带认证的 URL 通过回环 SOCKS5 中继交给 Chromium(issue #490)。选择持久化为可选 `AppSettings.networkProxy`。无协议/存储版本升级(D340 / ADR 0177)。
- - **自填端点的明文 HTTP**:一个复选框,持久化为 `AppSettings.networkPolicy.allowInsecureUserEndpoints`(默认关闭)。开启后,你自己填写的端点(模型服务、MCP 服务器、市场源)可以用 `http` 访问;风险提示说明该连接不加密、同一网段的人可以读到该端点接受的一切凭据。https 访问局域网主机不需要该开关(ADR 0304)。
+ - **网络宽松模式**:一个开关,持久化为 `AppSettings.networkPolicy.mode`(`relaxed` | `strict`),**默认开启**。开启时,你自己填写的端点(模型服务、MCP 服务器、市场源、git 远端)可以是回环或局域网地址、可以使用明文 `http`,并容忍透明代理的 fake-IP 答案;关闭则回到"只允许公网 https"。首次用明文访问这类端点时会弹一次告知。它取代的三个旧确认开关(`networkProxy.allowFakeIp`、`configSync.allowInsecureHttp`、以及自填明文开关)都已删除(ADR 0304)。
- 平台支持的**关闭行为**仍保留在常规中,因为它改变的是
应用程序窗口行为,而不是智能体行为。
- 文件打开目标、菜单栏行为和底部面板行为不是
diff --git a/docs/zh-CN/spec/05-security/01-security.md b/docs/zh-CN/spec/05-security/01-security.md
index 82378819d..1dc1f27c9 100644
--- a/docs/zh-CN/spec/05-security/01-security.md
+++ b/docs/zh-CN/spec/05-security/01-security.md
@@ -98,13 +98,13 @@ CDP 插件工具在 Plan 中仍被拒绝)。 Bash 在 Plan 中仍然可用:
渲染层不拉取技能目录或 SKILL.md。Electron 主进程按公网策略发起 HTTPS 请求(ADR 0243 / D413,由 ADR 0272 / D436 修订):仅 `https`、共享的公网主机语法检查、`redirect: "manual"`,以及按请求实际会走的线路逐跳判定。每一跳之前,客户端都会向承载 `net.fetch` 的会话询问它自己的代理判定(`Session.resolveProxy`):`proxied` 线路上按线路判定,因此容忍解析器自身产物的那一类(`benchmark`,TUN fake-IP);`direct` 或读不出线路时默认保留完整的本地分类,回环、RFC1918、ULA、link-local、mapped IPv6 以及其他所有非公网类别一律拒绝。显式 `allowFakeIp` 选项仅可为透明路由器/TUN 部署额外放行 benchmark 占位地址。安装只通过 `skills.create` 写入 markdown。内联相邻 markdown 后仍受 128 KiB 宿主上限约束。
-用户自己填写的源地址改由 ADR 0304 判定:可以是回环或局域网目录服务,明文 `http` 需要先在设置里开启 `networkPolicy.allowInsecureUserEndpoints`。来自目录正文内部的文档 URL、以及每一次重定向目标,仍然沿用上面的公网策略。
+用户自己填写的源地址改由 ADR 0304 判定:可以是回环或局域网目录服务,明文 `http` 由网络宽松模式允许(`networkPolicy.mode`,默认开启)。来自目录正文内部的文档 URL、以及每一次重定向目标,仍然沿用上面的公网策略。
-MCP 市场只接受无凭据的公网 HTTPS 源和目录端点。Main 在每一跳前向承载请求的同一 Electron session 询问代理线路。在完整的 `proxied` 线路上使用 Chromium `net.fetch`,让系统/PAC 和自定义代理能够解析 fake-IP 主机;此时容忍本地解析器的 `benchmark` fake-IP 类别,但真实私网及其他非公网类别仍然拒绝。在 `direct` 或 `unknown` 线路上保留原有 Node HTTPS 路径,把选中的公网地址固定到 socket,同时保留原主机名用于 TLS SNI 和 HTTP Host;显式 `allowFakeIp` 选项仅额外允许 benchmark 答案,绝不允许其他非公网类别。重定向手动跟随、仅限 HTTPS、最多五跳,并在每次连接前重新检查。响应上限为 4 MiB,请求共享 8 秒截止时间,源、缓存和条目数量均有界。跨 origin 的用户 MCP 重定向不会转发调用方 header。
+MCP 市场只接受无凭据的公网 HTTPS 源和目录端点。Main 在每一跳前向承载请求的同一 Electron session 询问代理线路。在完整的 `proxied` 线路上使用 Chromium `net.fetch`,让系统/PAC 和自定义代理能够解析 fake-IP 主机;此时容忍本地解析器的 `benchmark` fake-IP 类别,但真实私网及其他非公网类别仍然拒绝。在 `direct` 或 `unknown` 线路上保留原有 Node HTTPS 路径,把选中的公网地址固定到 socket,同时保留原主机名用于 TLS SNI 和 HTTP Host;网络宽松模式(默认开启)仅额外容忍 benchmark 答案,绝不允许其他非公网类别。重定向手动跟随、仅限 HTTPS、最多五跳,并在每次连接前重新检查。响应上限为 4 MiB,请求共享 8 秒截止时间,源、缓存和条目数量均有界。跨 origin 的用户 MCP 重定向不会转发调用方 header。
手动配置的用户 MCP 仍遵循 ADR 0142,可以显式使用本地/LAN 端点;市场路径不会扩大该策略。
-用户自己填写的市场源地址同样由 ADR 0304 判定:可以是回环或局域网端点,明文 `http` 需要开启 `networkPolicy.allowInsecureUserEndpoints`。源返回的任何内容——registry 记录、目录正文、重定向目标——仍然沿用上面的公网策略。
+用户自己填写的市场源地址同样由 ADR 0304 判定:可以是回环或局域网端点,明文 `http` 由网络宽松模式允许(`networkPolicy.mode`,默认开启)。源返回的任何内容——registry 记录、目录正文、重定向目标——仍然沿用上面的公网策略。
## 5. 命令执行
diff --git a/docs/zh-CN/spec/08-meta/decisions-log.md b/docs/zh-CN/spec/08-meta/decisions-log.md
index 48602a450..1fcb5f03d 100644
--- a/docs/zh-CN/spec/08-meta/decisions-log.md
+++ b/docs/zh-CN/spec/08-meta/decisions-log.md
@@ -1173,7 +1173,7 @@ D193 和 D194。
| D188 | 将聊天配置文件替换为 Plan 状态 | *(被 D189 取代)* **PI-Desktop 有 1 个 pi Agent 和 1 个产品选择器:`Agent | 计划`. Plan is that Agent after entering planning state, never a second Agent, planner model, planner service, or permission mode. Agent remains the default. Persisted sessions, app defaults, and scheduled values stored as `聊天` migrate to `计划`; the internal `页面 = “聊天”` route may remain as a conversation-surface detail. Plan exposes `读取`, `Glob`, `Grep`, `浏览器预览`, `Bash`, `CompactCon text`, and `ExitPlanMode`; it denies `Write`, `编辑`, plugin tools, and unknown tools. Plan retains permission-mode selection: Bash prompts under `ask` and `accept-edits`, and runs without confirmation under `auto`,因此 Plan 是计划意图而不是严格的只读安全配置文件。** | 历史预检查点Plan合约;保留解释取代链 |
| D189 | Plan 检查点工件、批准和执行纪元 | **相同的 pi Agent 使用 `Agent | Plan`, with Agent default. Plan calls `SubmitPlan(标题, markdown, 问题)` as the only tool in its assistant batch. Rust host-core writes the submitted Markdown bytes unchanged to a new immutable unique file under `<workspaceRoot>/.pi/plan/*.md`; it stores the relative artifact path, SHA-256, and byte size together with structured title/question fields in the existing `plan_approvals` row. No title/question wrapper is added and no prior artifact is replaced. The approval surface displays title, question, an artifact opener, absolute expiry, and status, and offers only Approve or Reject. Approve requires an explicit `ask`, `accept-edits`, or `auto` permission mode, with Ask selected by default; Reject carries no mode. The approval expires at one absolute 30-minute deadline and uses `PLAN_APPROVAL_TIMEOUT`. The same `plan_approvals` row carries `execution_id` and `execution_state` through `queued → 运行 → 已完成 | 中断了`. A startup transaction marks prior pending approvals and queued/running execution states interrupted before serving RPC; no work is replayed. Pending interruption/rejection/expiry leaves the session Plan; an already-approved queued/running interruption leaves the session Agent. One active turn, idle-only configuration, and one pending approval/queued-or-running execution per session are enforced. Scheduled Plan is rejected before provider, artifact, or queue work with `PLAN_REQUIRES_INTERACTIVE_SESSION`。协议 v9 和存储模式 v10 携带的合约没有序列化的 process-epoch 字段。** | 不可变的主机工件保留提交的检查点,同时一个 approval/execution 行和启动进程栅栏可防止重新启动重播,而不会丢失已批准的 Agent 状态 |
| D190 | 可选择的命令 shell 目录和执行标识 | **主机核心公开稳定的平台感知目录 ID:`windows-powershell`、`cmd`、`git-bash` 和 `bash`;平台目录仅包含该平台支持的 ID。 `defaultCommandShell` 保留在主机设置中,并且设置写入拒绝不可用或错误的平台 ID。如果持久选择稍后变得不可用,则有效 shell 会有意回退到第一个可用的平台 shell。 `Bash` 工具和 `tools.execute` 协议名称保持不变;每个回合都会固定有效的 shell ID 和方言,并且主机在使用 `COMMAND_SHELL_CHANGED` 生成之前拒绝过时的 ID/dialect。 Shell 标识是目录选择,而不是可执行路径哈希。 Bash 分别流式传输 stdout 和 stderr,使用强制的 60 秒默认超时和 1-300 秒覆盖,并且 cancellation/timeout 关闭完整的进程树。** | 用户可以选择命令语言,而无需增加协议工具,而平台验证、显式回退和转固定目录身份可保持执行的可预测性 |
-| D604 | 信任用户自己填写的网络端点 | **对用户填写的 URL 修订 ADR 0243 / 0245 / 0247;沿用 ADR 0142 / 0257 / 0300。用户自己在设置里填写的 URL——市场源、git 远端、MCP OAuth 端点、生成图片 URL——改按"用户端点"策略判定:回环、RFC1918、CGNAT、link-local、ULA、site-local 与 `.local` 都可达,明文 `http` 需要主机侧 `networkPolicy.allowInsecureUserEndpoints` 开关(默认关闭)。第三方内容仍只允许公网并把校验过的地址固定到连接:registry 记录、目录正文、目录内部的文档 URL、以及每一次重定向目标。云元数据、`unspecified`、multicast、reserved、documentation 在任何输入上一律拒绝。默认代理绕过列表增加 `10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,169.254.0.0/16`。不改主机协议、不改存储 schema:`networkPolicy.allowInsecureUserEndpoints` 只是既有 app settings 里的一个布尔字段,写入时校验。** | 拒绝用户自己填写的局域网地址并没有消除那次请求——它只是把同样的工作搬到应用旁边的 shell 或浏览器里,因此这条边界牺牲了功能,却没有阻止用户已经做出的决定。SSRF 风险在第三方内容那一侧,所以边界的那一半保持不变。见 ADR 0304。 |
+| D604 | 信任用户自己填写的网络端点 | **对用户填写的 URL 修订 ADR 0243 / 0245 / 0247;沿用 ADR 0142 / 0257 / 0300。用户自己在设置里填写的 URL——市场源、git 远端、MCP OAuth 端点、生成图片 URL——改按"用户端点"策略判定:回环、RFC1918、CGNAT、link-local、ULA、site-local 与 `.local` 都可达,明文 `http` 也可用。这一切由**一个**开关决定:`networkPolicy.mode`(`relaxed` | `strict`),**默认 `relaxed`**,并取代此前按界面分散的确认(明文开关、WebDAV 的 `allowInsecureHttp`、`networkProxy.allowFakeIp`),旧的 `allowInsecureUserEndpoints: false` 迁移为 `strict`;首次明文访问会弹一次告知(`insecureNoticeAcknowledged`)。第三方内容在任何模式下仍只允许公网并把校验过的地址固定到连接:registry 记录、目录正文、目录内部的文档 URL、以及每一次重定向目标。云元数据、`unspecified`、multicast、reserved、documentation 在任何输入上一律拒绝。默认代理绕过列表增加 `10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,169.254.0.0/16`。不改主机协议、不改存储 schema:`networkPolicy` 只是既有 app settings 里的一个字段,写入时校验。** | 拒绝用户自己填写的局域网地址并没有消除那次请求——它只是把同样的工作搬到应用旁边的 shell 或浏览器里,因此这条边界牺牲了功能,却没有阻止用户已经做出的决定。SSRF 风险在第三方内容那一侧,所以边界的那一半保持不变。见 ADR 0304。 |
## 2026-08-05 — 仅代理模式
@@ -3552,9 +3552,12 @@ D193 和 D194。
- 用户自己填写的端点——模型 base URL、MCP 服务器、市场源、git 远端、
生成图片 URL——可以解析到回环、RFC1918、CGNAT、link-local、ULA、
- site-local 或 `.local`。明文 `http` 需要主机侧
- `settings.networkPolicy.allowInsecureUserEndpoints` 开关(默认关闭);
- `https` 访问局域网主机不需要开关。
+ site-local 或 `.local`,也可以使用明文 `http`。这一切由**一个**主机侧
+ 开关决定:`settings.networkPolicy.mode`(`relaxed` | `strict`),**默认
+ `relaxed`**;它取代了此前的三个确认开关(`networkProxy.allowFakeIp`、
+ `configSync.allowInsecureHttp`、自填明文开关),旧的
+ `allowInsecureUserEndpoints: false` 迁移为 `strict`。首次明文访问会弹一次
+ 告知。`https` 访问局域网主机不需要开关。
- 第三方内容不变。registry 记录、市场目录正文、目录内部的文档 URL、
以及每一次 HTTP 重定向目标,仍然只允许公网,并把校验过的地址固定到
连接上。共享客户端按每一跳的来源判定,只有用户发起请求的首跳可以是
diff --git a/packages/i18n/src/locales/de/index.ts b/packages/i18n/src/locales/de/index.ts
index 4e6c0484f..0401a5c58 100644
--- a/packages/i18n/src/locales/de/index.ts
+++ b/packages/i18n/src/locales/de/index.ts
@@ -608,7 +608,7 @@ sklm: {
urlHint: "https://…/catalog.json",
documentTooLarge: "Diese Skill überschreitet nach dem Anhängen der Ressourcen das 128-KB-Dokumentlimit.",
sourceUnsafe:
- "Quell-URL muss eine http- oder https-Adresse sein, keine Cloud-Metadaten-Adresse. Für Klartext-HTTP auf dem eigenen Rechner oder im LAN in den Netzwerkeinstellungen „Klartext-HTTP für eigene lokale und LAN-Endpunkte zulassen“ einschalten.",
+ "Quell-URL muss eine http- oder https-Adresse sein, keine Cloud-Metadaten-Adresse. Für Klartext-HTTP auf dem eigenen Rechner oder im LAN in den Netzwerkeinstellungen „Lockerer Netzwerkmodus“ einschalten.",
pageInfo: "Seite {{page}} von {{pages}} · {{total}} Skills",
pagePrev: "Zurück",
pageNext: "Weiter",
@@ -692,9 +692,6 @@ sklm: {
"Synchronize portable configuration through an encrypted WebDAV vault. Conversation history, source files, and runtime state are never included.",
endpoint: "WebDAV URL",
endpointPlaceholder: "https://dav.example.com/",
- allowInsecureHttp: "HTTP für eine vertrauenswürdige LAN-Adresse zulassen",
- allowInsecureHttpWarning:
- "HTTP verschlüsselt WebDAV-Anmeldedaten nicht. Nur für eine vertrauenswürdige LAN-Adresse aktivieren; öffentliche HTTP-Endpunkte werden abgelehnt.",
remoteMode: "Server-Kompatibilität",
remoteModeHint:
"Der strikte Modus erfordert zuverlässige bedingte Schreibvorgänge. Verwende den Kompatibilitätsmodus nur für Server, die If-Match/If-None-Match ignorieren.",
@@ -975,7 +972,7 @@ sklm: {
urlHint: "https://… (Registry-Endpunkt oder Katalog-JSON)",
officialSource: "Offizielle Registry",
sourceUnsafe:
- "Quell-URL muss eine http- oder https-Adresse sein, keine Cloud-Metadaten-Adresse. Für Klartext-HTTP auf dem eigenen Rechner oder im LAN in den Netzwerkeinstellungen „Klartext-HTTP für eigene lokale und LAN-Endpunkte zulassen“ einschalten.",
+ "Quell-URL muss eine http- oder https-Adresse sein, keine Cloud-Metadaten-Adresse. Für Klartext-HTTP auf dem eigenen Rechner oder im LAN in den Netzwerkeinstellungen „Lockerer Netzwerkmodus“ einschalten.",
pageInfo: "Seite {{page}} von {{pages}} · {{total}} Server",
pagePrev: "Zurück",
pageNext: "Weiter",
@@ -1171,19 +1168,20 @@ sklm: {
"proxyUrlPlaceholder": "sock5://127.0.0.1:1080",
"proxyBypass": "Bypass",
"proxyBypassDesc": "Hosts, die den Proxy überspringen.",
- proxyFakeIp: "Proxy-Fake-IP für Marktquellen zulassen",
- proxyFakeIpDesc: "Nur für einen transparenten Router-/TUN-Proxy aktivieren. Andere private Adressen bleiben blockiert.",
+ networkRelaxedMode: "Lockerer Netzwerkmodus",
+ networkRelaxedModeDesc:
+ "Selbst eingetragene Endpunkte sind erreichbar – ein Modelldienst, MCP-Server, eine Marktquelle oder ein Git-Remote auf deinem Rechner oder im LAN. Klartext-HTTP ist erlaubt, und Fake-IP-Antworten eines transparenten Proxys werden toleriert.",
+ networkRelaxedModeStrictDesc:
+ "Nur öffentliche HTTPS-Endpunkte bleiben erreichbar: eine LAN-Adresse oder eine Klartextverbindung wird abgelehnt, ebenso Fake-IP-Antworten eines Proxys.",
+ networkInsecureNoticeTitle: "Klartext-HTTP in dein eigenes Netz",
+ networkInsecureNoticeBody:
+ "Du erreichst eine selbst eingetragene Adresse – auf deinem Rechner oder im LAN – über unverschlüsseltes HTTP. Wer im selben Netzsegment sitzt, kann die Zugangsdaten in diesem Datenverkehr möglicherweise mitlesen. Stell in den Netzwerkeinstellungen auf „Strict“ um, um solche Verbindungen abzulehnen.",
"proxyInvalid": "Geben Sie eine http-, https- oder sock5-URL mit einem Host ein.",
"proxySaveError": "Der Proxy konnte nicht gespeichert werden.",
"proxyTest": "Test",
"proxyTesting": "Wird getestet…",
"proxyTestOk": "Verbunden",
"proxyTestFail": "Verbindung konnte nicht hergestellt werden: {{message}}",
- "networkAllowInsecureUserEndpoints": "Klartext-HTTP für eigene lokale und LAN-Endpunkte zulassen",
- "networkAllowInsecureUserEndpointsDesc":
- "Gilt für Endpunkte, die du selbst einträgst: einen Modelldienst, MCP-Server oder eine Marktquelle auf diesem Rechner oder im LAN. HTTPS zu einer LAN-Adresse braucht diesen Schalter nicht.",
- "networkAllowInsecureUserEndpointsWarning":
- "Klartext-HTTP ist nicht verschlüsselt. Wer im selben Netzsegment sitzt, kann diesen Datenverkehr und die Zugangsdaten, die der Dienst annimmt, mitlesen.",
"defaultsTitle": "Standardwerte",
"defaultModel": "Standardmodell",
"defaultModelNone": "Kein KI-Anbieter bereit",
diff --git a/packages/i18n/src/locales/en/index.ts b/packages/i18n/src/locales/en/index.ts
index 62366eeea..f38152a42 100644
--- a/packages/i18n/src/locales/en/index.ts
+++ b/packages/i18n/src/locales/en/index.ts
@@ -615,7 +615,7 @@ sklm: {
urlHint: "https://…/catalog.json",
documentTooLarge: "This skill is larger than the 128 KB document limit after attaching resources.",
sourceUnsafe:
- "Source URL must be an http or https address, and not a cloud metadata address. For plain http on your own machine or LAN, turn on “Allow plain HTTP for my own local and LAN endpoints” in Network settings.",
+ "Source URL must be an http or https address, and not a cloud metadata address. For plain http on your own machine or LAN, turn on “Relaxed network mode” in Network settings.",
pageInfo: "Page {{page}} of {{pages}} · {{total}} skills",
pagePrev: "Previous page",
pageNext: "Next page",
@@ -847,7 +847,7 @@ sklm: {
urlHint: "https://… (registry endpoint or catalog JSON)",
officialSource: "Official registry",
sourceUnsafe:
- "Source URL must be an http or https address, and not a cloud metadata address. For plain http on your own machine or LAN, turn on “Allow plain HTTP for my own local and LAN endpoints” in Network settings.",
+ "Source URL must be an http or https address, and not a cloud metadata address. For plain http on your own machine or LAN, turn on “Relaxed network mode” in Network settings.",
pageInfo: "Page {{page}} of {{pages}} · {{total}} servers",
pagePrev: "Previous page",
pageNext: "Next page",
@@ -939,9 +939,6 @@ sklm: {
"Synchronize portable configuration through an encrypted WebDAV vault. Conversation history, source files, and runtime state are never included.",
endpoint: "WebDAV URL",
endpointPlaceholder: "https://dav.example.com/",
- allowInsecureHttp: "Allow HTTP for a trusted LAN address",
- allowInsecureHttpWarning:
- "HTTP does not encrypt WebDAV credentials. Enable only for a trusted LAN address; public HTTP endpoints are rejected.",
remoteMode: "Server compatibility",
remoteModeHint:
"Strict mode requires reliable conditional writes. Use compatibility mode only for a server that ignores If-Match/If-None-Match.",
@@ -1186,19 +1183,20 @@ sklm: {
proxyUrlPlaceholder: "socks5://127.0.0.1:1080",
proxyBypass: "Bypass",
proxyBypassDesc: "Hosts that skip the proxy.",
- proxyFakeIp: "Allow proxy fake-IP for market sources",
- proxyFakeIpDesc: "Only enable this for a transparent router/TUN proxy. Other private addresses remain blocked.",
+ networkRelaxedMode: "Relaxed network mode",
+ networkRelaxedModeDesc:
+ "Endpoints you enter yourself are reachable — a model service, MCP server, market source, or git remote on this machine or your LAN. Plain HTTP is allowed, and a transparent proxy's fake-IP answers are tolerated.",
+ networkRelaxedModeStrictDesc:
+ "Only public HTTPS endpoints stay reachable: a LAN address or a plaintext connection is refused, and a proxy's fake-IP answers are rejected.",
+ networkInsecureNoticeTitle: "Plain HTTP to your own network",
+ networkInsecureNoticeBody:
+ "You are reaching an address you entered yourself, on this machine or your LAN, over unencrypted HTTP. Anyone on the same network segment may be able to read the credentials in that traffic. Switch to Strict in Network settings to refuse those connections.",
proxyInvalid: "Enter an http, https, or socks5 URL with a host.",
proxySaveError: "Couldn't save the proxy.",
proxyTest: "Test",
proxyTesting: "Testing…",
proxyTestOk: "Connected",
proxyTestFail: "Couldn't connect: {{message}}",
- networkAllowInsecureUserEndpoints: "Allow plain HTTP for my own local and LAN endpoints",
- networkAllowInsecureUserEndpointsDesc:
- "Applies to endpoints you enter yourself: a model service, MCP server, or market source on this machine or your LAN. HTTPS to a LAN address does not need this switch.",
- networkAllowInsecureUserEndpointsWarning:
- "Plain HTTP is not encrypted. Anyone on the same network segment can intercept this traffic and the credentials the endpoint accepts.",
defaultsTitle: "Defaults",
defaultModel: "Default model",
defaultModelNone: "No AI provider ready",
diff --git a/packages/i18n/src/locales/es/index.ts b/packages/i18n/src/locales/es/index.ts
index 2cee1a9c7..a18e4848c 100644
--- a/packages/i18n/src/locales/es/index.ts
+++ b/packages/i18n/src/locales/es/index.ts
@@ -608,7 +608,7 @@ sklm: {
urlHint: "https://…/catalog.json",
documentTooLarge: "Esta skill supera el límite de 128 KB del documento tras adjuntar recursos.",
sourceUnsafe:
- "La URL de origen debe ser http o https, no una dirección de metadatos en la nube. Para usar http sin cifrar en tu equipo o la LAN, activa «Permitir HTTP sin cifrar para mis propios servicios locales y de la LAN» en los ajustes de Red.",
+ "La URL de origen debe ser http o https, no una dirección de metadatos en la nube. Para usar http sin cifrar en tu equipo o la LAN, activa «Modo de red flexible» en los ajustes de Red.",
pageInfo: "Página {{page}} de {{pages}} · {{total}} skills",
pagePrev: "Anterior",
pageNext: "Siguiente",
@@ -692,9 +692,6 @@ sklm: {
"Synchronize portable configuration through an encrypted WebDAV vault. Conversation history, source files, and runtime state are never included.",
endpoint: "WebDAV URL",
endpointPlaceholder: "https://dav.example.com/",
- allowInsecureHttp: "Allow HTTP for a trusted LAN address",
- allowInsecureHttpWarning:
- "HTTP does not encrypt WebDAV credentials. Enable only for a trusted LAN address; public HTTP endpoints are rejected.",
remoteMode: "Compatibilidad del servidor",
remoteModeHint:
"El modo estricto requiere escrituras condicionales fiables. Usa el modo de compatibilidad solo con servidores que ignoran If-Match/If-None-Match.",
@@ -975,7 +972,7 @@ sklm: {
urlHint: "https://… (endpoint de registro o JSON de catálogo)",
officialSource: "Registro oficial",
sourceUnsafe:
- "La URL de origen debe ser http o https, no una dirección de metadatos en la nube. Para usar http sin cifrar en tu equipo o la LAN, activa «Permitir HTTP sin cifrar para mis propios servicios locales y de la LAN» en los ajustes de Red.",
+ "La URL de origen debe ser http o https, no una dirección de metadatos en la nube. Para usar http sin cifrar en tu equipo o la LAN, activa «Modo de red flexible» en los ajustes de Red.",
pageInfo: "Página {{page}} de {{pages}} · {{total}} servidores",
pagePrev: "Anterior",
pageNext: "Siguiente",
@@ -1171,19 +1168,20 @@ sklm: {
"proxyUrlPlaceholder": "calcetines5://127.0.0.1:1080",
"proxyBypass": "Omitir",
"proxyBypassDesc": "Hosts que omiten el proxy.",
- proxyFakeIp: "Permitir fake-IP del proxy para fuentes del mercado",
- proxyFakeIpDesc: "Actívalo solo con un proxy transparente de router/TUN. Las demás direcciones privadas siguen bloqueadas.",
+ networkRelaxedMode: "Modo de red flexible",
+ networkRelaxedModeDesc:
+ "Las direcciones que escribes tú son accesibles —un servicio de modelos, un servidor MCP, una fuente del mercado o un remoto de git en este equipo o en tu LAN—, se permite el HTTP sin cifrar y se toleran las respuestas fake-IP de un proxy transparente.",
+ networkRelaxedModeStrictDesc:
+ "Solo siguen siendo accesibles los endpoints HTTPS públicos: se rechazan las direcciones de la LAN y las conexiones en claro, y también las respuestas fake-IP del proxy.",
+ networkInsecureNoticeTitle: "HTTP sin cifrar hacia tu propia red",
+ networkInsecureNoticeBody:
+ "Estás accediendo por HTTP sin cifrar a una dirección que escribiste tú, en este equipo o en tu LAN. Alguien en el mismo segmento de red podría leer las credenciales de ese tráfico. Cambia a modo estricto en los ajustes de Red para rechazar esas conexiones.",
"proxyInvalid": "Ingrese una URL http, https o Socks5 con un host.",
"proxySaveError": "No se pudo guardar el proxy.",
"proxyTest": "Prueba",
"proxyTesting": "Probando…",
"proxyTestOk": "Conectado",
"proxyTestFail": "No se pudo conectar: ​​{{message}}",
- "networkAllowInsecureUserEndpoints": "Permitir HTTP sin cifrar para mis propios servicios locales y de la LAN",
- "networkAllowInsecureUserEndpointsDesc":
- "Se aplica a las direcciones que escribes tú: un servicio de modelos, un servidor MCP o una fuente del mercado en este equipo o en tu LAN. HTTPS a una dirección de la LAN no necesita esta opción.",
- "networkAllowInsecureUserEndpointsWarning":
- "El HTTP sin cifrar no protege la conexión: cualquiera en el mismo segmento de red puede interceptar el tráfico y las credenciales que acepta el servicio.",
"defaultsTitle": "Valores predeterminados",
"defaultModel": "Modelo predeterminado",
"defaultModelNone": "No hay ningún proveedor de IA listo",
diff --git a/packages/i18n/src/locales/fr/index.ts b/packages/i18n/src/locales/fr/index.ts
index 23f175a15..d70c37878 100644
--- a/packages/i18n/src/locales/fr/index.ts
+++ b/packages/i18n/src/locales/fr/index.ts
@@ -608,7 +608,7 @@ sklm: {
urlHint: "https://…/catalog.json",
documentTooLarge: "Cette skill dépasse la limite de 128 Ko une fois les ressources jointes.",
sourceUnsafe:
- "L'URL source doit être une adresse http ou https, pas une adresse de métadonnées cloud. Pour du HTTP en clair sur votre machine ou votre réseau local, activez « Autoriser le HTTP en clair pour mes propres services locaux et du réseau local » dans les réglages Réseau.",
+ "L'URL source doit être une adresse http ou https, pas une adresse de métadonnées cloud. Pour du HTTP en clair sur votre machine ou votre réseau local, activez « Mode réseau souple » dans les réglages Réseau.",
pageInfo: "Page {{page}} sur {{pages}} · {{total}} skills",
pagePrev: "Précédente",
pageNext: "Suivante",
@@ -692,9 +692,6 @@ sklm: {
"Synchronize portable configuration through an encrypted WebDAV vault. Conversation history, source files, and runtime state are never included.",
endpoint: "WebDAV URL",
endpointPlaceholder: "https://dav.example.com/",
- allowInsecureHttp: "Allow HTTP for a trusted LAN address",
- allowInsecureHttpWarning:
- "HTTP does not encrypt WebDAV credentials. Enable only for a trusted LAN address; public HTTP endpoints are rejected.",
remoteMode: "Compatibilité du serveur",
remoteModeHint:
"Le mode strict exige des écritures conditionnelles fiables. Utilisez le mode de compatibilité uniquement avec un serveur qui ignore If-Match/If-None-Match.",
@@ -975,7 +972,7 @@ sklm: {
urlHint: "https://… (endpoint de registre ou JSON de catalogue)",
officialSource: "Registre officiel",
sourceUnsafe:
- "L'URL source doit être une adresse http ou https, pas une adresse de métadonnées cloud. Pour du HTTP en clair sur votre machine ou votre réseau local, activez « Autoriser le HTTP en clair pour mes propres services locaux et du réseau local » dans les réglages Réseau.",
+ "L'URL source doit être une adresse http ou https, pas une adresse de métadonnées cloud. Pour du HTTP en clair sur votre machine ou votre réseau local, activez « Mode réseau souple » dans les réglages Réseau.",
pageInfo: "Page {{page}} sur {{pages}} · {{total}} serveurs",
pagePrev: "Précédente",
pageNext: "Suivante",
@@ -1171,19 +1168,20 @@ sklm: {
"proxyUrlPlaceholder": "chaussettes5://127.0.0.1:1080",
"proxyBypass": "Contourner",
"proxyBypassDesc": "Hôtes qui ignorent le proxy.",
- proxyFakeIp: "Autoriser les fake-IP du proxy pour les sources du marché",
- proxyFakeIpDesc: "À activer uniquement avec un proxy transparent de routeur/TUN. Les autres adresses privées restent bloquées.",
+ networkRelaxedMode: "Mode réseau souple",
+ networkRelaxedModeDesc:
+ "Les adresses que vous saisissez vous-même sont accessibles — un service de modèles, un serveur MCP, une source du marché ou un dépôt git sur cette machine ou votre réseau local. Le HTTP en clair est autorisé et les réponses fake-IP d'un proxy transparent sont tolérées.",
+ networkRelaxedModeStrictDesc:
+ "Seuls les points de terminaison HTTPS publics restent accessibles : une adresse du réseau local ou une connexion en clair est refusée, tout comme les réponses fake-IP du proxy.",
+ networkInsecureNoticeTitle: "HTTP en clair vers votre propre réseau",
+ networkInsecureNoticeBody:
+ "Vous accédez en HTTP non chiffré à une adresse que vous avez saisie, sur cette machine ou votre réseau local. Une personne sur le même segment de réseau peut peut-être lire les identifiants de ce trafic. Passez en mode strict dans les réglages Réseau pour refuser ces connexions.",
"proxyInvalid": "Saisissez une URL http, https ou chaussettes5 avec un hôte.",
"proxySaveError": "Impossible d'enregistrer le proxy.",
"proxyTest": "Test",
"proxyTesting": "Test…",
"proxyTestOk": "Connecté",
"proxyTestFail": "Impossible de se connecter : {{message}}",
- "networkAllowInsecureUserEndpoints": "Autoriser le HTTP en clair pour mes propres services locaux et du réseau local",
- "networkAllowInsecureUserEndpointsDesc":
- "Concerne les adresses que vous saisissez vous-même : un service de modèles, un serveur MCP ou une source du marché sur cette machine ou votre réseau local. HTTPS vers une adresse locale n'a pas besoin de cette option.",
- "networkAllowInsecureUserEndpointsWarning":
- "Le HTTP en clair n'est pas chiffré : toute personne sur le même segment réseau peut intercepter le trafic et les identifiants acceptés par ce service.",
"defaultsTitle": "Valeurs par défaut",
"defaultModel": "Modèle par défaut",
"defaultModelNone": "Aucun fournisseur d'IA prêt",
diff --git a/packages/i18n/src/locales/ko/index.ts b/packages/i18n/src/locales/ko/index.ts
index 41752298c..de5135a55 100644
--- a/packages/i18n/src/locales/ko/index.ts
+++ b/packages/i18n/src/locales/ko/index.ts
@@ -617,7 +617,7 @@ sklm: {
urlHint: "https://…/catalog.json",
documentTooLarge: "리소스를 첨부한 뒤 문서가 128KB 제한을 초과합니다.",
sourceUnsafe:
- "소스 URL은 http 또는 https 주소여야 하며 클라우드 메타데이터 주소는 안 됩니다. 내 컴퓨터나 LAN에서 평문 http를 쓰려면 네트워크 설정에서 “직접 입력한 로컬·LAN 서비스에 평문 HTTP 허용”을 켜세요.",
+ "소스 URL은 http 또는 https 주소여야 하며 클라우드 메타데이터 주소는 안 됩니다. 내 컴퓨터나 LAN에서 평문 http를 쓰려면 네트워크 설정에서 “네트워크 완화 모드”를 켜세요.",
pageInfo: "{{page}} / {{pages}} 페이지 · 총 {{total}}개",
pagePrev: "이전 페이지",
pageNext: "다음 페이지",
@@ -700,9 +700,6 @@ sklm: {
"Synchronize portable configuration through an encrypted WebDAV vault. Conversation history, source files, and runtime state are never included.",
endpoint: "WebDAV URL",
endpointPlaceholder: "https://dav.example.com/",
- allowInsecureHttp: "Allow HTTP for a trusted LAN address",
- allowInsecureHttpWarning:
- "HTTP does not encrypt WebDAV credentials. Enable only for a trusted LAN address; public HTTP endpoints are rejected.",
remoteMode: "서버 호환 모드",
remoteModeHint:
"엄격 모드는 신뢰할 수 있는 조건부 쓰기를 요구합니다. If-Match/If-None-Match를 무시하는 서버에서만 호환 모드를 사용하세요.",
@@ -985,7 +982,7 @@ sklm: {
urlHint: "https://… (레지스트리 엔드포인트 또는 카탈로그 JSON)",
officialSource: "공식 레지스트리",
sourceUnsafe:
- "소스 URL은 http 또는 https 주소여야 하며 클라우드 메타데이터 주소는 안 됩니다. 내 컴퓨터나 LAN에서 평문 http를 쓰려면 네트워크 설정에서 “직접 입력한 로컬·LAN 서비스에 평문 HTTP 허용”을 켜세요.",
+ "소스 URL은 http 또는 https 주소여야 하며 클라우드 메타데이터 주소는 안 됩니다. 내 컴퓨터나 LAN에서 평문 http를 쓰려면 네트워크 설정에서 “네트워크 완화 모드”를 켜세요.",
pageInfo: "{{page}} / {{pages}} 페이지 · 총 {{total}}개",
pagePrev: "이전 페이지",
pageNext: "다음 페이지",
@@ -1184,19 +1181,20 @@ sklm: {
proxyUrlPlaceholder: "socks5://127.0.0.1:1080",
proxyBypass: "우회",
proxyBypassDesc: "프록시를 사용하지 않을 호스트입니다.",
- proxyFakeIp: "마켓 소스에 프록시 fake-IP 허용",
- proxyFakeIpDesc: "투명한 라우터/TUN 프록시에서만 켜세요. 다른 사설 주소는 계속 차단됩니다.",
+ networkRelaxedMode: "네트워크 완화 모드",
+ networkRelaxedModeDesc:
+ "직접 입력한 주소(이 컴퓨터나 LAN에 있는 모델 서비스, MCP 서버, 마켓 소스, git 원격)에 연결할 수 있고, 평문 HTTP도 허용되며, 투명 프록시의 fake-IP 응답도 허용됩니다.",
+ networkRelaxedModeStrictDesc:
+ "공용 HTTPS 엔드포인트만 연결할 수 있습니다. LAN 주소와 평문 연결은 거부되고, 프록시의 fake-IP 응답도 거부됩니다.",
+ networkInsecureNoticeTitle: "내 네트워크로 나가는 평문 HTTP",
+ networkInsecureNoticeBody:
+ "직접 입력한 이 컴퓨터나 LAN 주소에 암호화되지 않은 HTTP로 접속하고 있습니다. 같은 네트워크 대역에 있는 사람이 그 트래픽의 자격 증명을 읽을 수 있습니다. 네트워크 설정에서 엄격 모드로 바꾸면 이런 연결을 거부합니다.",
proxyInvalid: "호스트가 포함된 http, https 또는 socks5 URL을 입력하세요.",
proxySaveError: "프록시를 저장할 수 없습니다.",
proxyTest: "테스트",
proxyTesting: "테스트 중…",
proxyTestOk: "연결됨",
proxyTestFail: "연결할 수 없습니다: {{message}}",
- networkAllowInsecureUserEndpoints: "직접 입력한 로컬·LAN 서비스에 평문 HTTP 허용",
- networkAllowInsecureUserEndpointsDesc:
- "직접 입력한 주소에만 적용됩니다: 이 컴퓨터나 LAN에 있는 모델 서비스, MCP 서버, 마켓 소스. LAN 주소에 HTTPS를 쓰면 이 항목이 필요하지 않습니다.",
- networkAllowInsecureUserEndpointsWarning:
- "평문 HTTP는 암호화되지 않습니다: 같은 네트워크 대역에 있는 사람이 이 연결과 서비스가 받는 자격 증명을 가로챌 수 있습니다.",
defaultsTitle: "기본값",
defaultModel: "기본 모델",
defaultModelNone: "사용 가능한 AI 프로바이더 없음",
diff --git a/packages/i18n/src/locales/tr/index.ts b/packages/i18n/src/locales/tr/index.ts
index e2895efb9..8fcf6d878 100644
--- a/packages/i18n/src/locales/tr/index.ts
+++ b/packages/i18n/src/locales/tr/index.ts
@@ -617,7 +617,7 @@ sklm: {
urlHint: "https://…/catalog.json",
documentTooLarge: "Kaynaklar eklendikten sonra bu beceri 128 KB belge sınırını aşıyor.",
sourceUnsafe:
- "Kaynak URL'si http veya https bir adres olmalı, bulut meta veri adresi olmamalıdır. Kendi makinenizde veya LAN'ınızda düz http için Ağ ayarlarında “Kendi yerel ve LAN servislerim için düz HTTP'ye izin ver” seçeneğini açın.",
+ "Kaynak URL'si http veya https bir adres olmalı, bulut meta veri adresi olmamalıdır. Kendi makinenizde veya LAN'ınızda düz http için Ağ ayarlarında “Esnek ağ modu” seçeneğini açın.",
pageInfo: "Sayfa {{page}} / {{pages}} · {{total}} skill",
pagePrev: "Önceki sayfa",
pageNext: "Sonraki sayfa",
@@ -699,9 +699,6 @@ sklm: {
connectionDescription: "Şifreli bir WebDAV kasası üzerinden taşınabilir yapılandırmayı senkronize edin.",
endpoint: "WebDAV URL'si",
endpointPlaceholder: "https://dav.example.com/",
- allowInsecureHttp: "Allow HTTP for a trusted LAN address",
- allowInsecureHttpWarning:
- "HTTP does not encrypt WebDAV credentials. Enable only for a trusted LAN address; public HTTP endpoints are rejected.",
remoteMode: "Sunucu uyumluluğu",
remoteModeHint:
"Katı mod güvenilir koşullu yazma işlemleri gerektirir. Uyumluluk modunu yalnızca If-Match/If-None-Match'i yok sayan sunucularda kullanın.",
@@ -975,7 +972,7 @@ sklm: {
urlHint: "https://… (kayıt uç noktası veya katalog JSON)",
officialSource: "Resmî kayıt",
sourceUnsafe:
- "Kaynak URL'si http veya https bir adres olmalı, bulut meta veri adresi olmamalıdır. Kendi makinenizde veya LAN'ınızda düz http için Ağ ayarlarında “Kendi yerel ve LAN servislerim için düz HTTP'ye izin ver” seçeneğini açın.",
+ "Kaynak URL'si http veya https bir adres olmalı, bulut meta veri adresi olmamalıdır. Kendi makinenizde veya LAN'ınızda düz http için Ağ ayarlarında “Esnek ağ modu” seçeneğini açın.",
pageInfo: "Sayfa {{page}} / {{pages}} · {{total}} sunucu",
pagePrev: "Önceki sayfa",
pageNext: "Sonraki sayfa",
@@ -1174,19 +1171,20 @@ sklm: {
proxyUrlPlaceholder: "socks5://127.0.0.1:1080",
proxyBypass: "Muaf tut",
proxyBypassDesc: "Vekili atlayan ana makineler.",
- proxyFakeIp: "Pazar kaynakları için proxy fake-IP adreslerine izin ver",
- proxyFakeIpDesc: "Yalnızca şeffaf yönlendirici/TUN proxy için açın. Diğer özel adresler engellenmeye devam eder.",
+ networkRelaxedMode: "Esnek ağ modu",
+ networkRelaxedModeDesc:
+ "Kendi girdiğiniz adresler erişilebilir: bu makinede veya LAN'ınızda bir model hizmeti, MCP sunucusu, pazar kaynağı ya da git uzak deposu. Düz HTTP'ye izin verilir ve şeffaf bir proxy'nin fake-IP yanıtları hoş görülür.",
+ networkRelaxedModeStrictDesc:
+ "Yalnızca genel HTTPS uç noktaları erişilebilir kalır: LAN adresleri ve düz metin bağlantılar reddedilir, proxy'nin fake-IP yanıtları da reddedilir.",
+ networkInsecureNoticeTitle: "Kendi ağınıza düz HTTP",
+ networkInsecureNoticeBody:
+ "Kendi girdiğiniz bu makine veya LAN adresine şifrelenmemiş HTTP ile erişiyorsunuz. Aynı ağ kesimindeki biri bu trafikteki kimlik bilgilerini okuyabilir. Ağ ayarlarında katı moda geçerek bu tür bağlantıları reddedebilirsiniz.",
proxyInvalid: "Ana makineli bir http, https veya socks5 URL’si girin.",
proxySaveError: "Vekil kaydedilemedi.",
proxyTest: "Dene",
proxyTesting: "Deneniyor…",
proxyTestOk: "Bağlandı",
proxyTestFail: "Bağlanılamadı: {{message}}",
- networkAllowInsecureUserEndpoints: "Kendi yerel ve LAN servislerim için düz HTTP'ye izin ver",
- networkAllowInsecureUserEndpointsDesc:
- "Yalnızca kendi girdiğin adresler için geçerlidir: bu makinede veya LAN'ında çalışan bir model servisi, MCP sunucusu ya da pazar kaynağı. LAN adresine HTTPS kullanıyorsan bu anahtar gerekmez.",
- networkAllowInsecureUserEndpointsWarning:
- "Düz HTTP şifrelenmez: aynı ağ kesimindeki kişiler bu bağlantıyı ve servisin kabul ettiği kimlik bilgilerini ele geçirebilir.",
defaultsTitle: "Varsayılanlar",
defaultModel: "Varsayılan model",
defaultModelNone: "Hazır AI servisi yok",
diff --git a/packages/i18n/src/locales/zh-CN/index.ts b/packages/i18n/src/locales/zh-CN/index.ts
index 31b2f70c2..170d6616b 100644
--- a/packages/i18n/src/locales/zh-CN/index.ts
+++ b/packages/i18n/src/locales/zh-CN/index.ts
@@ -611,7 +611,7 @@ sklm: {
urlHint: "https://…/catalog.json",
documentTooLarge: "展开相邻资源后超过 128 KB 文档上限,无法安装。",
sourceUnsafe:
- "源地址必须是 http/https 地址,且不能指向云元数据之类的地址。要用明文 http 访问自己的本机或局域网服务,请在网络设置里开启“允许对自填的本机/局域网服务使用明文 HTTP”。",
+ "源地址必须是 http/https 地址,且不能指向云元数据之类的地址。要用明文 http 访问自己的本机或局域网服务,请在网络设置里开启“网络宽松模式”。",
pageInfo: "第 {{page}} / {{pages}} 页 · 共 {{total}} 个",
pagePrev: "上一页",
pageNext: "下一页",
@@ -689,8 +689,6 @@ sklm: {
connectionDescription: "通过加密的 WebDAV 保管库同步可移植配置。不会包含对话历史、源文件或运行时状态。",
endpoint: "WebDAV 地址",
endpointPlaceholder: "https://dav.example.com/",
- allowInsecureHttp: "允许在受信任的内网地址使用 HTTP",
- allowInsecureHttpWarning: "HTTP 不会加密 WebDAV 凭据。仅对你控制的受信任内网地址启用;公网 HTTP 地址会被拒绝。",
remoteMode: "服务器兼容模式",
remoteModeHint: "严格模式要求服务器可靠支持条件写入。仅当服务器忽略 If-Match/If-None-Match 时使用兼容模式。",
remoteModeStrict: "严格 CAS(推荐)",
@@ -960,7 +958,7 @@ sklm: {
urlHint: "https://…(registry 端点或目录 JSON)",
officialSource: "官方注册表",
sourceUnsafe:
- "源地址必须是 http/https 地址,且不能指向云元数据之类的地址。要用明文 http 访问自己的本机或局域网服务,请在网络设置里开启“允许对自填的本机/局域网服务使用明文 HTTP”。",
+ "源地址必须是 http/https 地址,且不能指向云元数据之类的地址。要用明文 http 访问自己的本机或局域网服务,请在网络设置里开启“网络宽松模式”。",
pageInfo: "第 {{page}} / {{pages}} 页 · 共 {{total}} 个",
pagePrev: "上一页",
pageNext: "下一页",
@@ -1157,19 +1155,20 @@ sklm: {
proxyUrlPlaceholder: "socks5://127.0.0.1:1080",
proxyBypass: "绕过列表",
proxyBypassDesc: "不走代理的主机。",
- proxyFakeIp: "允许市场源使用代理 fake-IP",
- proxyFakeIpDesc: "仅在路由器/TUN 透明代理下开启;其他私网地址仍会被阻止。",
+ networkRelaxedMode: "网络宽松模式",
+ networkRelaxedModeDesc:
+ "你自己填写的地址(本机或局域网里的模型服务、MCP 服务器、市场源、git 远端)都能直连,允许明文 HTTP,也容忍代理的 fake-IP 应答。",
+ networkRelaxedModeStrictDesc:
+ "只允许公网 HTTPS:局域网地址和明文连接都会被拒绝,代理的 fake-IP 应答也会被拒绝。",
+ networkInsecureNoticeTitle: "正在用明文 HTTP 访问你自己的网络",
+ networkInsecureNoticeBody:
+ "你正在通过未加密的 HTTP 访问自己填写的本机/局域网地址。同一网段的人可能读到其中的凭据。到网络设置里改成严格模式即可拒绝这类连接。",
proxyInvalid: "请输入带主机名的 http、https 或 socks5 URL。",
proxySaveError: "无法保存代理设置。",
proxyTest: "测试",
proxyTesting: "测试中…",
proxyTestOk: "已连接",
proxyTestFail: "无法连接:{{message}}",
- networkAllowInsecureUserEndpoints: "允许对自填的本机/局域网服务使用明文 HTTP",
- networkAllowInsecureUserEndpointsDesc:
- "只影响你自己填写的地址:本机或局域网上的模型服务、MCP 服务器、市场源。用 HTTPS 访问局域网地址不需要开启此项。",
- networkAllowInsecureUserEndpointsWarning:
- "明文 HTTP 不加密:同一网段的其他人可能截获这条连接,以及服务所接受的凭据。",
defaultsTitle: "默认项",
defaultModel: "默认模型",
defaultModelNone: "还没有可用的 AI 服务",
diff --git a/packages/i18n/src/locales/zh-TW/index.ts b/packages/i18n/src/locales/zh-TW/index.ts
index 2f9ff3ce1..a179bc7e0 100644
--- a/packages/i18n/src/locales/zh-TW/index.ts
+++ b/packages/i18n/src/locales/zh-TW/index.ts
@@ -611,7 +611,7 @@ sklm: {
urlHint: "https://…/catalog.json",
documentTooLarge: "展開相鄰資源後超過 128 KB 文件上限,無法安裝。",
sourceUnsafe:
- "源位址必須是 http/https 位址,且不能指向雲端中繼資料之類的位址。要用明文 http 存取自己的本機或區域網路服務,請在網路設定中開啟「允許對自填的本機/區域網路服務使用明文 HTTP」。",
+ "源位址必須是 http/https 位址,且不能指向雲端中繼資料之類的位址。要用明文 http 存取自己的本機或區域網路服務,請在網路設定中開啟「網路寬鬆模式」。",
pageInfo: "第 {{page}} / {{pages}} 頁 · 共 {{total}} 個",
pagePrev: "上一頁",
pageNext: "下一頁",
@@ -689,8 +689,6 @@ sklm: {
connectionDescription: "透過加密的 WebDAV 保管庫同步可攜式設定。不會包含對話記錄、原始碼或執行階段狀態。",
endpoint: "WebDAV 網址",
endpointPlaceholder: "https://dav.example.com/",
- allowInsecureHttp: "允許在受信任的內網位址使用 HTTP",
- allowInsecureHttpWarning: "HTTP 不會加密 WebDAV 憑據。僅對你控制的受信任內網位址啟用;公網 HTTP 位址會被拒絕。",
remoteMode: "伺服器相容模式",
remoteModeHint: "嚴格模式要求伺服器可靠支援條件寫入。僅在伺服器忽略 If-Match/If-None-Match 時使用相容模式。",
remoteModeStrict: "嚴格 CAS(推薦)",
@@ -960,7 +958,7 @@ sklm: {
urlHint: "https://…(registry 端點或目錄 JSON)",
officialSource: "官方註冊表",
sourceUnsafe:
- "源位址必須是 http/https 位址,且不能指向雲端中繼資料之類的位址。要用明文 http 存取自己的本機或區域網路服務,請在網路設定中開啟「允許對自填的本機/區域網路服務使用明文 HTTP」。",
+ "源位址必須是 http/https 位址,且不能指向雲端中繼資料之類的位址。要用明文 http 存取自己的本機或區域網路服務,請在網路設定中開啟「網路寬鬆模式」。",
pageInfo: "第 {{page}} / {{pages}} 頁 · 共 {{total}} 個",
pagePrev: "上一頁",
pageNext: "下一頁",
@@ -1157,19 +1155,20 @@ sklm: {
proxyUrlPlaceholder: "socks5://127.0.0.1:1080",
proxyBypass: "繞過列表",
proxyBypassDesc: "不走代理的主機。",
- proxyFakeIp: "允許市場來源使用代理 fake-IP",
- proxyFakeIpDesc: "僅在路由器/TUN 透明代理下開啟;其他私有位址仍會被阻止。",
+ networkRelaxedMode: "網路寬鬆模式",
+ networkRelaxedModeDesc:
+ "你自己填寫的位址(本機或區域網路裡的模型服務、MCP 伺服器、市場來源、git 遠端)都能直連,允許明文 HTTP,也容忍代理的 fake-IP 回應。",
+ networkRelaxedModeStrictDesc:
+ "只允許公網 HTTPS:區域網路位址和明文連線都會被拒絕,代理的 fake-IP 回應也會被拒絕。",
+ networkInsecureNoticeTitle: "正在用明文 HTTP 存取你自己的網路",
+ networkInsecureNoticeBody:
+ "你正在透過未加密的 HTTP 存取自己填寫的本機/區域網路位址。同一網段的人可能讀到其中的憑證。到網路設定裡改成嚴格模式即可拒絕這類連線。",
proxyInvalid: "請輸入帶主機名的 http、https 或 socks5 URL。",
proxySaveError: "無法儲存代理設定。",
proxyTest: "測試",
proxyTesting: "測試中…",
proxyTestOk: "已連線",
proxyTestFail: "無法連線:{{message}}",
- networkAllowInsecureUserEndpoints: "允許對自填的本機/區域網路服務使用明文 HTTP",
- networkAllowInsecureUserEndpointsDesc:
- "只影響你自己填寫的位址:本機或區域網路上的模型服務、MCP 伺服器、市場來源。用 HTTPS 存取區域網路位址不需要開啟此項。",
- networkAllowInsecureUserEndpointsWarning:
- "明文 HTTP 不加密:同一網段的其他使用者可能截獲這條連線,以及服務所接受的憑證。",
defaultsTitle: "預設項",
defaultModel: "預設模型",
defaultModelNone: "還沒有可用的 AI 服務",
diff --git a/packages/shared/src/network-policy.test.ts b/packages/shared/src/network-policy.test.ts
index fe1d63709..ed462fa9f 100644
--- a/packages/shared/src/network-policy.test.ts
+++ b/packages/shared/src/network-policy.test.ts
@@ -2,65 +2,100 @@ import { describe, expect, it } from "vitest";
import {
DEFAULT_NETWORK_POLICY,
allowInsecureUserEndpoints,
+ isRelaxedNetworkPolicy,
+ needsInsecureEndpointNotice,
normalizeNetworkPolicy,
validateNetworkPolicy,
} from "./network-policy.js";
describe("normalizeNetworkPolicy", () => {
- it("keeps the opt-in and drops everything else", () => {
+ it("defaults to the relaxed mode", () => {
+ expect(DEFAULT_NETWORK_POLICY.mode).toBe("relaxed");
+ expect(normalizeNetworkPolicy(undefined)).toEqual({ mode: "relaxed" });
+ expect(normalizeNetworkPolicy({})).toEqual({ mode: "relaxed" });
+ });
+
+ it("keeps a stored mode and the one-time notice flag", () => {
+ expect(normalizeNetworkPolicy({ mode: "strict" })).toEqual({ mode: "strict" });
+ expect(normalizeNetworkPolicy({ mode: "relaxed", insecureNoticeAcknowledged: true })).toEqual({
+ mode: "relaxed",
+ insecureNoticeAcknowledged: true,
+ });
+ });
+
+ it("migrates the pre-mode plaintext flag", () => {
+ // A build before the mode existed stored one bare flag. Its `false` is the
+ // user's own answer and survives as `strict`; `true` means the default.
+ expect(normalizeNetworkPolicy({ allowInsecureUserEndpoints: false })).toEqual({
+ mode: "strict",
+ });
expect(normalizeNetworkPolicy({ allowInsecureUserEndpoints: true })).toEqual({
- allowInsecureUserEndpoints: true,
+ mode: "relaxed",
});
- expect(normalizeNetworkPolicy({ allowInsecureUserEndpoints: false })).toEqual({});
- expect(normalizeNetworkPolicy({ allowInsecureUserEndpoints: "yes" })).toEqual({});
- expect(normalizeNetworkPolicy({ somethingElse: true })).toEqual({});
- expect(normalizeNetworkPolicy(null)).toEqual({});
- expect(normalizeNetworkPolicy(undefined)).toEqual({});
+ // An explicit mode wins over the legacy key.
+ expect(
+ normalizeNetworkPolicy({ mode: "strict", allowInsecureUserEndpoints: true }),
+ ).toEqual({ mode: "strict" });
});
- it("defaults to refusing the plaintext case", () => {
- expect(DEFAULT_NETWORK_POLICY.allowInsecureUserEndpoints).toBe(false);
+ it("drops unusable values", () => {
+ expect(normalizeNetworkPolicy({ mode: "loose" })).toEqual({ mode: "relaxed" });
+ expect(normalizeNetworkPolicy({ insecureNoticeAcknowledged: "yes" })).toEqual({
+ mode: "relaxed",
+ });
+ expect(normalizeNetworkPolicy("strict")).toEqual({ mode: "relaxed" });
});
});
describe("validateNetworkPolicy", () => {
- it("accepts an absent section, a boolean and an empty object", () => {
+ it("accepts an absent section and a well-formed one", () => {
expect(validateNetworkPolicy(undefined)).toEqual({
ok: true,
- value: { allowInsecureUserEndpoints: false },
+ value: { mode: "relaxed" },
+ });
+ expect(validateNetworkPolicy({ mode: "strict" })).toEqual({
+ ok: true,
+ value: { mode: "strict" },
});
- expect(validateNetworkPolicy({})).toEqual({ ok: true, value: {} });
- expect(validateNetworkPolicy({ allowInsecureUserEndpoints: true })).toEqual({
+ expect(validateNetworkPolicy({ mode: "relaxed", insecureNoticeAcknowledged: true })).toEqual({
ok: true,
- value: { allowInsecureUserEndpoints: true },
+ value: { mode: "relaxed", insecureNoticeAcknowledged: true },
});
});
- it("refuses a non-object or a non-boolean flag", () => {
+ it("refuses a non-object, an unknown mode and a non-boolean flag", () => {
expect(validateNetworkPolicy([]).ok).toBe(false);
expect(validateNetworkPolicy("networkPolicy").ok).toBe(false);
- expect(validateNetworkPolicy({ allowInsecureUserEndpoints: 1 }).ok).toBe(false);
- expect(validateNetworkPolicy({ allowInsecureUserEndpoints: null }).ok).toBe(false);
+ expect(validateNetworkPolicy({ mode: "loose" }).ok).toBe(false);
+ expect(validateNetworkPolicy({ insecureNoticeAcknowledged: 1 }).ok).toBe(false);
});
});
-describe("allowInsecureUserEndpoints", () => {
- it("reads the networkPolicy section of a settings object", () => {
- expect(
- allowInsecureUserEndpoints({ networkPolicy: { allowInsecureUserEndpoints: true } }),
- ).toBe(true);
- expect(
- allowInsecureUserEndpoints({ networkPolicy: { allowInsecureUserEndpoints: false } }),
- ).toBe(false);
- expect(allowInsecureUserEndpoints({})).toBe(false);
- expect(allowInsecureUserEndpoints(null)).toBe(false);
- expect(allowInsecureUserEndpoints({ networkPolicy: "yes" })).toBe(false);
+describe("isRelaxedNetworkPolicy", () => {
+ it("reads the section of a settings object and defaults to relaxed", () => {
+ expect(isRelaxedNetworkPolicy({ networkPolicy: { mode: "relaxed" } })).toBe(true);
+ expect(isRelaxedNetworkPolicy({ networkPolicy: { mode: "strict" } })).toBe(false);
+ expect(isRelaxedNetworkPolicy({})).toBe(true);
+ expect(isRelaxedNetworkPolicy(null)).toBe(true);
+ // Only the section is read: nothing sets a top-level lookalike.
+ expect(isRelaxedNetworkPolicy({ mode: "strict" })).toBe(true);
});
- it("ignores a top-level lookalike key", () => {
- // Only the section is read: the host validates that one on write, and a
- // stray top-level field is not something any surface sets.
- expect(allowInsecureUserEndpoints({ allowInsecureUserEndpoints: true })).toBe(false);
- expect(allowInsecureUserEndpoints({ networkPolicy: { allowInsecure: true } })).toBe(false);
+ it("is the same reading as allowInsecureUserEndpoints", () => {
+ const strict = { networkPolicy: { mode: "strict" as const } };
+ expect(allowInsecureUserEndpoints(strict)).toBe(false);
+ expect(allowInsecureUserEndpoints({})).toBe(true);
+ });
+});
+
+describe("needsInsecureEndpointNotice", () => {
+ it("owes the notice once, in the relaxed mode only", () => {
+ expect(needsInsecureEndpointNotice({})).toBe(true);
+ expect(
+ needsInsecureEndpointNotice({
+ networkPolicy: { mode: "relaxed", insecureNoticeAcknowledged: true },
+ }),
+ ).toBe(false);
+ expect(needsInsecureEndpointNotice({ networkPolicy: { mode: "strict" } })).toBe(false);
});
});
diff --git a/packages/shared/src/network-policy.ts b/packages/shared/src/network-policy.ts
index a846c6a45..d4d9764fc 100644
--- a/packages/shared/src/network-policy.ts
+++ b/packages/shared/src/network-policy.ts
@@ -3,50 +3,65 @@
*
* Address judgement lives in `public-network.ts`, which answers "is this
* address public?". This module answers the separate question the app asks
- * before it applies that judgement: "did the user type this endpoint in
- * themselves, and did they accept the plaintext case for it?".
+ * before it applies that judgement: "how much does this app trust the endpoints
+ * the user typed?".
*
* Endpoints the user typed — a model base URL, an MCP server, a market source,
- * a git remote, a WebDAV root — are that person's own choice, so the guard
- * treats loopback and LAN addresses as reachable. Content the app did not
+ * a git remote, a WebDAV root — are that person's own choice, so the relaxed
+ * mode treats loopback and LAN addresses as reachable, allows plain `http`, and
+ * tolerates a transparent proxy's fake-IP answers. Content the app did not
* receive from the user — a registry record, a market catalog body, an HTTP
- * redirect target — keeps the strict public-network policy, because that is
- * where the SSRF risk lives.
+ * redirect target — keeps the strict public-network policy in either mode,
+ * because that is where the SSRF risk lives.
*/
+export const NETWORK_POLICY_MODES = ["relaxed", "strict"] as const;
+
/**
* Who chose the address one request is judged for.
*
* `user` is an endpoint the person typed into a settings field: their own
* machine, their own LAN service, their own public server. `third-party` is
* everything the app did not receive from them — a redirect target, a catalog
- * body, a registry record — which keeps the strict public-network policy,
- * because that is the input an attacker controls.
+ * body, a registry record — which keeps the strict public-network policy in
+ * either mode, because that is the input an attacker controls.
*/
export type EndpointOrigin = "user" | "third-party";
+export type NetworkPolicyMode = (typeof NETWORK_POLICY_MODES)[number];
/** `settings.networkPolicy`. */
export type NetworkPolicySettings = {
/**
- * Permit plain `http` for a user-supplied endpoint. Off by default: on a LAN
- * a plaintext hop carries whatever credentials that endpoint accepts, so it
- * stays the user's explicit call rather than a default (the shape ADR 0300
- * uses for a WebDAV endpoint).
+ * `relaxed` is the default: an endpoint the user typed may be a loopback or
+ * LAN address, plain `http` is usable, and a TUN proxy's fake-IP answers are
+ * tolerated. `strict` keeps the public-HTTPS-only boundary for those endpoints
+ * too.
+ */
+ mode?: NetworkPolicyMode;
+ /**
+ * Set once the app has told the user that a plaintext hop to their own LAN is
+ * in use. The notice is informational; the mode stays what it was.
*/
- allowInsecureUserEndpoints?: boolean;
+ insecureNoticeAcknowledged?: boolean;
};
-export const DEFAULT_NETWORK_POLICY: NetworkPolicySettings = {
- allowInsecureUserEndpoints: false,
-};
+export const DEFAULT_NETWORK_POLICY: NetworkPolicySettings = { mode: "relaxed" };
/** Keep only the fields this policy defines, with their usable values. */
export function normalizeNetworkPolicy(value: unknown): NetworkPolicySettings {
const record =
value && typeof value === "object" ? (value as Record<string, unknown>) : {};
- const next: NetworkPolicySettings = {};
- if (record.allowInsecureUserEndpoints === true) {
- next.allowInsecureUserEndpoints = true;
+ const stored =
+ record.mode === "strict" || record.mode === "relaxed" ? record.mode : undefined;
+ // A build before the mode existed stored one bare flag for the plaintext case.
+ // Its `false` is the user's own answer, so it survives as `strict`; its `true`
+ // and its absence both mean the default, `relaxed`.
+ const legacy = record.allowInsecureUserEndpoints;
+ const next: NetworkPolicySettings = {
+ mode: stored ?? (legacy === false ? "strict" : "relaxed"),
+ };
+ if (record.insecureNoticeAcknowledged === true) {
+ next.insecureNoticeAcknowledged = true;
}
return next;
}
@@ -62,24 +77,52 @@ export function validateNetworkPolicy(value: unknown): ValidateNetworkPolicyResu
if (typeof value !== "object" || Array.isArray(value)) {
return { ok: false, error: "networkPolicy must be an object" };
}
- const flag = (value as Record<string, unknown>).allowInsecureUserEndpoints;
- if (flag !== undefined && typeof flag !== "boolean") {
- return { ok: false, error: "allowInsecureUserEndpoints must be a boolean" };
+ const record = value as Record<string, unknown>;
+ if (
+ record.mode !== undefined &&
+ record.mode !== "relaxed" &&
+ record.mode !== "strict"
+ ) {
+ return { ok: false, error: "networkPolicy.mode must be relaxed or strict" };
+ }
+ if (
+ record.insecureNoticeAcknowledged !== undefined &&
+ typeof record.insecureNoticeAcknowledged !== "boolean"
+ ) {
+ return {
+ ok: false,
+ error: "insecureNoticeAcknowledged must be a boolean",
+ };
}
return { ok: true, value: normalizeNetworkPolicy(value) };
}
/**
- * Read the plaintext opt-in out of a whole settings object.
- *
- * Only the `networkPolicy` section is read. A top-level lookalike key must not
- * be able to turn the opt-in on: the host validates this section on write, and
- * any other spelling of the flag is a field nothing sets.
+ * Whether the relaxed mode is in force for `settings`. Absent settings and an
+ * absent `networkPolicy` section both mean yes: that is the documented default.
+ */
+export function isRelaxedNetworkPolicy(settings: unknown): boolean {
+ const section =
+ settings && typeof settings === "object"
+ ? (settings as { networkPolicy?: unknown }).networkPolicy
+ : undefined;
+ return normalizeNetworkPolicy(section).mode !== "strict";
+}
+
+/**
+ * The reading every plaintext decision uses: relaxed mode is what allows a
+ * plain `http` hop to an endpoint the user typed.
*/
export function allowInsecureUserEndpoints(settings: unknown): boolean {
+ return isRelaxedNetworkPolicy(settings);
+}
+
+/** Whether the one-time plaintext notice still owes the user an explanation. */
+export function needsInsecureEndpointNotice(settings: unknown): boolean {
const section =
settings && typeof settings === "object"
? (settings as { networkPolicy?: unknown }).networkPolicy
: undefined;
- return normalizeNetworkPolicy(section).allowInsecureUserEndpoints === true;
+ const policy = normalizeNetworkPolicy(section);
+ return policy.mode !== "strict" && policy.insecureNoticeAcknowledged !== true;
}
diff --git a/packages/shared/src/network-proxy.test.ts b/packages/shared/src/network-proxy.test.ts
index ce09f6a9b..ca05ebf03 100644
--- a/packages/shared/src/network-proxy.test.ts
+++ b/packages/shared/src/network-proxy.test.ts
@@ -76,10 +76,12 @@ describe("validateNetworkProxy", () => {
value: { mode: "direct" },
});
});
- it("preserves the explicit fake-IP market opt-in without widening other modes", () => {
+ it("drops the retired fake-IP key from a stored proxy", () => {
+ // The fake-IP tolerance moved to `networkPolicy.mode`; an older stored value
+ // is ignored rather than refused, so an existing profile keeps loading.
expect(validateNetworkProxy({ mode: "direct", allowFakeIp: true })).toEqual({
ok: true,
- value: { mode: "direct", allowFakeIp: true },
+ value: { mode: "direct" },
});
expect(validateNetworkProxy({ mode: "system", allowFakeIp: false })).toEqual({
ok: true,
diff --git a/packages/shared/src/network-proxy.ts b/packages/shared/src/network-proxy.ts
index bd2c29eec..016162a7a 100644
--- a/packages/shared/src/network-proxy.ts
+++ b/packages/shared/src/network-proxy.ts
@@ -50,12 +50,6 @@ export type NetworkProxySettings = {
* {@link DEFAULT_NETWORK_PROXY_BYPASS} for custom mode.
*/
bypass?: string;
- /**
- * Opt in to router/TUN fake-IP answers for public market sources. This only
- * permits the benchmark placeholder range; all other non-public classes stay
- * blocked. Absent means disabled.
- */
- allowFakeIp?: boolean;
};
export type ParsedProxyUrl = {
@@ -95,7 +89,9 @@ export function normalizeNetworkProxy(value: unknown): NetworkProxySettings {
settings.url = record.url.trim();
}
if (bypass) settings.bypass = bypass;
- if (record?.allowFakeIp === true) settings.allowFakeIp = true;
+ // A build before the network policy owned it stored `allowFakeIp` here. The
+ // key is ignored, not rejected: the proxy decides where traffic goes, and
+ // `networkPolicy.mode` decides what the app tolerates from the route.
return settings;
}
@@ -205,7 +201,6 @@ export function validateNetworkProxy(
const settings = normalizeNetworkProxy(value);
if (settings.mode !== "custom") {
const next: NetworkProxySettings = { mode: settings.mode };
- if (settings.allowFakeIp) next.allowFakeIp = true;
return { ok: true, value: next };
}
const parsed = parseProxyUrl(settings.url ?? "");
@@ -215,7 +210,6 @@ export function validateNetworkProxy(
url: parsed.value.href,
};
if (settings.bypass?.trim()) next.bypass = settings.bypass.trim();
- if (settings.allowFakeIp) next.allowFakeIp = true;
return { ok: true, value: next };
}
diff --git a/packages/shared/src/protocol.ts b/packages/shared/src/protocol.ts
index 2529e1ba9..963457aef 100644
--- a/packages/shared/src/protocol.ts
+++ b/packages/shared/src/protocol.ts
@@ -352,6 +352,13 @@ export const IPC = {
agentQueueChanged: "pi-desktop/agent/event/queueChanged",
hostStatus: "pi-desktop/app/event/hostStatus",
toast: "pi-desktop/app/event/toast",
+ /**
+ * The first plaintext hop to an endpoint the user typed, sent once and only
+ * until the shell records `networkPolicy.insecureNoticeAcknowledged`. The
+ * shell owns the wording, because the address is not a secret and the copy
+ * is localized.
+ */
+ insecureEndpointNotice: "pi-desktop/network/event/insecureEndpointNotice",
browserState: "pi-desktop/browser/event/state",
browserPreview: "pi-desktop/browser/event/preview",
windowMaximized: "pi-desktop/window/event/maximized",
diff --git a/packages/shared/src/types/config-sync.ts b/packages/shared/src/types/config-sync.ts
index 5e1f3f910..dbc01d550 100644
--- a/packages/shared/src/types/config-sync.ts
+++ b/packages/shared/src/types/config-sync.ts
@@ -78,7 +78,6 @@ export type ConfigSyncPreferences = {
username: string;
directory: string;
deviceLabel: string;
- allowInsecureHttp?: boolean;
remoteMode?: ConfigSyncRemoteMode;
categories: ConfigSyncCategorySelection;
includeSecrets: boolean;
@@ -138,8 +137,6 @@ export type ConfigSyncState = {
username?: string;
directory?: string;
deviceLabel?: string;
- /** True only when the configured WebDAV endpoint is an acknowledged LAN HTTP target. */
- allowInsecureHttp?: boolean;
remoteMode: ConfigSyncRemoteMode;
categories: ConfigSyncCategorySelection;
includeSecrets: boolean;
@@ -163,7 +160,6 @@ export type ConfigSyncConfigureInput = {
deviceLabel: string;
/** Required when creating or unlocking the encrypted vault. */
backupPassword: string;
- allowInsecureHttp?: boolean;
remoteMode?: ConfigSyncRemoteMode;
categories?: Partial<ConfigSyncCategorySelection>;
includeSecrets?: boolean;