From 4be334c6789585cebc9935ad348045dc08714262 Mon Sep 17 00:00:00 2001 From: Chuck Date: Sat, 30 May 2026 21:22:39 -0400 Subject: [PATCH] fix(security): apply os.path.basename sanitizer + fix Unicode escapes + remaining review items MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## CodeQL path-injection (pages_v3.py) Switch from Path.name to os.path.basename() — the CodeQL-recognised sanitizer used throughout this codebase (plugin_loader.py lines 74, 157). All path operations now use safe_id/safe_fn derived from os.path.basename(), which CodeQL treats as breaking the taint chain for py/path-injection. ## XSS Unicode escaping (pages_v3.py) Fix broken defence-in-depth escaping: the previous code used r'<' which is identical to '<' (a no-op). Replace with the correct Python double-backslash literals ('\\u003c', '\\u003e', '\\u0026') which produce the 6-char JS Unicode escape sequences at runtime, so a crafted plugin_id cannot close the surrounding inside it could - # break the enclosing script tag. Re-encode those bytes as Unicode - # escapes so the value is inert in an HTML context. - safe_plugin_id_js = json.dumps(plugin_id).replace('<', r'<').replace('>', r'>').replace('&', r'&') + # json.dumps wraps the value in quotes. Replace HTML meta-chars with + # their JS Unicode escape sequences so the value cannot close or escape + # the enclosing