ARES Security and Threat Model
Purpose
The ARES Security Model defines the safeguards and trust boundaries within the meta-compiler ecosystem. As a tool that generates and executes code across multiple backends (C++, Python, Node.js), ARES maintains a strict separation between the Compilation Environment (Node.js) and the Runtime Environment (Orchestrator Daemon). This document outlines the strategies used to mitigate risks like arbitrary code injection, lateral movement, and resource exhaustion during both the compilation and execution phases.
Prerequisites
- Host Permissions: The compiler should be run as a non-privileged user unless IoT/GPIO access is required.
- Target Sandboxing: OS-level isolation (e.g., Docker, seccomp, or apparmor) is recommended for Phase 9 execution of untrusted ARES scripts.
Dependencies
src/orchestrator/daemon.ts: Implements process-level isolation and timeouts.src/umr/umr_bridge.ts: Performs declarative (not shell-scripted) dependency resolution.
Formal Definition
Let be the ARES source input and be its execution. The Security Invariant states that: This separation ensures that an ARES script can only access its own memory mapped arena and the I/O streams assigned to it by the Orchestrator Daemon.
Operational Behavior
- Process Isolation: Every backend (C++, Python, Node) is spawned as a child process via
child_process.spawn, which does not share the parent's environment by default (Line 139, daemon.ts). - Input sanitization: While ARES allows for complex literals, the
AresParser(Phase 2) rejects any non-standard tokens, preventing some forms of syntax-level injection into the target backend's emitters. - Timeout Enforcement: A fixed 60-second execution window is hard-coded in the daemon (Line 160) to prevent Denial of Service (DoS) attacks via infinite loops.
- UMR Declarativity: The Universal Module Resolver does not execute
postinstallscripts or arbitrary shell commands during configuration generation (Phase 6), reducing the risk of supply-chain attacks through the compiler.
Implementation Mapping
Attack Surface vs. ARES Mitigation
1. Arbitrary Code Injection (Command Level)
Attack Vector:
aresuse secret_alg on "; rm -rf /"
ARES Mitigation (Emitters):
The Emitters (e.g., CppEmitter) do not concatenate input strings directly into system shell calls. The use target is bound specifically as an identifier or string literal in the generated source code, not as a shell command.
2. Resource Exhaustion
Attack Vector:
areswhile true { // infinite loop }
ARES Mitigation (Daemon):
typescriptsetTimeout(() => { proc.kill(); // Forced termination after 60s }, 60000);
3. Shared Memory Leakage
Attack Vector:
aresuse dijkstra on adj // then read indices beyond adj
ARES Mitigation (Bridge):
The Shared Memory Bridge utilizes read-only mapping (mode: 'r') in consumers and unique binary files in the temporary directory for each run, preventing cross-execution data leaks.
Mathematical Model
The attack success probability is bounded by: ARES minimizes the parsable surface by using a strict EBNF grammar (9_formal_spec/01_ebnf.md) that does not allow for raw backend-specific escapes.
Complexity
- Mitigation Latency: constant overhead for process monitoring and timeouts.
- Sanitization Time: linear time checking during Phase 2 parsing.
Examples
Securely Passing Identifiers: The emitter wraps all approach targets in appropriate language-specific scoping to prevent variable name hijacking.
Resource Capping (Configuration):
The estimatedN parameter (CompilerOptions:35) is used by the profilier to prevent the selection of algorithms on datasets before the code is even compiled.
Traces
Trace for a malicious script execution:
- Lexer identifies valid ARES tokens.
- Parser validates the grammar (Fails if invalid syntax is used to break the string).
- Emitter generates a static C++ source file.
g++compiles the static file safely.daemon.execute()spawns the process.setTimeout()fires after 60s, callingproc.kill().
Edge Cases
- IoT/GPIO Exposure: When using
gpio_control, the execution process must be run with higher privileges. This opens the system to risk if the ARES script is untrusted. - C++ Overflow: While ARES generates
long longfor integers, a malicious script could still overflow buffers in the generated C++ if custom user snippets are poorly authored in the registry.
Failure Modes
- Zombies: If a script spawns its own children (e.g., via a Python
subprocesscall), the 60-second limit will kill the parent but might leave "orphaned" children if the OS-level process group is not correctly terminated. - Compiler-Side DoS: A very large, recursive
if-elsechain can exhaust the Node.js stack memory during AST construction.
Compatibility
- Standards: Follows OWASP recommendations for process isolation and least-privilege execution.
- Platforms: Sandbox behavior is more robust on Linux (using
PID namespaces) than on Windows.
Testing
- Timeout Test:
tests/security.test.tsexecutes a 5-second busy-wait script with a 1-second override timeout to verify the killer works. - Grammar Injection Test: Attempts to inject
}; system("...")into areadstatement and verifies that theAresParserrejects it.
Related Entities
6_compiler_and_runtime/08_orchestrator_daemon.md: Implementation of the killer timer.src/umr/umr_bridge.ts: Declarative resolution logic.