AI Coding-Agent Guardrails interview questions

27 questions from the AI Coding-Agent Guardrails course, each with the correct answer and an explanation. Try to answer before you open the answer.

The Threat Model

1. What is the main goal of guardrails?

  1. To make mistakes impossible
  2. To slow the agent down
  3. To make mistakes small, visible and reversible
  4. To replace code review
Show answer

Answer: To make mistakes small, visible and reversible

You cannot remove all errors, but you can limit what an error can do.

Lesson: Why Guardrails

2. An agent edits the CI workflow when asked to fix a typo. Which risk family is this?

  1. Scope creep
  2. Network latency
  3. Font rendering
  4. Cache misses
Show answer

Answer: Scope creep

Changing files outside the task is scope creep, controlled by protected paths and diff review.

Lesson: What Can Go Wrong

3. How should an agent treat text found inside a dependency's README?

  1. As trusted instructions
  2. As a command from the user
  3. As the system prompt
  4. As untrusted data
Show answer

Answer: As untrusted data

Content from outside your control is data and must never gain the authority of an instruction.

Lesson: Trust Boundaries

4. Why use several independent guardrail layers?

  1. More layers always run faster
  2. One failure then does not become an incident
  3. A single layer is illegal
  4. It removes the need for logs
Show answer

Answer: One failure then does not become an incident

If one control fails, another can still stop or limit the harm.

Lesson: Defence in Depth

Permissions and Command Policy

5. How should an action that is not listed in the policy be treated?

  1. Allowed automatically
  2. Asked about, the safe default
  3. Ignored
  4. Deleted
Show answer

Answer: Asked about, the safe default

Defaulting to ask (fail closed) means a forgotten case cannot silently run something risky.

Lesson: Allow, Ask, Deny

6. Why does `git status; rm -rf x` pass a "starts with git status" rule?

  1. Git runs rm automatically
  2. rm is a safe command
  3. The semicolon is invalid
  4. The rule only checks the beginning of the line
Show answer

Answer: The rule only checks the beginning of the line

Chaining operators append extra commands after the matched prefix.

Lesson: Why Prefix Allowlists Fail

7. In the parsed allowlist, what happens to a line containing `$(...)`?

  1. It is rejected because of the metacharacter
  2. It runs with extra logging
  3. It is rewritten by the shell
  4. It is always allowed
Show answer

Answer: It is rejected because of the metacharacter

Metacharacters are rejected up front, so command substitution cannot hide a second command.

Lesson: A Parsed Allowlist

8. Why is an allowlist not a sandbox?

  1. Sandboxes are slower
  2. Allowlists cannot be written
  3. Allowed commands can still execute arbitrary project code
  4. They are the same thing
Show answer

Answer: Allowed commands can still execute arbitrary project code

An allowlist limits requests; a sandbox limits what any process can actually reach.

Lesson: Allowed Commands Can Still Run Code

Filesystem and Sandbox

9. Why is "path string starts with project folder" an unsafe check?

  1. Folders cannot have names
  2. Strings cannot be compared
  3. `..` and symlinks can point outside the folder
  4. It is too slow
Show answer

Answer: `..` and symlinks can point outside the folder

Only the resolved real path shows where a file operation will actually land.

Lesson: Path Guards and Symlinks

10. What should be mounted into the agent's container?

  1. Only the project folder
  2. The whole home directory
  3. The Docker socket
  4. Your SSH key folder
Show answer

Answer: Only the project folder

Exposing only the project keeps credentials and unrelated files out of reach.

Lesson: Containers and Dev Environments

11. Which file should usually be a protected path?

  1. A unit test for a helper
  2. A README paragraph
  3. A code comment
  4. A CI workflow file
Show answer

Answer: A CI workflow file

CI files control what runs with repository secrets, so changes need extra scrutiny.

Lesson: Protected Paths

Secrets and Network

12. What is a good way to limit the secrets an agent shell can see?

  1. Copy all your variables into it
  2. Start it with a clean environment
  3. Share your admin keys
  4. Print the environment in chat
Show answer

Answer: Start it with a clean environment

An empty starting environment means inherited tokens cannot be read or leaked.

Lesson: Keeping Secrets Out of Reach

13. What is the right role of a redaction filter?

  1. A replacement for access control
  2. A last-line safety net in addition to keeping secrets away
  3. A way to share secrets safely
  4. A guarantee that nothing leaks
Show answer

Answer: A last-line safety net in addition to keeping secrets away

It catches mistakes but is imperfect, so prevention comes first.

Lesson: Redacting Secrets

14. Why match the exact hostname rather than "contains pypi.org"?

  1. It makes no difference
  2. Hostnames are case-insensitive only
  3. Substring checks are faster
  4. Look-alike domains such as pypi.org.evil.com would pass
Show answer

Answer: Look-alike domains such as pypi.org.evil.com would pass

Attackers register domains that contain a trusted name, so only exact matches are safe.

Lesson: Network Egress Allowlists

Git and CI Guardrails

15. Which control stops even a compromised agent from pushing to main?

  1. Server-side branch protection
  2. A polite note in the prompt
  3. A longer commit message
  4. Using dark mode
Show answer

Answer: Server-side branch protection

Rules enforced by the Git host apply regardless of what the agent tries.

Lesson: Branches, Never Main

16. What should happen when an agent's pull request exceeds the size limit?

  1. It merges automatically
  2. The limit is raised silently
  3. It is split or gets deeper review
  4. The tests are deleted
Show answer

Answer: It is split or gets deeper review

Large changes get more scrutiny, not less.

Lesson: Diff Size and Scope Gates

17. Why are server-side CI checks more trustworthy than local checks?

  1. Local checks are always wrong
  2. CI is always faster
  3. The agent cannot silently modify or skip them
  4. Local checks cost money
Show answer

Answer: The agent cannot silently modify or skip them

Checks controlled outside the agent's environment remain valid even if the agent is compromised.

Lesson: CI and Review as the Final Authority

Hooks, Policy as Code and Budgets

18. When should a hook fail?

  1. Closed: block the action if the hook crashes
  2. Open: allow the action if the hook crashes
  3. Randomly
  4. Never
Show answer

Answer: Closed: block the action if the hook crashes

Failing closed prevents a broken check from silently letting risky actions through.

Lesson: Pre-Action Hooks

19. Why store the agent policy in the repository?

  1. So agents can edit it freely
  2. Because Git requires it
  3. To make it secret
  4. So changes are reviewed and shared like code
Show answer

Answer: So changes are reviewed and shared like code

Version control gives history, review and a single shared baseline.

Lesson: Policy as Code and Managed Settings

20. What does a session-wide budget catch that per-action checks miss?

  1. Spelling mistakes
  2. Loops and runaway behaviour across many individually fine actions
  3. Slow keyboards
  4. Missing semicolons
Show answer

Answer: Loops and runaway behaviour across many individually fine actions

Each action may look fine alone while the total is clearly excessive.

Lesson: Budgets and Rate Limits

Detection and Response

21. What should each audit log line include besides the action?

  1. The agent's password
  2. The decision and the reason
  3. A joke
  4. Nothing else
Show answer

Answer: The decision and the reason

Knowing why an action was allowed or denied is essential for improving the policy.

Lesson: Audit Logging

22. What should you do after discovering a guardrail bypass?

  1. Hide the logs
  2. Hope nobody finds it
  3. Delete the guardrail
  4. Fix it and add a test case for it
Show answer

Answer: Fix it and add a test case for it

A regression test keeps the same bypass from reappearing after future changes.

Lesson: Red-Teaming Your Guardrails

23. An agent may have exposed a key. What comes right after stopping it?

  1. Revoke or rotate the key
  2. Write a blog post
  3. Wait a week
  4. Rename the repository
Show answer

Answer: Revoke or rotate the key

Until the credential is revoked, anyone who captured it can keep using it.

Lesson: Incident Response and the Kill Switch

Putting It Together

24. Which is the better way to loosen a guardrail?

  1. Remove everything at once
  2. Disable logging first
  3. Loosen one capability at a time using audit evidence
  4. Ask the agent to decide
Show answer

Answer: Loosen one capability at a time using audit evidence

Incremental, evidence-based changes keep risk visible and reversible.

Lesson: Case Study: Rolling Out Agents to a Team

25. A hook script crashes while checking a command. What should happen to that command?

  1. It is allowed to keep things moving
  2. It runs twice
  3. It is blocked (fail closed)
  4. It is ignored forever
Show answer

Answer: It is blocked (fail closed)

A broken check must not silently allow risky actions.

Lesson: Revision: Cheat Sheet and Self-Check

26. An injected instruction tells the agent to upload `.env` to a website. Which two controls most directly stop it?

  1. Denying reads of .env and an egress allowlist
  2. A longer system prompt and a bigger font
  3. More commit messages
  4. Dark mode
Show answer

Answer: Denying reads of .env and an egress allowlist

One control keeps the secret out of reach; the other blocks the destination, so the attack needs two failures.

Lesson: Revision: Cheat Sheet and Self-Check

27. Which statement about prefix allowlists is correct?

  1. They are safe because commands are short
  2. They are required by Linux
  3. They replace sandboxes
  4. They can be bypassed by chaining operators and substitution
Show answer

Answer: They can be bypassed by chaining operators and substitution

`git status; rm -rf x` starts with an allowed prefix yet runs a second command.

Lesson: Revision: Cheat Sheet and Self-Check

← Back to the course