Bird
0
0

You wrote this code to sandbox a dangerous file operation:

medium📝 Debug Q14 of 15
Agentic AI - Agent Safety and Guardrails
You wrote this code to sandbox a dangerous file operation:
import sandbox
sandbox.start()
open('/etc/passwd', 'w').write('hacked')
sandbox.stop()

But the file was overwritten on your system. What is the likely error?
AThe <code>sandbox.stop()</code> was missing
BSandbox was not properly isolating file writes
CThe <code>open</code> function is blocked in sandbox
DThe code should use <code>sandbox.write()</code> instead
Step-by-Step Solution
Solution:
  1. Step 1: Analyze sandbox isolation failure

    If the file was overwritten, sandbox did not isolate the file write operation properly.
  2. Step 2: Check other options

    Stopping sandbox does not affect isolation during execution; open is not necessarily blocked; sandbox.write() is not a standard method.
  3. Final Answer:

    Sandbox was not properly isolating file writes -> Option B
  4. Quick Check:

    Sandbox isolation failure = file overwritten [OK]
Quick Trick: Check if sandbox truly isolates file operations [OK]
Common Mistakes:
  • Assuming stopping sandbox fixes isolation
  • Thinking open() is always blocked
  • Expecting sandbox.write() method exists

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Agentic AI Quizzes