From 7bca7bf0db9523c182367fbe7524c9f60bd0ce19 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Fri, 3 Apr 2026 14:29:41 +0000 Subject: [PATCH] Validate announcement URL scheme and fix llama-only mode guard - Only allow https:// and http:// URLs for announcement_url to prevent javascript: or data: scheme injection from a compromised manifest. - Guard the install timestamp write with both _LLAMA_ONLY and _SKIP_PYTHON_DEPS checks to prevent uninitialized variable errors when running in UNSLOTH_STUDIO_LLAMA_ONLY=1 mode (set -u). --- studio/backend/utils/update_check.py | 5 ++++- studio/setup.sh | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/studio/backend/utils/update_check.py b/studio/backend/utils/update_check.py index 2a806239ae..695f5f69ff 100644 --- a/studio/backend/utils/update_check.py +++ b/studio/backend/utils/update_check.py @@ -94,7 +94,10 @@ def fetch_and_cache_update_status() -> UpdateStatus: if isinstance(announcement, dict): status.announcement_badge = announcement.get("badge") or None status.announcement_message = announcement.get("message") or None - status.announcement_url = announcement.get("url") or None + _url = announcement.get("url") or None + # Only allow http/https URLs to prevent javascript: or data: injection. + if _url and _url.startswith(("https://", "http://")): + status.announcement_url = _url _cached_status = status return status diff --git a/studio/setup.sh b/studio/setup.sh index 183d015359..87d989382b 100755 --- a/studio/setup.sh +++ b/studio/setup.sh @@ -1062,7 +1062,8 @@ else fi # end _SKIP_GGUF_BUILD check # ── Write install timestamp (only when python deps were actually updated) ── -if [ "$_SKIP_PYTHON_DEPS" = false ]; then +# Guard against uninitialized _SKIP_PYTHON_DEPS in llama-only mode. +if [ "$_LLAMA_ONLY" != "1" ] && [ "${_SKIP_PYTHON_DEPS:-true}" = false ]; then _STUDIO_INFO_DIR="$HOME/.unsloth/studio" mkdir -p "$_STUDIO_INFO_DIR" python - "$_STUDIO_INFO_DIR/UNSLOTH_STUDIO_INFO.json" <<'PY' 2>/dev/null || true