
Sandboxing AI-Generated Code
Sandboxing restricts the environment in which generated code runs. Isolation, limited permissions, resource controls, and output inspection reduce risk, but no sandbox makes arbitrary code automatically safe.
출처
전체 수업 요약
An AI assistant generates a short script to turn a table into a chart. The script looks ordinary, yet running it may read files, contact a network service, install packages, or consume excessive resources. Sandboxing creates a controlled execution environment that restricts what code can access and do. It is especially relevant when code has not been independently trusted, including code produced by an AI system.
A sandbox is a boundary, not a quality judgment about the program. It can limit filesystem access, network connections, process capabilities, memory, computing time, and other resources. Different technologies create different boundaries. Containers, virtual machines, language runtimes, and systems such as gVisor have distinct security models and limitations. Selecting a familiar technology without examining its configuration can create a false sense of protection.
For a classroom data exercise, imagine a teacher testing an AI-generated plotting script with a fictional dataset. The environment contains only the input file and a designated output directory. It has no production credentials, no access to learner records, and no unnecessary network access. A time limit and memory limit reduce the effect of an accidental infinite loop or oversized calculation. The teacher inspects the generated chart and the program's reported actions before making the exercise available to learners.
Useful boundaries can be undermined by convenience choices. Mounting a broad home directory exposes files the task does not need. Giving a container privileged access or control of the host's container service can weaken isolation substantially. Network access can allow unwanted downloads or data transmission. Dependencies may introduce risks independent of the generated script. The effective security arrangement includes the runtime, permissions, mounted data, credentials, packages, and surrounding infrastructure.
Sandboxing also does not prove that an answer is correct. A program can safely compute the wrong statistic, misread a column, or draw a misleading graph. Separate checks should verify assumptions, units, missing values, and the interpretation of results. Outputs themselves may require inspection before opening or sharing. A successful process exit means only that execution completed according to the runtime, not that the educational task was performed appropriately.
A useful learning activity asks groups to draw a boundary around a fictional code runner and list what crosses it. Introduce requests to read another directory, download a package, or write a file outside the output area, and ask which should be permitted for the stated task. Explain the purpose of each decision rather than memorizing one technology's settings. In real deployments, keep the runtime maintained, test restrictions, record relevant execution evidence, and provide a way to stop or discard a run. Sandboxing helps make experimentation manageable when it is combined with minimal access, suitable supervision, and independent checks of what the computation actually means.


