Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: open https: links without slashes as web links; canonical citation URLs; treat Windows theme and search-connector files as dangerous (#13195)

Daniel Han3b1d13da414c
diff --git a/studio/frontend/src/features/browser/dangerous-file-types.json b/studio/frontend/src/features/browser/dangerous-file-types.json
index cd2daa3f994..bfeae37d08a 100644
--- a/studio/frontend/src/features/browser/dangerous-file-types.json
+++ b/studio/frontend/src/features/browser/dangerous-file-types.json
@@ -24,6 +24,7 @@
"csh",
"deb",
"definition",
+ "deskthemepack",
"desktop",
"diagcab",
"diagcfg",
@@ -119,6 +120,7 @@
"scr",
"sct",
"search-ms",
+ "searchconnector-ms",
"seplugin",
"service",
"settingcontent-ms",
@@ -129,6 +131,8 @@
"sparseimage",
"sys",
"terminal",
+ "theme",
+ "themepack",
"toast",
"tool",
"udif",
diff --git a/studio/frontend/src/features/chat/utils/document-citation-source.ts b/studio/frontend/src/features/chat/utils/document-citation-source.ts
index 64dad31a9a3..6c52675c29b 100644
--- a/studio/frontend/src/features/chat/utils/document-citation-source.ts
+++ b/studio/frontend/src/features/chat/utils/document-citation-source.ts
@@ -8,7 +8,9 @@ export function isSafeNavigableSourceUrl(raw: unknown): string {
try {
const parsed = new URL(value);
if (parsed.protocol === "http:" || parsed.protocol === "https:") {
- return value;
+ // The parsed form: `https:evil.example` or a tab inside `https:\t//` parse as absolute, but the raw string
+ // has no `://`, so openLink would treat it as relative and let it replace Studio's own page.
+ return parsed.href;
}
} catch {}
return "";
diff --git a/studio/frontend/src/lib/open-link.ts b/studio/frontend/src/lib/open-link.ts
index 7a9ddb07925..2b5121c6c90 100644
--- a/studio/frontend/src/lib/open-link.ts
+++ b/studio/frontend/src/lib/open-link.ts
@@ -28,6 +28,18 @@ export function openExternalLink(url: string): void {
* preventDefault; false lets native navigation proceed (relative, empty). */
export function openLink(url: string): boolean {
if (!url) return false;
+ // The URL parser drops tabs and newlines, so `https:\t//host` navigates like `https://host`.
+ url = url.replace(/[\t\n\r]/g, "");
+
+ // `https:host` (no slashes) is absolute too: open it as a web link instead of letting native navigation replace
+ // Studio's page.
+ if (/^https?:/i.test(url) && !url.includes("://")) {
+ try {
+ url = new URL(url).href;
+ } catch {
+ return true;
+ }
+ }
// Anchor links scroll within the page, don't open externally
if (url.startsWith("#")) {
diff --git a/studio/frontend/tests/download-safety-windows-shell-types.test.ts b/studio/frontend/tests/download-safety-windows-shell-types.test.ts
new file mode 100644
index 00000000000..6fec1fc2569
--- /dev/null
+++ b/studio/frontend/tests/download-safety-windows-shell-types.test.ts
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+import assert from "node:assert/strict";
+import test from "node:test";
+import policy from "../src/features/browser/dangerous-file-types.json" with { type: "json" };
+
+test("Windows theme and search-connector files are treated as dangerous", () => {
+ // Opening a crafted .theme or .searchConnector-ms reaches an attacker SMB share and leaks the NTLM hash.
+ for (const ext of ["theme", "themepack", "deskthemepack", "searchconnector-ms"]) {
+ assert.ok(policy.extensions.includes(ext), ext);
+ }
+});
diff --git a/studio/frontend/tests/open-link-scheme-without-slashes.test.ts b/studio/frontend/tests/open-link-scheme-without-slashes.test.ts
new file mode 100644
index 00000000000..4d3e544a59a
--- /dev/null
+++ b/studio/frontend/tests/open-link-scheme-without-slashes.test.ts
@@ -0,0 +1,50 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+import assert from "node:assert/strict";
+import { readFileSync } from "node:fs";
+import test from "node:test";
+import ts from "typescript";
+import { isSafeNavigableSourceUrl } from "../src/features/chat/utils/document-citation-source.ts";
+
+// open-link.ts imports `@/lib/api-base`; load it as the web build (isTauri = false) with window.open recorded.
+const source = readFileSync(new URL("../src/lib/open-link.ts", import.meta.url), "utf8").replace(
+ /^import \{ isTauri \} from "@\/lib\/api-base";$/m,
+ "const isTauri = false;",
+);
+const js = ts.transpileModule(source, {
+ compilerOptions: { module: ts.ModuleKind.ESNext, target: ts.ScriptTarget.ES2022 },
+}).outputText;
+const opened: string[] = [];
+(globalThis as Record<string, unknown>).window = {
+ open: (url: string) => opened.push(url),
+ location: { hash: "" },
+};
+const { openLink } = await import(`data:text/javascript,${encodeURIComponent(js)}`);
+
+test("https: without slashes opens as a web link instead of navigating Studio's page", () => {
+ for (const [href, expected] of [
+ ["https:evil.example/x", "https://evil.example/x"],
+ ["https:\t//evil.example/x", "https://evil.example/x"],
+ ["HTTP:evil.example", "http://evil.example/"],
+ ]) {
+ opened.length = 0;
+ assert.equal(openLink(href), true, href);
+ assert.deepEqual(opened, [expected], href);
+ }
+});
+
+test("relative, anchor and ordinary web links are unchanged", () => {
+ opened.length = 0;
+ assert.equal(openLink("/chat?thread=1"), false);
+ assert.equal(openLink("docs/page"), false);
+ assert.equal(openLink("https://unsloth.ai/docs"), true);
+ assert.deepEqual(opened, ["https://unsloth.ai/docs"]);
+});
+
+test("citation sources come back in their parsed form", () => {
+ assert.equal(isSafeNavigableSourceUrl("https:\t//a.example/x"), "https://a.example/x");
+ assert.equal(isSafeNavigableSourceUrl("https:a.example"), "https://a.example/");
+ assert.equal(isSafeNavigableSourceUrl("https://a.example/x?y=1"), "https://a.example/x?y=1");
+ assert.equal(isSafeNavigableSourceUrl("javascript:alert(1)"), "");
+});