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).
This commit is contained in:
Daniel Han 2026-04-03 14:29:41 +00:00
commit 7bca7bf0db
2 changed files with 6 additions and 2 deletions

View file

@ -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

View file

@ -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