From ec792ee10d967c471a8571bcb31a034ee1004b4c Mon Sep 17 00:00:00 2001 From: imSp4rky Date: Tue, 8 Sep 2026 19:24:20 -0600 Subject: [PATCH] fix(api): reject a NUL byte in output_dir before resolving it --- unshackle/core/api/handlers.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unshackle/core/api/handlers.py b/unshackle/core/api/handlers.py index c6640269..90577e1b 100644 --- a/unshackle/core/api/handlers.py +++ b/unshackle/core/api/handlers.py @@ -1556,8 +1556,11 @@ def validate_download_parameters(data: Dict[str, Any]) -> Optional[str]: # The serve user would create and write any directory a client names; keep it under downloads. if data.get("output_dir"): root = config.directories.downloads.resolve() + raw = str(data["output_dir"]) + if "\x00" in raw: + return "output_dir is not a usable path." try: - target = (root / str(data["output_dir"])).resolve() + target = (root / raw).resolve() except (OSError, ValueError): return "output_dir is not a usable path." if not target.is_relative_to(root):