newOS4 Code Review

Reviewed by Kimi K2.7 Code (kimi-k2.7-code) · v4.5.83 · 2026-07-03 · ~48K LOC across 54 modules

5
CRITICAL
8
HIGH
5
MEDIUM
0
LOW
18
Total Issues

1. Architecture

HIGH
terminal.js (2,765 lines)
God-object terminal.js — Command dispatch, pipe chain, Levenshtein suggestion, and security gating all live in one file. Far beyond single responsibility.
HIGH
module-aiassist.js (3,479 lines)
AI surface is bloated — Combines agent loop, tool definitions, guardrails, shadow snapshots, confidence escalation, and six profiles. Should be split into planner, tool-router, guardrail/policy, executor, and budget-controller.
MEDIUM
AI stack (6+ modules)
Fragmented AI surface — aiassist, orchestrator, neural-vfs, memory-graph, world-model, smartctx, predictor, agent-registry have clear overlap and likely inconsistent policy enforcement.
HIGH
Extension modules (21 ext)
No capability manifest for extensions — 21 extension modules register commands into the same terminal namespace. No disclosed sandbox-permission model, so a compromised extension can escalate via terminal dispatch.

2. Security

CRITICAL
Entire security model
Client-authoritative security is not real security — The 4-level security manager runs in browser JS and can be bypassed with DevTools, a malicious browser extension, XSS, or a compromised dependency. Security decisions must be enforced by a server/trusted enclave, not code the attacker already controls.
CRITICAL
module-aiassist.js
AI autonomy over destructive tools is dangerous — AI agent has tool access to fs, system, webdav, crypto, secrets, shell. If guardrails are client-side, prompt injection can defeat them. Autonomous delete, write, token-send, or secret-read operations require human approval or server-side policy.
HIGH
secret-vault.js
Secret vault exposed to browser memory — AES-GCM + PBKDF2 600K iterations is cryptographically sound, but derived key is held in JS memory while unlocked. XSS, compromised extension, or malicious module can exfiltrate plaintext after unlock. Use non-extractable WebCrypto keys (subtle CryptoKey), keep vault locked by default.
HIGH
terminal.js pipe chain
Pipe chain command injection surface — String-based command dispatch creates a mini-shell. If any module builds arguments by string concatenation, this becomes a command-injection vector. Need tokenized AST parsing and strict argument schemas.
HIGH
module-orchestrator.js
A2A mailbox lacks identity and authorization — Without message signing, sender verification, and capability ACLs, any module or injected script can post as an agent or spoof a heartbeat.
CRITICAL
main.html / terminal output
No Content Security Policy or output sanitization — Terminal output often renders user or LLM-generated content. Missing CSP/output encoding opens a persistent XSS path that defeats every other security control.

3. Code Quality

HIGH
Multiple files >1,000 lines
Module bloat — terminal.js, module-aiassist.js, webdav.js, mindmap.js, three.js, filemgr.js, chatstudio.js all exceed 1,000 lines. Difficult to unit-test, review, or refactor safely.
HIGH
Entire codebase
No disclosed test harness or static analysis — A system this complex needs automated tests, property-based tests for the VFS, and linting. Not mentioned in the codebase description.
MEDIUM
terminal.js command dispatch
Stringly-typed command dispatch — Commands registered by name and routed through terminal.js. Without typed schemas, every command parser re-implements validation, leading to subtle bugs.
MEDIUM
module-system.js / module-modmgr.js
Hardcoded categories possible — Project guidelines warn against hardcoded help categories. If violated, indicates configuration drift.

4. Performance

HIGH
virtual-fs.js
localStorage VFS is synchronous and quota-limited — Every VFS op blocks main thread, capped at 5-10 MB. Checkpoint/rollback serializes entire tree to JSON, causing jank and OOM on large trees.
CRITICAL
module-neural-vfs.js
Neural VFS deep LLM indexing is expensive — Indexes files semantically via deep LLM calls. On CPU-only 15GB RAM host this is unsustainable: latency high, token/memory cost unbounded, results may hallucinate.
HIGH
module-aiassist.js
AI loop snapshots and six profiles multiply cost — Shadow snapshots copy state per iteration. Six loop profiles plus confidence escalation mean unpredictable token/CPU consumption. Without hard iteration/token budget, agent can run away.
HIGH
module-sandbox.js
Sandbox inline-eval fallback removes isolation — If fallback executes user/module code in main thread, it bypasses sandbox and blocks UI.
MEDIUM
Boot/startup
Large startup bundle cost — 48K JS across 54 modules creates large initial parse/compile cost. Consider lazy-loading by category.

5. AI Integration

CRITICAL
module-aiassist.js confidence escalation
Guardrails and confidence escalation are client-authoritative — If AI can decide to escalate its own confidence and disable checks, prompt injection can do the same. Escalation must require external, human-verified signal.
CRITICAL
module-aiassist.js tool definitions
Tool surface too broad for autonomous agent — Tools covering filesystem, secrets, crypto, webdav, shell, system reset, and multi-agent messaging give LLM kernel-level power. Demands server-side policy layer, deterministic deny-lists, and per-tool approval prompts.
HIGH
module-neural-vfs.js / module-memory-graph.js
Neural VFS / memory graph can be poisoned — Maliciously named files or crafted content can bias semantic indices and memory-graph facts, causing LLM to make wrong decisions or leak data.
MEDIUM
module-orchestrator.js consensus
Multi-agent consensus without clear failure model — Consensus engine and heartbeat exist, but browser agents can crash, be spoofed, or disagree. No described Byzantine-fault or leader-election model.
MEDIUM
module-world-model.js
World model self-referential risk — Synthesizes system self-awareness. If LLM misrepresents its own state, downstream agents act on false beliefs.

6. Top 5 Recommendations

#1
Entire security model
Move security enforcement out of the browser
Create server-side (or trusted-enclave) capability/policy engine. Browser can request operations, but destructive, secret, or network actions must be authorized server-side with signed tokens, audit logs, and rate limits. Treat client-side guardrails as UX, not security.
#2
module-aiassist.js
Put AI agent under mandatory human-in-the-loop and hard budgets
Require explicit approval for high-impact tools (write, delete, secret-read, webdav, shell, system, reset). Cap loop iterations, tokens, and elapsed time per profile. Disable confidence escalation as a self-approval mechanism.
#3
virtual-fs.js
Replace localStorage VFS with async, encrypted, quota-aware storage
Use IndexedDB or backend store, async APIs, chunked objects, incremental checkpoints, and integrity checks. Encrypt sensitive VFS nodes at rest. Provide export/import/backup, not just rollback.
#4
terminal.js + module-aiassist.js
Refactor into small, testable subsystems
Split terminal.js into tokenizer/parser, dispatcher, pipe engine, and renderer. Split module-aiassist.js into planner, tool-router, policy/guardrail, executor, budget-controller, and snapshot manager. Add unit tests and enforce max-lines-per-module policy.
#5
main.html / runtime
Harden browser runtime against XSS and secret extraction
Deploy strict CSP. Sanitize all terminal output. Use non-extractable CryptoKey objects. Keep secret vault locked by default. Move credentials/tokens out of localStorage into server session or secure cookie. Add audit log for every security-critical operation.

7. Summary Risk Matrix

🔴 CRITICAL

🟠 HIGH

🟡 MEDIUM


Overall verdict: newOS4 is an ambitious and feature-rich shell, but its current architecture trusts the browser with security and AI autonomy decisions. The top priority is to introduce a server-side trust anchor and enforce hard limits on AI power before adding more modules.

Review generated by Kimi K2.7 Code (kimi-k2.7-code) via Hermes Agent · newOS4 v4.5.83 · 2026-07-03