User- and group-based policies
Give a directory group, a user, a connector or a single agent its own guardrail policy with guardrail profiles. Write the assignments, see which profile a person gets, read the audit record, and ship the same config to managed hosts.
A guardrail profile is a named set of guardrail overrides. When several profiles are proven to match a request, the profile that enforces at least what each of the others does applies; when none does, their strictest combination applies. If an assignment needs an identity fact the OS has not confirmed, the request is refused and the missing fact is named. A default profile catches everyone else. For the task, see Give a group its own policy.
Where the identity comes from
DefenseClaw reads who a user is from the operating system and never calls
Active Directory, Okta or Entra. Only facts the OS vouches for (verified)
can select a profile. See
How DefenseClaw knows who a user is.
Group assignments follow the OS-verified account ID. When two accounts share
a visible name, an administrator uses each uid or SID with the managed
enterprise <os> profile-explain --user to inspect their decisions
separately; a per-user install explains only your own account.
Give a group its own policy
A guardrail profile is a named set of guardrail settings. You assign profiles to directory groups, users, agents or connectors. When several profiles are proven to match, the one that covers the others, or their strictest combination, applies; default_profile catches everyone else. A request whose assignment needs an identity fact the operating system has not confirmed is refused, and the refusal names that fact. Only identities the operating system vouches for can select a profile (how DefenseClaw knows who a user is).
Before you start
- The users are in a directory group or a local group on the host. Find the exact spelling:
id -Gnon Linux, ordefenseclaw guardrail profile explain --user alice --json | jq .subjectrun as alice (a per-user install explains only your own account). - The AD group names in this page's YAML examples use Linux SSSD's
name@domainform. On a managed macOS host, use theDOMAIN\groupspelling thatenterprise macos profile-explainlists for that user. A Linuxname@domainentry does not select the macOS AD group. - On Windows, group profiles need the standalone enterprise install. Per-user installs have no group list.
- Steps 1 to 3 are for a per-user install. A managed host (Linux, macOS or Windows) has no per-user
config.yamland nodefenseclaw guardrailcommands exceptdefenseclaw guardrail profile explainon Linux and macOS, which shows a standard user their own profile (Managed command availability): put the profiles in the machine config and check them as Deliver it to managed hosts shows. On Windows that is& 'C:\Program Files\Cisco\DefenseClaw\bin\defenseclaw.exe' config validate FILEand& 'C:\Program Files\Cisco\DefenseClaw\bin\defenseclaw.exe' enterprise windows profile-explain --user CORP\alice, from an elevated PowerShell prompt.
Steps
-
Add profiles and assignments to
~/.defenseclaw/config.yaml. Contractors are enforced from day one; the ML team stays in observe mode.~/.defenseclaw/config.yaml guardrail: mode: observe profiles: contractors: description: Contractors are enforced from day one mode: action block_at: MEDIUM alert_at: LOW ml-team: description: The ML team stays in observe mode mode: observe profile_assignments: - profile: contractors match: {groups: ["contractors@corp.example.com"]} - profile: ml-team match: {groups: ["ml-team@corp.example.com"]} default_profile: ml-teamFor a managed AD-bound Mac, replace the first group selector with the name that
enterprise macos profile-explainreports for the user's group:macOS AD group selector match: {groups: ['CORP\contractors']}A person in both groups gets
contractors: it enforces at least whatml-teamdoes. Order does not matter. -
Validate the file and list what the gateway sees.
defenseclaw config validate defenseclaw guardrail profile listGuardrail profiles ------------------ * contractors Contractors are enforced from day one (mode=action, block_at=MEDIUM, alert_at=LOW) * ml-team The ML team stays in observe mode (mode=observe) * assignments (strictest applies): 1. contractors <- groups=contractors@corp.example.com 2. ml-team <- groups=ml-team@corp.example.com * default: ml-teamconfig validaterejects an unknown profile name, an emptymatch, a malformed agent id and a forbidden key. -
Ask which profile a person gets. With no
--user,guardrail profile explainexplains the account that runs the command. The managedenterprise linux|macos|windows profile-explaincommands need--userwhen an administrator runs them; on Linux and macOS a standard user leaves it out and gets their own profile only. A per-user install also explains only the account that runs it: run the command as the person, since--userwith another account is refused.defenseclaw guardrail profile explain --user alice@corp.example.com --connector claudecodeGuardrail profile resolution ---------------------------- user: alice (7 group(s)) profile: contractors match: group (contractors@corp.example.com) digest: sha256:49ed…0c64 … applies (claudecode): mode=action block_at=MEDIUM alert_at=LOW hilt=off rule_pack=…matchsays why:agent,user,group,connector,default,default_unverifiedordefault_lookup_failed(reference). A warning line names a group the host does not know; fix the spelling.
Check it worked
profile explain shows the expected profile and mode. The gateway applies config changes on its next reload. Each hook decision records defenseclaw.guardrail.profile.name, so the audit log shows which profile decided.
Good to know
- Set a strict
default_profilefor accounts no assignment selects. While a directory lookup fails, a request whose assignment needs the missing fact is refused (default_lookup_failed) and names that fact. - On a per-user install the user owns
config.yamland can change their own profile. On a managed host the profile lives in the machine config: the administrator checks the file with/opt/defenseclaw/bin/defenseclaw-gateway config validate FILE, applies it with/opt/defenseclaw/bin/defenseclaw-gateway enterprise linux ensure --config FILE(/opt/cisco/defenseclaw/bin/defenseclaw-gateway enterprise macos ensure --config FILEon macOS), and checks one account with/opt/defenseclaw/bin/defenseclaw-gateway enterprise linux profile-explain --user USER --connector CONNECTOR(/opt/cisco/defenseclaw/bin/defenseclaw-gateway enterprise macos profile-explainon macOS), as root.
Undo
Delete the profiles, profile_assignments and default_profile keys. Everyone follows the global guardrail.* settings again.
A complete example
guardrail:
mode: observe # the global posture, used when no profile applies
block_at: HIGH
profiles:
strict:
description: Default for verified users who match nothing else
mode: action
block_at: MEDIUM
contractors:
description: Contractors are enforced from day one
mode: action
block_at: MEDIUM
alert_at: LOW
hilt: {enabled: true, min_severity: LOW} # asks below block_at; at or above it the call blocks
rule_pack: strict
connectors:
codex: {mode: observe} # but Codex only observes for this profile
ml-team:
description: The ML team stays in observe mode
mode: observe
alice-codex:
description: Stricter Codex policy for one person
connectors:
codex: {mode: action, block_at: MEDIUM}
profile_assignments: # when several match, the strictest applies
- profile: ml-team # by one agent install
match: {agents: ["agt-3f9c0a1b2c3d4e5f"]}
- profile: alice-codex # by user and connector together
match:
users: ["alice@CORP.EXAMPLE.COM"]
connectors: [codex]
- profile: contractors # by directory group
match: {groups: ["contractors@corp.example.com"]}
- profile: ml-team # by directory group
match: {groups: ["ml-team@corp.example.com"]}
default_profile: strict # everyone verified who matched nothing aboveThen check it and see who gets what:
defenseclaw config validate
defenseclaw guardrail profile list
defenseclaw guardrail profile explain --user alice@corp.example.com --connector codexprofile list prints the profiles, the ordered assignments and the default.
config validate rejects an unknown profile name, an assignment with an empty
match, a malformed agent ID and a forbidden key.
What a profile can set
| Key | Meaning |
|---|---|
description | Free text for operators. |
mode | observe records policy findings without enforcing them; hook fail mode and proxy availability still apply. One exception: an agent that changes DefenseClaw's own files, such as a copy into ~/.defenseclaw, is blocked in every mode (rule tamper.detector_state_write, with every rule pack). action enforces the thresholds. A profile's own mode (or its connectors.<agent>.mode) applies inside the person's managed sandboxes too, so an observe profile alerts there with "would block" as on the host. A sandbox whose profile sets no mode enforces, whatever guardrail.mode says. |
block_at, alert_at | CRITICAL, HIGH, MEDIUM or LOW. These effective thresholds apply to tool calls, prompts, responses and proxy decisions. When unset, the selected rule pack supplies the levels (a strict pack blocks MEDIUM and above by default). A profile with block_at: CRITICAL can therefore turn a MEDIUM prompt finding from a strict-pack block into an alert, according to its effective alert_at. Secure Client rejects profiles and keeps its existing content thresholds. A plain regex rule that only matches text an inert command prints (echo marker) is recorded on a tool call but does not block; a rule meant to block a command needs an expression over the parsed command (CEL rules). |
hilt | enabled and min_severity (LOW, MEDIUM, HIGH or CRITICAL, in any case, like block_at) for human approval. |
rule_pack | A rule pack for this profile: default, strict, permissive or a guardrail.custom_packs name. When a custom pack's directory does not load as the gateway starts (it is created a moment later, for example by the MDM that delivers it), the profile scans with the base rule set and the gateway retries the pack every 30 seconds; explain says so meanwhile. A reload refuses a pack that does not load. |
rules | Rule customization for this profile: protections, rules turned on or off, severity overrides and suppressions. Edit it with defenseclaw guardrail protection, rule and suppress, which take --profile P. |
block_message | The text a blocked user sees. |
connectors.<name> | The same settings for one connector, except description. |
enabled and hook_fail_mode are rejected inside a profile and inside its
connector entries, because both are built into the hooks installed on the
machine. A profile name is lower case letters, digits, - and _, at most 64
characters.
For one connector, the most specific value wins:
- the profile's
connectors.<name>entry; - the profile's own field;
guardrail.connectors.<name>(see Multi-connector);- the application protection overlay;
- the global
guardrail.*value.
Write the assignments
Each assignment has a profile and a match with at least one of four keys.
| Key | Matches | Spell it as |
|---|---|---|
groups | A directory or local group of the verified user | Linux: the name id -Gn prints, which is group@domain with SSSD fully qualified names (ml-team@corp.example.com). Write it fully qualified then: the bare name selects nobody, and the warning names the spelling the host knows. A bare name that is also a local group of the host (/etc/group, the local macOS node) selects the members of that local group; the warnings say so and profile explain reports matched_group_source (local, directory or local and directory); local and directory means that the bare name matched both a local group and a DOMAIN\name group in the user's group list. If the source cannot be determined, matched_group_source is left out. A SID selects nobody on Linux and macOS, and a malformed SID selects nobody anywhere; ensure, status and verify warn about each (profile_assignment_unmatched). A numeric group id matches only while no name answers for that group on the host: the host then lists the group by its gid, and once the group has a name, write the name. id -Gn separates groups with spaces, and a space can belong to a name: Active Directory's default group prints as domain users@corp.example.com, so copy everything up to and including @domain, or read the exact name with getent group <gid> (id -G lists the gids). Quote such a name in YAML ('domain users@corp.example.com'). Case does not matter. Windows: CORP\ML-Team, the bare name ML-Team, or the SID, including Entra S-1-12-1-... SIDs. A standalone enterprise gateway resolves each name to its SID when it loads the config and matches the SIDs of the caller, so a slow domain controller cannot make a resolved group miss. A name whose SID lookup is still unresolved leaves a needed assignment fact unproven, so affected requests are refused with that missing group SID named (the gateway waits up to 3 seconds for the lookup when it loads the config, then retries every minute); a name definitively absent selects nobody, and profile explain, status and doctor name it until it does (the gateway retries it every minute). The gateway also looks each resolved name up again every minute, so a group that is deleted and created again under the same name (it gets a new SID) is followed within a minute, and a deleted one is named as no longer existing. An Entra group matches only when a built-in local group lists it (Entra groups on Windows). macOS AD: use the DOMAIN\name group name from dscl, dseditgroup or profile-explain; Linux SSSD's name@domain does not match it. id -Gn splits names containing spaces. A bare name also selects, by its name part, the members of the DOMAIN\name Active Directory group the user is already listed in; this bare-name match runs on every host that has no Windows SID resolver, so a Linux host whose groups print as DOMAIN\name (winbind) behaves the same way. On macOS DefenseClaw also asks Open Directory whether the user is a member, nested groups included, of each group name an assignment writes (names that contain @ are skipped, since a macOS group cannot have one); Open Directory's search order only decides which group that nested-membership check resolves (the local one when both exist). An account in more than 2048 groups fails the group lookup instead of matching part of its groups. Write DOMAIN\name to target only the Active Directory group. For macOS and Windows domain groups in YAML, use single quotes such as 'CORP\ML-Team' or double the backslash inside double quotes ("CORP\\ML-Team"). Obtain Windows names containing spaces from the Windows group tools. Entra groups reach Linux only through Himmelblau or Entra Domain Services, and never reach macOS through Platform SSO (Entra groups per platform). |
users | The verified user | Entries are compared literally, never as patterns: * or ? selects nobody, and ensure, status and verify warn (profile_assignment_unmatched); use default_profile for everyone no assignment selects. A uid or SID, the account name, DOMAIN\user (CORP\alice, the form winbind and Windows report), or the principal or UPN (alice@CORP.EXAMPLE.COM). DOMAIN is the account's NetBIOS domain (CORP) or its DNS domain. A bare account name selects directory accounts only; a local account (in /etc/passwd, the computer's SAM or the local macOS node) is selected by its uid or SID, or as .\user on every platform (also COMPUTER\user on Windows). An Entra ID account matches as AzureAD\name. On macOS an AD account matches as DOMAIN\user when it is in the domain the Mac is bound to, the form macOS uses for its groups, and by its UPN, which the hook guardian reads from the account's domain record (a mobile account's included). On standalone enterprise Linux the UPN of an SSSD account comes from SSSD InfoPipe (userPrincipalName listed in the [ifp] user_attributes); when InfoPipe stops reporting it, the guardian keeps the UPN it read before, and status, verify, profile explain and the gateway log warn (profile_assignment_unmatched), as they do when an entry written as a UPN matches no account while InfoPipe reports none. |
connectors | The connector the request comes from: the hook route, the connector an inspect call authenticated for, or the connector the LLM proxy serves | codex, claudecode, cursor and the others. |
agents | One agent install | An agent identity from defenseclaw agent identities: agt- and 16 hex digits. |
On Linux, a group ID with no name counts as unnamed only when every NSS
group provider the system asks shows that it has no name for it. A provider
DefenseClaw cannot check (Himmelblau, aad) leaves the name unknown. The
account is still in the group, so a groups entry with the number can
match. An assignment whose groups entry may name that group makes the
request refuse with the missing group fact named (default_lookup_failed).
After upgrading from 1.0.0–1.0.3 on Linux or macOS, an agents entry written
for a 1.0.x agent ID keeps applying, with no rebind step, to the account that
held the UID at the upgrade. At its first identity pass after the upgrade, the
root hook guardian records, once, which account held each enrolled UID (its
name and its SID, or the identity of its home directory) in a migration map in
the identity spool, legacy-agent-owners.json. The file is owned like the
other spool files and never changes afterwards.
An account the map does not record (a later account given the UID, a namesake from another domain, an account created again) does not get the entry as a match. The request is refused until ownership of the entry is proven; its profile is listed as a candidate for diagnosis. Windows needs nothing: the 1.0.x agent IDs of a SID are unchanged. A per-user (non-managed) gateway keeps its own account's entries.
On Linux, a local account without a SID is proven by its home directory, and
the gateway takes that proof only while the local account database has not
changed since the guardian last read it. Any change to /etc/passwd
(useradd, userdel, usermod, or a standard user's own chfn or chsh,
which are setuid and rewrite the file) therefore refuses the requests of every
local account whose profile comes from such a 1.0.3 agents entry, with
ownership of a pre-upgrade agent identity is unconfirmed, until the
guardian's next pass, at most about a minute later. A clock that is ahead
when the file changes does not make the refusal last longer. Workaround: wait
about a minute and retry.
On Linux, for up to one guardian pass (about a minute) after an account
without a SID (a local, SSSD or LDAP account) is deleted and created again
under the same uid, name and home path, the new account's agent requests can
still be recorded under the earlier account's agent identity, and a directory
account can still get the earlier holder's pre-upgrade agents assignment.
Workaround: wait one minute before the new account's first agent session, or
give the new account another uid.
After an upgrade from 1.0.3 or 1.0.4 on a managed Linux host, a local account
that was deleted and created again under the same uid and name more than seven
days before the first agent request after the upgrade, and that has run no
agent since, or whose home is on a file system that keeps no creation time
(some NFS mounts), can be taken for the earlier holder of a 1.0.3 agents
assignment. Workaround: give a recreated account another uid, or remove the
earlier holder's 1.0.3 agents entry.
How the keys combine:
- Keys AND, values OR. Inside one
match, every key you list must match. For one key, any one value is enough.{groups: [a, b], connectors: [codex]}means "in group a or b, and using Codex". - The profile that covers the others applies, or their strictest
combination. When several profiles are proven to match a request, DefenseClaw
applies the profile that enforces at least what each of the others does.
When none does, it applies their strictest combination, whatever the order
of the assignments. Order only sets which assignment
explainreports when two give the same profile. Different proven profiles do not cause a refusal. - The strictest combination. Every block of any candidate applies, each
in its own mode on each path: hooks take the candidates whose hook mode
blocks, the inspect endpoints and the LLM proxy those whose guardrail mode
blocks. On a path, the action applies wherever one blocks, with the lowest
block_atand the strictest HILT of those that block there, and the rules of their rule packs are enforced. A candidate that only observes on a path changes nothing there. Suppressions apply only when all those packs share them (allows are the intersection). Every sensitive tool any of them inspects is inspected. A tool call is judged within the same semantic rule cost budget as with one profile; a rule several packs share is judged once. The sandbox limits of all candidates are combined: requirements and blocks are unions, allowed lists are intersections, and false wins. If no sandbox can satisfy them all (for example two different required packs), no sandbox runs, and an agent one of them requires in a sandbox does not run on the host either.hook_fail_modeis a machine setting, so it is the same for all. The block message is the base configuration's.profile-explainshows the combination to administrators as a profile namedstrictest.<a>.<b>withcandidate_profiles. A user sees "strictest combination" and never the names of the other profiles:explainandstatusshow a user only their own effective policy. - Unproven facts refuse a decision that needs them. When a fact an
assignment needs is not proven in this pass (the directory lookup failed or
timed out, a group name no provider confirms, a UPN the guardian has not
written yet, a Windows group name whose SID lookup is pending, a uid more
than one account holds, or a pre-1.0.4
agentsentry the upgrade did not bind), the request is refused with the missing fact named. A refused hook call gets the event's own denial where the agent's hook can deny it (Claude CodePostToolBatchincluded). An event the hook can only observe (AntigravityPostToolUse, Cursor's after-the-fact events) is allowed and auditedwould_block, not enforced, and a stop, session-end or idle event gets the agent's plain allow, so the agent is never asked to start another turn.profile explainshowsrefused,refused_reason,unproven_factsand the candidate profiles (default_lookup_failed). A fact no assignment needs does not make the decision uncertain. An account is recognized by its SID (SSSD or Windows) or by its macOS local record; for an account that has neither (a local or LDAP Linux account, a macOS directory account with no local record) no profile is kept, so an account deleted and created again under the same UID and name never gets the former account's profile. - Case and accents' encoding do not matter. Groups, account names,
principals and UPNs compare without regard to case, so
alice@CORP.EXAMPLE.COMandalice@corp.example.comare the same user. They also compare as the same text whether an accented letter is typed precomposed (é) or as a letter plus a combining accent, as some editors and copy-paste sources produce it. - A bare name selects directory accounts, never a local namesake. It is
the name without its domain, so
alicematches the directory accountalice@corp.example.comon a host that uses short account names, but not a local accountalicethat someone created on the host: that account is another person and gets the next assignment or the default profile. Select a local account by its uid or SID, or as.\alice. Requests andguardrail profile explainbuild the user the same way, andconfig validate,ensure,status,verifyand the gateway log warn (profile_assignment_unmatched) when a bare entry names a local account of the host. A name whose domain the directory does not confirm, such as annss_ldapor plain LDAP account namedbob@corp.example.comorCORP\bob, is not matched by name at all, only by its uid. Use the principal, the uid or the SID to tell two people of the same short name apart. When a bare name selects a directory account,explain,statusanddoctorwarn and name the principal to write instead. On a qualified-name SSSD Active Directory host with one joined domain, a bare entry keeps matching that account after a 1.0.3 upgrade. With multiple joined Active Directory domains or a configured trusted child, the entry selects the account of that name in each domain: the default and permissive policy tiers match it and explain, status, verify and doctor warn and name every account; the strict policy tier refuses affected requests when the assignment could change the profile. Write the qualified principal the warning shows, or the uid, to select one account. DOMAIN\usernames the verified account domain. The domain part is the NetBIOS name (or DNS name) the directory confirms for the account: winbind, also withuse default domain = yeswhere accounts have bare names; SSSD for an Active Directory account it holds by its SID; the LSA on Windows; the AD binding on a Mac. It is never guessed from the first label of the DNS domain, soCORP\alicedoes not select an account of another domain.- On Linux a principal needs the account's SID. A principal-only
assignment (
alice@CORP.EXAMPLE.COM) matches an SSSD account only when SSSD holds a SID for its uid and the joined domain holdsalicewith that same SID. An account of another SSSD domain, such as plain LDAP, or annss_ldapaccount never gets the AD principal, whatever its name. While SSSD does not answer (stopped, restarting, or no answer within 2 seconds) the lookup fails and the account keeps its last facts for up to an hour; with none, a principal-dependent assignment refuses the request (default_lookup_failed) and names the missing account fact. Add the uid to the assignment when the account must match regardless. Groups follow the same rule: an account keeps only the groups inside the domain of its SID (an LDAPcarolnext to an ADcaroldoes not get the ADcarol's groups), and an account whose qualified-looking name no directory confirms (an LDAP account namedbob@corp.example.comorCORP\bob) is selected by its uid only. See When Linux attributes a principal. - Nothing matches: the default. A request that no assignment selects gets
guardrail.default_profile. An empty default keeps the globalguardrail.*settings.
Find the exact spelling of a user's groups before you write the assignment:
defenseclaw guardrail profile explain --user alice@corp.example.com --json | jq .subjectThe subject lists the user ID, the principal and the groups exactly as the
gateway sees them, so the name in your assignment is the name that matches.
Assign by the name id -Gn prints, and check the assignments again after a
group is renamed or deleted in the directory: an assignment that names the old
name selects nobody, and the users of that group fall through to the next
assignment or the default. The gateway looks the groups of your assignments up
in the operating system, and a group it definitely does not find is a warning in
guardrail profile explain, guardrail profile list, guardrail status and
doctor (on standalone enterprise, enterprise <os> status and verify,
code profile_assignment_unmatched; the gateway lists these warnings only
with its credential, because they name groups and accounts, so on Windows
status run from a prompt that is not elevated says how many there are
instead), and a line in the gateway log at start,
at every reload and when a later check (at most once a minute, while the
gateway is asked for its health or a profile) first finds it, for example after
an SSSD naming switch
([guardrail] assignment 1: group "..." is not known to this host). A lookup
that fails or times out says nothing. Neither does the check while the
directory is unreachable: an SSSD that is offline with a cold cache answers
"no such group" for groups that exist, so the warnings wait while the
"Directory lookups" warning is showing, and for an account whose own lookup
failed. A bare group name (no domain to ask) is not reported as renamed or
deleted on standalone enterprise while the directory answers for none of the
directory accounts in the guardian's identity records: one note says the
groups could not be checked, and they are checked again once it answers. On
Windows the SID of a group survives a rename, so it is the spelling to use
there; on Linux and macOS a group is matched by its name.
How many profiles. A config holds at most 1,024 profiles and 4,096
assignments. Profiles cost time when the config loads: at gateway start, at
each reload and in each defenseclaw command that reads config.yaml. On a
2 vCPU Linux host, with one assignment of three groups per profile,
defenseclaw-gateway start took about 0.45 seconds longer with 100 or 250
profiles than without profiles, and about 1 second longer with 1,000.
Requests do not slow down with the number of profiles: the gateway matches a
subject once and caches the result. To keep the config small, give one profile to many
groups in one match rather than writing a profile for each group.
The match reason
Every decision records why a profile was chosen. When an assignment sets more
than one key, the reason names the most specific key, in the order
connector, group, user, agent.
match | Meaning |
|---|---|
agent | An agents entry matched. |
user | A users entry matched (also when connectors was set too). |
group | A groups entry matched; matched_group names it. |
connector | Only a connectors entry matched. |
default | The user is verified, but no assignment matched, so default_profile applied. |
default_unverified | No verified user reached the gateway, so only assignments that match on connectors alone could apply. |
default_lookup_failed | An identity fact was not proven in this pass (a failed or slow directory lookup, a group name no provider confirms, a UPN the guardian has not written yet, a Windows group name whose SID lookup is pending, a uid more than one account holds, a pre-1.0.4 agents entry the upgrade did not bind). A request whose assignment needs the fact is refused and names it; otherwise the proven or default profile applies. A per-user Linux gateway whose own process groups are known but whose account holder needs a root-only SSSD check uses the profile selected by a proven connector-only assignment, or the configured default when none match, for OSS default and permissive hooks when the holder is the sole missing fact and a possible profile only lowers the block threshold with the same rule pack, sandbox and approval controls. explain and doctor show an account-holder warning. Inspection takes the same fallback only where the selected profile already blocks on it. A profile that would start blocking there, managed installs and the strict tier still require proof. On refusal, explain lists refused_reason, unproven_facts and candidate_profiles; the candidate profile is diagnostic and does not authorize the request. |
Only verified facts select a profile
The subject of a profile decision is the user the gateway authenticated the
request as, with the directory facts it resolved for that user from the
operating system: the hook socket's peer, a per-user credential, and the
account the gateway runs as on a per-user install (see
how the gateway learns who called).
An agent in a sandbox counts as the user who started the sandbox, with the
same facts and refresh as that user's other agents, and its hooks always
enforce (see
sandboxed agents).
Identity headers, hook payloads and claimed
facts never reach the matcher. A user who forges a header, sets
KRB5CCNAME or alters a hook payload cannot change verified identity. On a
standalone enterprise install, the user cannot edit the machine-owned profile
or move to a weaker one. On a per-user install, the user owns the configuration
file and can change their own profile; enforce profiles with machine-owned
configuration when users must not weaken them.
What follows when the identity is missing:
- No verified user. Assignments with
users,groupsoragentscannot match. Onlyconnectors-only assignments can, then the default applies (default_unverified). - Directory lookup fails or is slow. A first request for a user the
gateway has not seen yet waits up to two seconds for a cold SSSD or Active
Directory answer. Then every assignment is read without names or groups.
One that matches on the verified uid, SID, agent or connector alone
matches. One that names groups, or lists users by name but not this uid or
SID, may match. One that lists only other uids or SIDs, or another agent or
connector, does not. If an assignment may match on the missing facts, the
request is refused and names them (
default_lookup_failed). If no assignment needs them, the proven match or default applies. The lookup is retried 15 seconds later. Later requests use the cached answer. A lookup counts as failed unless every part of it finished: an account whose group list timed out, or that is in more than 2,048 groups, has no facts rather than part of its membership. On Linux the group names are looked up 64 at a time, one batch after the other because a cold SSSD answers one request at a time, so an account in several hundred groups resolves in one background lookup even when SSSD starts cold (about 30 ms per group, so 400 groups take around 12 seconds). Facts that still hold a group as a bare number (no group answered for that id) are served but refreshed after two minutes, not 15. The gateway log names the account and the reason once when its lookup starts failing ([identity] directory lookup for 1201 failed: ... in 3000 groups, more than the 2048 ...) and once when it works again, andguardrail profile explainshows the same reason as a lookup error instead of a profile. - Windows group names have a limit. Windows resolves names for at most 128
groups per account within the two-second lookup budget. Additional groups
remain as SIDs. Use a group SID in the assignment when the named group may
be beyond that limit;
profile explainwarns about unresolved names. - macOS group facts must be newer than the account listing. A group fact newer than the last account listing is not proven. A request that finds the listing expired waits up to 250 ms for a new one. Until a listing confirms the account, or after the account's own record changed since the listing, its groups are unproven and a group-dependent assignment refuses the request with the missing group fact named.
- Managed macOS hooks check secondary groups on each call. The gateway
waits up to two seconds for a current Open Directory answer. If it cannot
obtain one, a group-dependent assignment is unproven and the hook refuses
when that assignment could change the profile.
profile-explainuses the same fresh lookup. A group removal takes effect on the first hook after Open Directory reports it. - Group changes take time on Linux and per-user macOS. SSSD caches the account first (90 minutes by
default). The gateway caches each successful directory lookup for up to
15 minutes from the last successful lookup, then starts a background refresh
on a request. Incomplete or partial answers are retried sooner. A request
after expiry may use the previous facts while its lookup runs. A user added to a group gets the
group's profile after the operating system and gateway see the change.
guardrail profile explainasks the operating system directly, so it already shows the new profile, and it hands the facts it resolved to the gateway's cache: the hooks of the explained account use the new profile from their next call. Itscache:line (per-user CLI) orcacheobject (managedprofile-explain:age_seconds,refresh_after_seconds,differs) states the facts the hooks use now;differsis true only when explain could not resolve the account itself. A config push that changesguardrail.profiles,guardrail.profile_assignmentsorguardrail.default_profilehas each account refresh its facts at its next request, so a pushed assignment applies to a group the user already joined. On a bound Mac the longer delay can be Open Directory's own membership cache (a removed member stayed in the group for more than ten minutes): flush it withdscacheutil -flushcacheanddsmemberutil flushcache, then explain the account, or restart the gateway. Managed macOS hooks check again on every call after Open Directory reports the change. On Windows, group profiles use a current desktop sign-in token. After sign-out, group membership is unknown: a group-dependent assignment refuses an SSH or scheduled-task agent until the user signs in at the desktop again. A membership change also needs a new desktop sign-in. On Linux and per-user macOS, while the directory does not answer, the gateway keeps using a user's last facts for at most an hour (four times the cache lifetime). After that group-dependent assignments cannot be proven and refuse requests with the missing group fact named until a lookup succeeds (default_lookup_failed). A verified UID, SID or agent assignment still matches when no assignment needs the missing group fact.defenseclaw doctor,guardrail statusandguardrail profile explainwarn while lookups are failing, with the number of accounts, the first failure and the reason; the gateway log has one line when an account's lookups start to fail and one when they work again.
An unverified request that no connectors-only assignment selects gets the
default profile. Set a strict default_profile for requests whose identity
facts are fully known but no assignment matches.
Per-user installs on Windows have no groups
On a per-user Windows install the gateway cannot read the sign-in token's
groups, so groups assignments never match and explain shows no groups.
users, connectors and agents assignments work. Group-based profiles on
Windows need the standalone enterprise profile, where the SYSTEM enumerator
supplies the groups. Per-user Linux and macOS installs read groups from the
OS account database.
Worked scenarios
Contractors enforced, the ML team observing
Start every developer in observe mode while you tune the rule packs, enforce
for contractors from the first day, and pin the ML team to observe so that
moving the global mode to action later does not change theirs.
guardrail:
mode: observe
profiles:
contractors: {mode: action, block_at: MEDIUM, alert_at: LOW}
ml-team: {mode: observe}
profile_assignments:
- {profile: contractors, match: {groups: ["contractors@corp.example.com"]}}
- {profile: ml-team, match: {groups: ["ml-team@corp.example.com"]}}A person in both groups gets contractors: it enforces at least what ml-team does.
Block MEDIUM for one group only
Everyone else keeps the global HIGH threshold.
guardrail:
mode: action
block_at: HIGH
profiles:
finance: {block_at: MEDIUM}
profile_assignments:
- {profile: finance, match: {groups: ["finance@corp.example.com"]}}finance sets only block_at; it inherits the mode, the rule pack and
everything else from the global settings.
A stricter policy for one connector for one user
guardrail:
profiles:
alice-codex:
connectors:
codex: {mode: action, block_at: MEDIUM}
profile_assignments:
- profile: alice-codex
match:
users: ["alice@CORP.EXAMPLE.COM"]
connectors: [codex]Alice's Codex requests get the stricter policy. Alice using Claude Code, and everybody else using Codex, fall through to the next assignment or the default.
Pin one agent
defenseclaw agent identities --user alice --connector codexCopy the agt- ID into an agents assignment. The ID names one connector
install for one user on one machine and stays the same across sessions and
restarts. On Linux and macOS the ID changes on upgrade from 1.0.0–1.0.3 to
1.0.4: it now includes the account's domain. The old assignment keeps applying
to the account the migration map recorded; there is no rebind step.
See Agent identity.
The pin applies to every decision the gateway makes for that install: its
hooks, its /api/v1/inspect calls and, for OpenClaw and ZeptoClaw, its LLM
traffic through the guardrail proxy. The proxy attributes each request to the
connector it serves and to that connector's install for the user the gateway
runs as, so an OpenClaw or ZeptoClaw install appears in
defenseclaw agent identities after its first proxied request. On proxied
traffic the profile sets the mode, the block message, the rule pack,
block_at, alert_at and hilt.
A pin names one install, so keep three things in mind:
- Sub-agents share the agent's
agt-, so one pin covers the agent and its sub-agents. - If the connector's config root moves, the install gets a new
agt-and the old pin matches nothing. List the identities again. - A sandboxed agent has its own
agt-per sandbox, so pinning the host install does not pin a sandboxed run. See sandboxed agents.
Try it and read the result
Ask the gateway
explain asks the running gateway, which resolves the user through the OS
the way it does for a live request. With no --user it explains the account
that runs the command. On Windows, name an Entra ID user by SID, as
AzureAD\<name>, by the bare name or by the UPN.
defenseclaw guardrail profile show contractors
defenseclaw guardrail profile explain --user alice@corp.example.com --connector codex user: alice (3 group(s))
profile: ml-team
match: group (ml-team@corp.example.com)
digest: sha256:4f460f32fe21aa052aa524027ba08c9f89fe695cbe39cea2fb0252e5e0a738bd
applies (codex): mode=observe block_at=pack alert_at=pack hilt=off rule_pack=...block_at=pack means the profile leaves the level to the rule pack. Add
--agent agt-... to see an agent assignment and --json for the full answer
with the subject and the effective settings. guardrail status, status and
doctor name the profile that decides for the account that runs them.
Read the decision record
Every hook, ACP and LLM proxy decision carries the profile and the reason:
| Attribute | Meaning |
|---|---|
defenseclaw.guardrail.profile.name | The profile that applied; absent when none did. |
defenseclaw.guardrail.profile.digest | sha256: digest of the profile's effective policy. |
defenseclaw.guardrail.profile.match | The reason, from the table above. |
defenseclaw.guardrail.profile.matched_group | The group that matched, for group. |
The same record carries the user and defenseclaw.agent.identity.id, and the
principal when ai_discovery.include_user_principal is on.
defenseclaw audit export --since 1h \
| jq -c 'select(.action=="hook_decision") | .structured
| {user: ."defenseclaw.user.name",
profile: ."defenseclaw.guardrail.profile.name",
match: ."defenseclaw.guardrail.profile.match",
digest: ."defenseclaw.guardrail.profile.digest"}'See a change land
Edit the config and the running gateway applies it on its next reload, with no
restart in the default hot mode. Each profile whose effective policy changed
writes one audit event with the reason guardrail_profile_reload and the
path guardrail.profiles.<name>.digest, holding the old and the new digest.
The stored action is config-update; audit export writes it as
config.change.applied, so filter on the reason, not the action. Compare the digest in a decision with the
one explain reports to prove which version of the policy decided it.
defenseclaw audit export --since 1h \
| jq -c 'select(tostring | contains("guardrail_profile_reload"))'The Grafana Identity & Users board charts decisions by profile and match reason and the digest timeline.
Deliver it to managed hosts
On a managed host (the enterprise package, MDM or Setup) the profiles live in the machine config, not in a user's home, and apply to every enrolled user.
| OS | Machine config | How a change applies |
|---|---|---|
| Linux | /etc/defenseclaw/config.yaml | defenseclaw-enterprise-apply.path runs ensure when the file changes |
| macOS | /opt/cisco/defenseclaw/etc/config.yaml | The apply LaunchDaemon runs ensure when the file changes |
| Windows | C:\ProgramData\Cisco\DefenseClaw\etc\config.yaml | Run Setup /ensure again with the new file |
-
Add the same
guardrail.profiles,profile_assignmentsanddefault_profilekeys to the machine config. A profile'srule_packnames a preset or aguardrail.custom_packsentry, as in Custom rule packs. -
Deliver the file the way you deliver the rest of the machine config, with your MDM (Deliver the config) or by hand:
sudo /opt/defenseclaw/bin/defenseclaw-gateway enterprise linux ensure --config /root/defenseclaw-config.yaml --jsonensurevalidates the file first. A config with an unknown profile or a forbidden key is refused and the installed config stays in force. Linux and macOS reportconfig_invalid; Windows argument preflight reportsinvalid_arguments(exit1639), with the reason inerrors[].message. See Change the config. -
Check the result as root. A managed install has no
defenseclawPython CLI (Managed command availability), so the checks use the gateway binary and print JSON:sudo /opt/defenseclaw/bin/defenseclaw-gateway enterprise linux profile-explain --user alice@corp.example.com --connector codexOn a Mac use
/opt/cisco/defenseclaw/bin/defenseclaw-gateway enterprise macos .... On Windows run& 'C:\Program Files\Cisco\DefenseClaw\bin\defenseclaw.exe' enterprise windows profile-explain --user CORP\alicefrom an elevated PowerShell prompt. The answer also lists every configured profile and its digest underprofiles. On Linux the command, run as root, resolves the account itself through NSS and passes those facts to the gateway, so a fresh local account does not stop atdefault_lookup_failedbecause the gateway service cannot run root-only SSSD checks. The JSON then has"facts_source": "caller". The gateway's own lookup is the fallback.
On a managed Windows computer, group profiles use the user's active desktop session token. After sign-out, group-dependent assignments use the default profile; the next desktop sign-in supplies current groups. SSH and scheduled-task sessions do not supply those groups. Guardrail profiles are rejected under the Secure Client profile, which keeps its behavior as it was.
Next steps
- Build a policy in the browser
- Thresholds
- Identity sources: the OS facts behind a verified identity.
- Configuration reference: every key and default.
- Per-connector overrides: the settings profiles layer on.
Multi-connector
One DefenseClaw gateway enforces guardrail policy for several hook connectors at once, each with its own mode, fail mode, HITL, block message and rule pack under guardrail.connectors. Add a connector with setup <connector> and choose Add.
Changing connectors
Use defenseclaw setup <connector> to add or reconfigure connector wiring, and setup remove <connector> to retire a connector without deleting audit history.