Skip to content

CCDV-F · Domain 7: Security and Safety · 8% of the exam

Task 7.2: Deterministic Guardrails and Least Privilege

Layered guardrails, the narrowest permissions that do the job, and hooks that enforce rules in code, so destructive actions cannot run even when the instructions are hostile.

Study it

  • Deterministic guardrails, least privilege and enforcing hooks

    Partly covered by: Guardrails

Sample questions

Try each one before opening the answer. Every option is explained, with the Anthropic documentation page that proves it.

Question 1 · choose 1

Your security team ships a PreToolUse hook in the repository's .claude/settings.json that blocks destructive commands. A developer who finds it slow commits nothing but adds this to their own .claude/settings.local.json:{"disableAllHooks": true}The guard must keep running for everyone, whatever their own settings files say. What should the security team do?

  1. ADeploy the hook through managed settings, since disableAllHooks set in user, project or local files can't disable managed hooks
  2. BMove the hook into each developer's ~/.claude/settings.json so that it no longer sits in a shared file
  3. CAdd "allowManagedHooksOnly": true to the project's .claude/settings.json so that local settings can't remove the hook
  4. DCopy the hook into .claude/settings.local.json as well, so that both files carry it
Show the answer and why
  • ADeploy the hook through managed settings, since disableAllHooks set in user, project or local files can't disable managed hooks

    Correct

    Only disableAllHooks set at the managed settings level can turn off hooks configured there.

  • BMove the hook into each developer's ~/.claude/settings.json so that it no longer sits in a shared file

    Incorrect

    A local file outranks user settings, so the local disableAllHooks still applies.

  • CAdd "allowManagedHooksOnly": true to the project's .claude/settings.json so that local settings can't remove the hook

    Incorrect

    allowManagedHooksOnly is a managed setting, and it restricts hooks to the managed ones rather than keeping a project hook.

  • DCopy the hook into .claude/settings.local.json as well, so that both files carry it

    Incorrect

    The same file's disableAllHooks turns off every hook outside managed settings.

Hooks merge across settings levels, and disableAllHooks follows the settings precedence. Set in user, project or local settings, it can't disable hooks configured through managed policy, so a guard that must always run belongs in managed settings.

Question 2 · choose 2

Claude Code runs on untrusted repositories in your review environment. Even if a file in a repository instructs it to, no shell command it runs may send data to any host other than github.com. Today the only control is an allow rule, Bash(curl http://github.com/ *). Which TWO changes enforce the requirement? (Choose TWO.)

  1. ATurn on the Bash sandbox with network.allowedDomains listing only github.com
  2. BRewrite the allow rule as Bash(curl https://github.com/*) so that only GitHub URLs can match
  3. CAdd a CLAUDE.md line telling Claude never to contact other hosts
  4. DSet allowUnsandboxedCommands to false so that blocked commands can't be retried outside the sandbox
  5. ERely on the sandbox's allowedDomains to keep the WebFetch tool on github.com as well
Show the answer and why
  • ATurn on the Bash sandbox with network.allowedDomains listing only github.com

    Correct

    The operating system enforces the sandbox's network limits on shell commands and the processes they start.

  • BRewrite the allow rule as Bash(curl https://github.com/*) so that only GitHub URLs can match

    Incorrect

    Bash patterns that constrain arguments are fragile; variables or other tools get past them.

  • CAdd a CLAUDE.md line telling Claude never to contact other hosts

    Incorrect

    CLAUDE.md is context Claude tries to follow, not an enforced control.

  • DSet allowUnsandboxedCommands to false so that blocked commands can't be retried outside the sandbox

    Correct

    With the unsandboxed retry disabled, Claude Code ignores the request to run a command outside the sandbox.

  • ERely on the sandbox's allowedDomains to keep the WebFetch tool on github.com as well

    Incorrect

    allowedDomains limits shell commands; built-in web tools follow permission rules instead.

Argument-matching Bash rules are fragile, for example against URL=http://github.com && curl $URL. The Bash sandbox is enforced by the operating system around shell commands and their processes, with network access limited to allowed domains; disabling unsandboxed retries removes the escape hatch. WebFetch is governed by permission rules.

Question 3 · choose 1

Your organization wants only the permission rules it deploys to apply on company machines, so that allow rules in developers' user or project settings are ignored. Which setting does this, and where?

  1. AallowManagedPermissionRulesOnly, set in managed settings
  2. BallowManagedPermissionRulesOnly, set in each repository's .claude/settings.json
  3. CdefaultMode "dontAsk", set in each developer's user settings
  4. DA deny rule for every tool in the repository's settings
Show the answer and why
  • AallowManagedPermissionRulesOnly, set in managed settings

    Correct

    It makes managed settings the only source of permission rules.

  • BallowManagedPermissionRulesOnly, set in each repository's .claude/settings.json

    Incorrect

    It is a managed setting; project files can't set it.

  • CdefaultMode "dontAsk", set in each developer's user settings

    Incorrect

    A permission mode does not stop other files' allow rules from applying.

  • DA deny rule for every tool in the repository's settings

    Incorrect

    That blocks tools rather than making the organization's rules the only ones.

allowManagedPermissionRulesOnly is a managed-only setting that makes managed settings the only settings source of permission rules, so allow rules from user or project settings no longer apply.

Question 4 · choose 1

A team wants a Claude Code hook that blocks writes to migration files outside business hours, and the rule must apply the same way every time. Which kind of hook fits a deterministic rule like this?

  1. AA prompt-based hook, so that a model judges each write
  2. BA command hook that runs a script with the rule
  3. CA Notification hook that alerts the team about each write
  4. DA CLAUDE.md line describing the rule
Show the answer and why
  • AA prompt-based hook, so that a model judges each write

    Incorrect

    Prompt-based hooks are for decisions that need judgment.

  • BA command hook that runs a script with the rule

    Correct

    Shell command hooks give deterministic control over the action.

  • CA Notification hook that alerts the team about each write

    Incorrect

    Notification hooks fire when Claude Code sends a notification, not before a tool call, so they cannot block the write.

  • DA CLAUDE.md line describing the rule

    Incorrect

    A line in CLAUDE.md relies on Claude choosing to follow it.

Hooks give deterministic control: certain actions always happen rather than relying on the model to choose them. Use shell command hooks for deterministic rules, and prompt-based hooks only for decisions that need judgment.

Practice domain 7 →Practice all domains →