Skip to content

Security: ayushjoshi0118/CodeScope

Security

docs/security.md

CodeScope Security & Sandbox Specifications

CodeScope treats all user-supplied and imported code as completely untrusted.

1. No Arbitrary Code Evaluation

  • CodeScope never executes user code with eval(), new Function(), or within the host browser context.
  • Execution is driven entirely by an AST-level interpreter (AstInterpreter.ts) that interprets nodes as discrete data structures.
  • Host APIs (window, document, localStorage, sessionStorage, cookies, fetch, XMLHttpRequest, WebSocket, Worker) are not passed or exposed into the interpreted environment.

2. Resource & Denial-of-Service Defense Limits

To guard against malicious, accidental, or infinite execution, CodeScope enforces deterministic limits on every run:

Limit Guard Default Threshold Behavior on Breach
Step Limit 3,000 steps Halts execution with LIMIT_REACHED: Exceeded maximum execution step limit.
Call Stack Depth 64 frames Halts recursive loops with LIMIT_REACHED: Maximum call stack depth exceeded.
Heap Object Allocations 1,000 objects Halts memory exhaustion with LIMIT_REACHED: Heap object limit exceeded.
Loop Iterations 1,000 passes / loop Halts runaway loops with LIMIT_REACHED: Loop exceeded maximum iterations.
Wall-Clock Execution Time 4,000 milliseconds Halts execution if time threshold is exceeded.

3. Trace Import Safety

  • Exported traces are strictly serialized JSON schemas (codescope-v1).
  • Imported files are size-checked (< 10MB) and validated for structure.
  • Imported code is never automatically executed on import. It is simply populated into the editor and viewable as a read-only historical trace until the user explicitly hits "Run".

There aren't any published security advisories