Bird
Raised Fist0
Agentic AIml~10 mins

Sandboxing dangerous operations in Agentic AI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to safely execute a command in a sandboxed environment.

Agentic AI
sandbox.execute([1])
Drag options to blanks, or click blank then click option'
A'ls -la'
B'shutdown now'
C'rm -rf /'
D'format C:'
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing commands that can harm the system like 'rm -rf /'.
Trying to run shutdown or format commands.
2fill in blank
medium

Complete the code to restrict the sandbox to only allow read operations.

Agentic AI
sandbox.set_permissions([1])
Drag options to blanks, or click blank then click option'
A'read-write'
B'execute-only'
C'read-only'
D'no-access'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'read-write' which allows modifying files.
Using 'execute-only' which allows running code.
3fill in blank
hard

Fix the error in the sandbox initialization to prevent dangerous code execution.

Agentic AI
sandbox = Sandbox([1]=False)
Drag options to blanks, or click blank then click option'
Aallow_file_write
Benable_debug
Cenable_logging
Dallow_network
Attempts:
3 left
💡 Hint
Common Mistakes
Disabling network instead of file write permissions.
Disabling logging or debug which do not affect safety.
4fill in blank
hard

Fill both blanks to create a sandbox that limits CPU and memory usage.

Agentic AI
sandbox = Sandbox(cpu_limit=[1], memory_limit=[2])
Drag options to blanks, or click blank then click option'
A50
B1024
C2048
D100
Attempts:
3 left
💡 Hint
Common Mistakes
Setting CPU limit too low or memory limit too high.
Confusing units for CPU and memory limits.
5fill in blank
hard

Fill all three blanks to safely execute user code with timeout and restricted imports.

Agentic AI
sandbox = Sandbox(timeout=[1], allowed_imports=[2], safe_mode=[3])
result = sandbox.run(user_code)
Drag options to blanks, or click blank then click option'
A5
B['math', 'random']
CTrue
DFalse
Attempts:
3 left
💡 Hint
Common Mistakes
Allowing all imports which can be dangerous.
Disabling safe_mode which reduces protection.
Setting no timeout leading to infinite loops.