Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is sandboxing in the context of dangerous operations?
Sandboxing is a safety technique that runs risky code or operations in a controlled, isolated environment to prevent harm to the main system.
Click to reveal answer
beginner
Why is sandboxing important when working with AI agents?
Because AI agents can perform unpredictable or harmful actions, sandboxing helps keep these actions contained so they don't damage data, systems, or privacy.
Click to reveal answer
intermediate
Name two common methods used to create a sandbox environment.
Two common methods are using virtual machines (VMs) and containers like Docker, which isolate the code from the main system.
Click to reveal answer
intermediate
How does sandboxing help in debugging dangerous operations?
Sandboxing lets developers safely test and observe risky code behavior without risking the main system, making it easier to find and fix problems.
Click to reveal answer
beginner
What could happen if dangerous operations are not sandboxed?
Without sandboxing, dangerous operations might corrupt data, crash systems, leak sensitive information, or cause security breaches.
Click to reveal answer
What is the main purpose of sandboxing dangerous operations?
ATo increase memory usage
BTo speed up code execution
CTo permanently delete data
DTo isolate risky code and protect the main system
✗ Incorrect
Sandboxing isolates risky code to prevent harm to the main system.
Which of the following is NOT a sandboxing method?
ADirect hardware access
BContainers
CVirtual machines
DRestricted user permissions
✗ Incorrect
Direct hardware access is not a sandboxing method; it bypasses isolation.
Sandboxing helps AI agents by:
APreventing harmful actions from affecting the system
BMaking them run faster
CAllowing them to run without any limits
DRemoving all errors automatically
✗ Incorrect
Sandboxing prevents harmful actions from affecting the system.
What risk does sandboxing reduce when testing new code?
ARisk of code running too slowly
BRisk of system damage or data loss
CRisk of code being too simple
DRisk of code being too short
✗ Incorrect
Sandboxing reduces the risk of system damage or data loss.
Which environment is commonly used to sandbox code?
ASpreadsheet
BText editor
CVirtual machine
DEmail client
✗ Incorrect
Virtual machines provide isolated environments for sandboxing code.
Explain in your own words what sandboxing dangerous operations means and why it is useful.
Think about how you might keep a risky task from causing problems.
You got /4 concepts.
Describe two ways to create a sandbox environment and how they help keep systems safe.
Consider tools that separate code from the main system.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of sandboxing dangerous operations in agentic AI?
easy
A. To run risky code safely without harming the main system
B. To speed up the execution of all code
C. To permanently delete unsafe files automatically
D. To make the code run without any errors
Solution
Step 1: Understand sandboxing concept
Sandboxing creates a safe space to run risky code separately from the main system.
Step 2: Identify the main goal
The goal is to protect the system from crashes or data loss caused by dangerous operations.
Final Answer:
To run risky code safely without harming the main system -> Option A
Quick Check:
Sandboxing = safe risky code execution [OK]
Hint: Sandboxing isolates risky code to protect your system [OK]
Common Mistakes:
Thinking sandboxing speeds up all code
Believing sandboxing deletes files automatically
Assuming sandboxing removes all errors
2. Which of the following is the correct way to start a sandbox environment in Python using the sandbox module?
easy
A. sandbox.init()
B. sandbox.run()
C. sandbox.execute()
D. sandbox.start()
Solution
Step 1: Recall sandbox module usage
The common method to begin a sandbox session is start() in many sandbox libraries.
Step 2: Match method names
Among the options, only sandbox.start() correctly initiates the sandbox environment.
Final Answer:
sandbox.start() -> Option D
Quick Check:
Start sandbox = sandbox.start() [OK]
Hint: Look for 'start' to begin sandbox safely [OK]
Common Mistakes:
Using run() which may execute outside sandbox
Confusing execute() with start()
Using init() which may not start sandbox
3. Consider this Python code snippet using a sandbox to run a risky operation:
import sandbox
sandbox.start()
result = sandbox.run('2 + 2')
sandbox.stop()
print(result)
What will be printed?
medium
A. 4
B. '2 + 2'
C. Error: sandbox.run not defined
D. None
Solution
Step 1: Understand sandbox.run behavior
The sandbox.run method executes the string expression safely inside the sandbox.
Step 2: Evaluate the expression '2 + 2'
Evaluating '2 + 2' returns the integer 4, which is stored in result.
Final Answer:
4 -> Option A
Quick Check:
Sandbox runs code safely, output = 4 [OK]
Hint: Sandbox.run executes string code safely and returns result [OK]
Common Mistakes:
Thinking sandbox.run returns the string itself
Assuming sandbox.run is undefined
Expecting None instead of result
4. You wrote this code to sandbox a dangerous file operation:
But the file was overwritten on your system. What is the likely error?
medium
A. The sandbox.stop() was missing
B. Sandbox was not properly isolating file writes
C. The open function is blocked in sandbox
D. The code should use sandbox.write() instead
Solution
Step 1: Analyze sandbox isolation failure
If the file was overwritten, sandbox did not isolate the file write operation properly.
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.
Final Answer:
Sandbox was not properly isolating file writes -> Option B
Quick Check:
Sandbox isolation failure = file overwritten [OK]
Hint: 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
5. 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
A. Run the code on your main system but monitor CPU usage
B. Run the code directly with exec() and catch exceptions
C. Run the code inside a containerized sandbox limiting file and network access
D. Run the code after removing all import statements manually
Solution
Step 1: Understand sandboxing for dangerous code
Containerized sandboxing isolates code with strict limits on file and network access.
Step 2: Evaluate other options
Using exec() directly is unsafe; monitoring CPU does not prevent damage; manual import removal is error-prone and incomplete.
Final Answer:
Run the code inside a containerized sandbox limiting file and network access -> Option C
Quick Check:
Container sandbox = safest isolation [OK]
Hint: Use container sandbox to limit risky operations [OK]