<aside> ๐
Date: Tuesday, October 13, 2026 ยท Week 3, Day 16 ยท Type: Build Day
</aside>
16.1 The Danger of eval() โ why running agent-generated code directly on your local machine or server is a severe security vulnerability.
16.2 Sandboxing Fundamentals โ process isolation, resource limits (CPU/RAM), and blocking external network calls.
16.3 Containerized Execution โ running untrusted code safely inside Docker containers or WebAssembly (WASM).
Build a secure Python-execution tool for your Day 15 agent that takes raw generated Python code, executes it inside an isolated subprocess with strict memory limits and a 3-second timeout, and captures stdout/stderr safely.
+--------------------+ +-------------------+ ========================
| Agent Python Code | --> | Sandbox Manager | --> | ISOLATED SUBPROCESS |
+--------------------+ +-------------------+ | - Max Time: 3.0s |
| - Memory Limit: 100MB |
| - Capture stdout/err |
========================
exec() function in production an immediate critical security vulnerability?Problem 16. Write a safe execution runner in Python using the subprocess module that executes an arbitrary Python code string in an isolated child process, enforces a strict 2.0-second timeout, captures stdout, and safely catches syntax/runtime errors without crashing the main application.
Data Structure: Process Execution Stream Buffer (stdout/stderr Pipes).
Mechanics: OS-level byte streams capturing inter-process communication output safely.
Real-World Production Use: Deployed inside all AI coding sandbox environments (E2B, Modal, Replit Agent).