Bird
0
0

You want to safely run user-submitted Python code that may contain dangerous operations like file access or network calls. Which approach best uses sandboxing to protect your system?

hard📝 Application Q15 of 15
Agentic AI - Agent Safety and Guardrails
You want to safely run user-submitted Python code that may contain dangerous operations like file access or network calls. Which approach best uses sandboxing to protect your system?
ARun the code on your main system but monitor CPU usage
BRun the code directly with <code>exec()</code> and catch exceptions
CRun the code inside a containerized sandbox limiting file and network access
DRun the code after removing all import statements manually
Step-by-Step Solution
Solution:
  1. Step 1: Understand sandboxing for dangerous code

    Containerized sandboxing isolates code with strict limits on file and network access.
  2. Step 2: Evaluate other options

    Using exec() directly is unsafe; monitoring CPU does not prevent damage; manual import removal is error-prone and incomplete.
  3. Final Answer:

    Run the code inside a containerized sandbox limiting file and network access -> Option C
  4. Quick Check:

    Container sandbox = safest isolation [OK]
Quick Trick: Use container sandbox to limit risky operations [OK]
Common Mistakes:
  • Trusting exec() without isolation
  • Relying on CPU monitoring only
  • Trying manual code cleaning for safety

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Agentic AI Quizzes