aboutsummaryrefslogtreecommitdiff
path: root/docs/audit-2026-06-18_chatstudio-overlay.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/audit-2026-06-18_chatstudio-overlay.md')
-rw-r--r--docs/audit-2026-06-18_chatstudio-overlay.md47
1 files changed, 47 insertions, 0 deletions
diff --git a/docs/audit-2026-06-18_chatstudio-overlay.md b/docs/audit-2026-06-18_chatstudio-overlay.md
new file mode 100644
index 0000000..8134caf
--- /dev/null
+++ b/docs/audit-2026-06-18_chatstudio-overlay.md
@@ -0,0 +1,47 @@
+# ChatStudio Overlay Audit — v4.5.70
+Date: 2026-06-18
+Auditor: Hermes Agent
+Files reviewed: module-chatstudio.js (1,064 lines), chat-commands.js (276 lines), chat-modules.js (375 lines), chat-ui.html (160 lines), chat-ui.css (747 lines)
+
+## P0 — Critical Security (3 issues) — FIXED in v4.5.70
+
+| # | Issue | File:Line | Status |
+|---|-------|-----------|--------|
+| 1 | XSS via single-quote injection — `escapeHtml()` didn't escape `'`, module IDs injected into `onclick` with single-quote delimiters | module-chatstudio.js:254, chat-modules.js:113-117 | ✅ Fixed — added `'` escaping |
+| 2 | Iframe preview without sandbox — `showHtmlPreview()`/`previewCodeBlock()` write AI content into unsandboxed iframe with full parent access | chat-ui.html:157 | ✅ Fixed — `sandbox="allow-same-origin"` |
+| 3 | `importModules()` accepts unvalidated JSON — zero schema check, no ID sanitization, one-click XSS via crafted import file | chat-modules.js:339-367 | ✅ Fixed — 1MB limit, schema validation, ID sanitization |
+
+## P1 — Bugs & Reliability (7 issues) — NOT YET FIXED
+
+| # | Issue | File:Line | Impact |
+|---|-------|-----------|--------|
+| 4 | No fetch timeouts — 11 bare `fetch()` calls with no AbortController | chat-commands.js:98,143,147,181,207,228,244,258 + module-chatstudio.js:446,465,773,860 | Slow/hung backend freezes chat indefinitely |
+| 5 | No streaming cancel — once `isStreaming=true`, no abort button or timeout | module-chatstudio.js:751-856 | Model hang = page reload required |
+| 6 | CSS load race condition — `resolve()` fires before CSS `<link>` onload | module-chatstudio.js:39-46 | FOUC on first overlay open |
+| 7 | `oninput` for Enter key — unreliable across browsers, should be `onkeydown` | chat-ui.html:65 | Enter key may not submit on some browsers |
+| 8 | Duplicate `modules` array — `chat-modules.js:75` declares local `var modules` shadowing `window.modules` | chat-modules.js:75 vs module-chatstudio.js:960 | If load order changes, `handleCommand` sees empty array |
+| 9 | `_csGlobalsInited` stuck true after init failure — placeholder stubs remain active on retry | module-chatstudio.js:94 vs 1054 | Retry silently does nothing |
+| 10 | `generateModuleWithAI` uses deprecated global `event` | chat-modules.js:276 | Fails in strict mode |
+
+## P2 — UX & Architecture (8 issues) — NOT YET FIXED
+
+| # | Issue | File:Line | Notes |
+|---|-------|-----------|-------|
+| 11 | API key in base64 localStorage — not encryption, trivially decodable | module-chatstudio.js:419 | Should use secret-vault.js |
+| 12 | Inconsistent storage encoding — messages plain JSON, logs/settings base64 | module-chatstudio.js:505 | Should be consistent |
+| 13 | Chat history no max size — long conversations overflow localStorage | module-chatstudio.js:502-508 | Cap at N messages |
+| 14 | Static `?v=5` cache-busting — doesn't use NEWOS4_VERSION | module-chatstudio.js:10489,10550 | Manual version bump needed |
+| 15 | `buildChatContext` naive HTML strip — regex-based, easily fooled | module-chatstudio.js:888 | Use DOMParser |
+| 16 | User messages get no markdown formatting — asymmetric UX | module-chatstudio.js:548 | Apply formatContent to user msgs too |
+| 17 | Activity log hardcoded 50 limit | module-chatstudio.js:325 | Not configurable |
+| 18 | `CHATSTUDIO_VERSION` not synced to `NEWOS4_VERSION` | module-chatstudio.js:231 | Stale version info |
+
+## Tool-Use Optimization — Applied in v4.5.70
+
+From AI self-report:
+- Search retry strategy: system prompt instructs AI to retry with `site:` operators if first search returns generic portals
+- No "waiting" hallucinations: system prompt bans announcing tool use ("Hold on...", "Fetching...")
+- Typo tolerance: system prompt instructs AI to recognize malformed commands and suggest correct one
+- Date injection: ChatStudio overlay now injects current date into every AI request
+- Updated default module prompt: lists all 4 tools (search, fetch, extract, summarize) with tool-use rules
+- Updated help text: shows all available commands \ No newline at end of file