MDM kit reference

Look up MDM kit options, execution requirements, Windows Setup properties, detection script options, the credential rotation journal and Win32 packager.

This page lists the options and rules of the MDM kit in packaging/mdm and of the Windows Setup. The task flow, exit codes, upgrades and uninstall are in Install with an MDM.

Wrapper options

The Linux and macOS wrapper is defenseclaw-enterprise.sh; the Windows wrapper is Invoke-DefenseClawEnterprise.ps1 (PowerShell 7).

Linux and macOSWindowsMeaning
--action ensure|status|verify-Action Ensure|Status|VerifyDefault ensure. status and verify are read-only and take no config or key. The Linux and macOS wrapper refuses a source with them; the Windows wrapper accepts -SetupPath. Use the uninstall script to remove.
--source FILE or --source-url https://...-SetupPath FILEThe artifact. Without it, the wrapper re-applies the installed deployment.
--sha256 HEX-Sha256 HEXThe pin. Required with hash-pinned trust.
--trust-mode hash_pinned|signed-TrustMode HashPinned|AuthenticodeDefault hash-pinned.
--allowed-team-id ID (macOS), --gpg-keyring FILE with --signature FILE or --signature-url URL (Linux)-AllowedSigners THUMBPRINT[,...]Signer pins for signed trust.
--config-file, --config-stdin-ConfigPath, -ConfigFromStdinThe config.
--secret-name with --secret-file or --secret-stdin-SecretName with -SecretPath or -SecretFromStdinThe optional key.
--cowork-package FILE, --cowork-signature FILE (macOS)-CoworkPackagePath, -CoworkSignaturePathA local Claude Cowork archive and its optional signature. The config carries their SHA-256 pins.
--format json|jamfnonejamf wraps the result document in <result> for Jamf Pro.
--product-version X.Y.Z-ProductVersion X.Y.ZLinux and macOS: refuse an artifact of any other version (mdm_version_mismatch) before anything is installed. Windows: only without -SetupPath; with it the wrapper refuses (mdm_invalid_arguments, 1639), because the pin already ties the Setup to one release.
--https-proxy URLnoneProxy for the download only. The services' own proxy is set in the config (Network proxy).
--log FILEnoneWrapper log path.
--staging-dir DIRnoneThe root-only folder for the staged artifact and config. Default /var/lib/defenseclaw-mdm on Linux and /var/tmp on macOS.

Rules for these options:

  • Downloads. --source-url must serve the file itself. The wrapper downloads with curl (or wget) and does not follow redirects, so a GitHub release link fails with HTTP 302. Host the artifact on your own HTTPS server.
  • Staging folder. It must be owned by root and not writable by others (mdm_staging_untrusted). A payload source runs its defenseclaw-gateway from there, so the filesystem must allow execution; CIS hosts mount /tmp and /var/tmp noexec.
  • fapolicyd. On an enforcing fapolicyd host, the payload source does not update the staged and installed-tree trust. Use the deb or rpm with the wrapper, or the manual two-stage tarball steps.
  • Unknown arguments. The wrapper refuses any argument it does not know, including positional arguments, with exit 2 (mdm_invalid_arguments). An MDM that appends its own arguments needs the line its recipe gives.

Settings block

Script-only MDMs that cannot pass arguments set the same values in the settings block at the top of defenseclaw-enterprise.sh. Flags override the settings block.

DC_ACTION, DC_SOURCE, DC_SOURCE_URL, DC_SOURCE_SHA256, DC_TRUST_MODE, DC_ALLOWED_TEAM_IDS, DC_GPG_KEYRING, DC_SIGNATURE, DC_SIGNATURE_URL, DC_PRODUCT_VERSION, DC_CONFIG_FILE, DC_COWORK_PACKAGE, DC_COWORK_SIGNATURE, DC_SECRET_NAME, DC_SECRET_FILE, DC_FORMAT, DC_HTTPS_PROXY, DC_LOG, DC_STAGING_DIR.

The config can also go between the DEFENSECLAW_CONFIG markers in dc_inline_config.

Linux signed trust

gpgv needs a binary keyring. Convert the release key once and deploy the result as a root-owned file:

gpg --dearmor < defenseclaw-enterprise-release-key.asc > defenseclaw-enterprise-release-key.gpg

Execution requirements

RequirementDetail
SYSTEM or rootOn Windows an elevated administrator session also works. The wrappers refuse anything else (mdm_not_root, mdm_not_elevated), and so does Setup.
No terminal, no inherited environmentThe Linux and macOS scripts set their own PATH and locale and work under env -i with no TTY. They read standard input only for --config-stdin or --secret-stdin.
Windows: native x64The lifecycle refuses ARM64 and 32-bit Windows. The wrapper also refuses a 32-bit or emulated PowerShell, Constrained Language Mode, and .NET loader-injection variables such as DOTNET_STARTUP_HOOKS. A 32-bit agent that starts Windows PowerShell must use %SystemRoot%\Sysnative\WindowsPowerShell\v1.0\powershell.exe.
Windows: PowerShell 7From Microsoft's x64 MSI, in C:\Program Files\PowerShell\7. The lifecycle refuses a preview build or one the MSI did not register. Invoke-DefenseClawEnterprise.ps1 and New-DefenseClawIntunePackage.ps1 need 7.4 or later. Setup, detect.ps1, uninstall.ps1 and the Intune scripts start without it.
One run at a timeA second run while one holds the lifecycle lock, or while dpkg, rpm or the macOS installer is busy, exits 1618 (Windows) or 75 (Linux, macOS). Retry later.
Windows: a busy computerA Setup that would upgrade the installed release exits 1618 (lifecycle_busy) before it changes anything when the processors are less than 25% idle over 6 seconds. The upgrade runs below normal priority so agent hooks keep answering.

Time limits on Windows

  • Setup gives the lifecycle 30 minutes by default (TIMEOUTSECONDS=60 to 7200), counted from when Setup starts.
  • A run with less than about a minute left after its payload checks changes nothing. A change needs TIMEOUTSECONDS of at least about 120; lower values suit only /verify and /status.
  • An upgrade can take several minutes, so keep the default unless you have a reason not to.
  • A run stopped at TIMEOUTSECONDS then runs its own recovery for up to 10 more minutes. Allow TIMEOUTSECONDS plus 10 minutes (40 minutes by default). An MDM that ends Setup sooner can stop that recovery and leave verify failing until the next /ensure or /repair.

Leftovers of an unmanaged install (Linux, macOS)

If DefenseClaw machine files exist that no committed deployment owns, ensure refuses with unmanaged_layout_present. Take them over once as root with enterprise linux ensure or enterprise macos ensure, adding --adopt-existing and --from-package (or --payload <dir>). It backs the old files up first. The wrapper does not pass --adopt-existing.

On a Linux tarball host with fapolicyd, use the two-stage install flow and pass --adopt-existing to the staged ensure.

Windows staging and Setup-only runs

The staging folder must be writable only by SYSTEM and Administrators, or the wrapper and Setup refuse the config. On client editions a new folder under C:\ can carry entries for Authenticated Users and Users that /inheritance:r does not remove. Remove them by name:

icacls C:\Staging /inheritance:r /grant:r "*S-1-5-18:(OI)(CI)F" "*S-1-5-32-544:(OI)(CI)F"
icacls C:\Staging /remove:g "*S-1-5-11" "*S-1-5-32-545" /T /C

icacls C:\Staging /T then lists only NT AUTHORITY\SYSTEM and BUILTIN\Administrators.

If your MDM can run a native executable as SYSTEM but not PowerShell 7, run Setup directly. Setup has no pin of its own, so check its SHA-256 first, in the in-box Windows PowerShell 5.1:

$pin = '<SHA-256 of the Setup from checksums.txt>'
$setup = 'C:\Staging\DefenseClawSetup-Enterprise-Standalone-x64.exe'
if ((Get-FileHash -LiteralPath $setup -Algorithm SHA256).Hash -ne $pin) { exit 1603 }
& $setup /ensure JSON=1 CONFIG=C:\Staging\config.yaml
exit $LASTEXITCODE

Setup properties

DefenseClawSetup-Enterprise-Standalone-x64.exe takes one action and NAME=value properties. Names are case-insensitive and ignore dashes. /quiet and /norestart are accepted and ignored. /? prints the list.

Action or propertyMeaning
/ensureInstall, upgrade, repair or no-op. Use this from an MDM.
/install, /upgrade, /repair, /reconcile, /status, /verify, /uninstallThe individual actions. /install also needs MANIFEST=, so use /ensure instead.
CONFIG=Absolute path of the config. Required for the first install.
MANIFEST=Optional administrator target manifest (targets.yaml). A first install with enterprise.enrollment.mode: manifest needs it.
COWORKPACKAGE=, COWORKSIGNATURE=A local Claude Cowork archive and its detached signature, checked against the config's SHA-256 pin.
ALLOWEDSIGNERS=Comma-separated SHA-256 thumbprints of accepted Authenticode signers.
JSON=1Print the result document on standard output. Always set it from an MDM.
NOSTART=1Install with the services stopped and disabled (mutating actions only).
PURGE=1With /uninstall, also remove each enrolled account's DefenseClaw data and per-user binaries.
FORCE=1With /uninstall, last resort: remove the deployment without recovering a pending transaction.
TIMEOUTSECONDS=Lifecycle timeout, 60 to 7200 seconds, counted from when Setup starts. Default 1800. See Time limits on Windows.
ATTESTCLAUDEEFFECTIVEPOLICY=1With /repair: record the administrator's attestation that Claude Code runs DefenseClaw's managed hooks. See Claude Code on Windows.

Setup refusals before the lifecycle starts

The standalone Setup checks its command line first:

ConditionExit and code
An unknown property, a CONFIG= or MANIFEST= path that is missing, relative or environment-expanded, /install without CONFIG= and MANIFEST=, or TIMEOUTSECONDS out of range1639, invalid_arguments
A CONFIG= or MANIFEST= file that a non-administrator owns or can change (the message names the account and the icacls fix)1639, invalid_arguments
A config that is malformed, not UTF-8 or does not validate. The installed config stays as it was.1639, invalid_arguments
A token that is not elevated1603

With JSON=1, Setup prints the same schema-version-2 document as the lifecycle, with errors[] and exit_code. Setup scans every argument for JSON=1, so /ensure BOGUS=1 JSON=1 still returns the JSON refusal.

Detection scripts

detect.ps1 (Windows)

detect.ps1 [-MinimumVersion X.Y.Z] [-RequireHealthy] [-RequireSessionsProtected] follows Intune's custom-detection rules:

  • Detected: exit 0, one line on standard output (DefenseClaw Enterprise <version>) and nothing on standard error.
  • Not detected: exit 1, with the reason on standard error.
  • It reads the marker through the 64-bit registry view, so it works in 32-bit Windows PowerShell.

detect.sh (Linux, macOS)

detect.sh [--min-version X.Y.Z] [--require-healthy] [--require-security-complete] [--require-tetragon MODE] [--require-sessions-protected] [--format exit|value|jamf] asks the installed, root-owned gateway for its status instead of trusting files. Run it as root.

FormatExit codeOutput
exit (default)0 when detected, 1 otherwiseDefenseClaw Enterprise <version> on standard output, or the reason on standard error
valueAlways 0 (except for a failed session check)The installed version, or not-installed, outdated (with --min-version), unhealthy (with --require-healthy), unknown (not run as root) or busy (a lifecycle run holds its lock). For inventory attributes.
jamfAlways 0 (same exception)The same values inside <result>...</result>, for Jamf Pro extension attributes
OptionMeaning
--require-healthyverify must pass with coverage_complete: true. When security_complete is false, every reason must be a host-hardening warning (hook_process_fail_open, unprivileged_user_namespaces, unprivileged_ptrace); those are printed on standard error and the host is healthy. Any other reason, such as agent_sessions_restart_required, guardian_repair_pending, enrolled_home_unavailable or agent_unprotected, reports unhealthy.
--require-security-completeAlso requires security_complete: true (DC_REQUIRE_SECURITY_COMPLETE=1 in the settings block).
--min-versionA dotted release such as X.Y.Z; a bad value exits 2. A leading v and build metadata (+...) are ignored, and a prerelease sorts before its release.
--require-tetragon consume|observe|enforceLinux only. Also runs enterprise linux tetragon verify --ready-for MODE --json; a failing check is tetragon-not-ready:<first failing check> in value and jamf format. See Tetragon on a Linux fleet.
--require-sessions-protectedFails while a running agent session predates its managed hooks.
  • Lock contention is busy (exit 75 in exit format). It is transient: retry after the apply finishes, and keep the device in the group it was in.
  • On Linux it reports unhealthy while dpkg lists the package half-configured or rpm lists two versions of it (an install cut short by a power loss), so the MDM runs the deployment again.
  • An unknown argument or a bad --format exits 2 and prints nothing on standard output.

Accounts without hooks

When an installed agent runs without DefenseClaw hooks for one account (agent_unprotected, hook_contract_unverified), verify reports a warning for that account and passes, with security_complete: false.

OSHealth result
Windowsdetect.ps1 -RequireHealthy follows the verify exit code, so the device stays healthy.
Linux, macOSdetect.sh --require-healthy reports unhealthy: hook_contract_unverified makes coverage_complete false, and agent_unprotected is not a host-hardening warning.

To collect security_complete across a fleet, read it from the last lifecycle result (%WINDIR%\Logs\DefenseClaw\last-result.json on Windows; the --json output of status on Linux and macOS) with a custom compliance script or inventory attribute.

Windows registry values

Besides the ProductVersion marker, Windows keeps:

  • The Add/Remove Programs entry HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\CiscoDefenseClawEnterprise (DisplayName "Cisco DefenseClaw Enterprise", DisplayVersion).
  • The marker's other values under HKLM\SOFTWARE\Cisco\DefenseClaw\Enterprise: Profile, InstallRoot, StateRoot, TrustMode, UpdatedAt and DisableSelfUpdate.

Claude Code on Windows

With Claude Code enabled, a Windows host reports security_complete: false until an administrator attests that Claude Code runs DefenseClaw's managed hooks.

  1. In an enrolled user's own session, have Claude Code make a tool call.
  2. From an elevated prompt, export the gateway's record with defenseclaw audit export --connector claudecode -o <file>.
  3. Once the record shows that call, run Setup /repair JSON=1 ATTESTCLAUDEEFFECTIVEPOLICY=1 (see Verify the install).

The record is bound to the hashes of the installed Claude Code policy and hook binary, so every upgrade makes it stale. Computers on the same release and Claude Code hook contract share the binding: check one reference computer, then push the /repair command to the others from your MDM after each upgrade.

When a Windows apply is not confirmed

On a device in bundle mode, a new signed bundle that never reaches a gateway reporting its policy before the apply deadline is failed, and the lifecycle restores its previous config.

CaseResult
Restoring or proving the previous policy fails during an outageThe gateway is stopped.
The gateway accepted the bundle but became unavailable before confirming itThe receipt stays applied and pending. Run ensure again after recovery to settle it.
A run was interrupted after writing the configA staged receipt stays pending until ensure checks the gateway.
An already confirmed bundle is delivered again during an outageIts signed config stays installed; the retry returns not_confirmed and creates no new receipt.

Credential rotation journal

When you deliver a credential with a bundle, the wrapper first writes what it replaces to a root-only journal: /var/lib/defenseclaw-mdm/rotation on Linux, /var/db/defenseclaw-mdm/rotation on macOS.

  • The bundle does not apply. The wrapper puts the earlier value back, or removes a credential it added.
  • The run is stopped. The next ensure restores the earlier value before it changes anything.
  • The new value stays only when the gateway reports that a bundle confirmed since uses it. Until then, <name>.value in the journal holds a root-only copy of the earlier credential.
  • The gateway refuses the put-back. The journal entry stays, the wrapper log says why, and the wrapper rotates no other credential until it is resolved. Every ensure then exits mdm_secret_failed. Deliver the package with --source, or fix the logged cause, and run ensure again.
  • Two runs at once. The wrapper holds a lock on the journal. A run that waits logs it after 2 seconds, then once a minute, for up to 10 minutes.

Intune Win32 packager

packaging/mdm/intune/windows/New-DefenseClawIntunePackage.ps1 builds the content folder that Intune, Workspace ONE and Configuration Manager install. It needs PowerShell 7.4 or later.

ParameterMeaning
-SetupPathThe Setup. Required.
-Sha256The Setup's pin. Required with hash-pinned trust; the script refuses a Setup that does not match.
-TrustModeHashPinned (default) or Authenticode.
-AllowedSignersWith Authenticode: SHA-256 thumbprints of accepted signer certificates, comma-separated or repeated.
-ConfigPathThe config. Without one the first install fails with 1639. Leave it out of an upgrade without -BundlePath for a device in bundle mode, which refuses it with bundle_required.
-BundlePathA signed policy bundle (.dcbundle). With -ConfigPath: the single app. Alone: a bundle-only app, which needs -BaseConfigPath. Both need -RequireBundle.
-BaseConfigPathWith -BundlePath alone: the base app's config. Its guardrail: block must be the bundle's, apart from custom_packs.<pack>.path, and its claude_code:, codex:, connector_hooks: and application_protection: blocks must be the bundle's or absent from both. No other setting is compared.
-TrustAnchorPathWith -BundlePath: the bundle trust anchor file to install.
-RequireBundleWith -BundlePath: the bundle version or id the generated detect-bundle.ps1 requires.
-OutputDirectoryWhere to write. Required. Its content folder must not exist yet.
-IntuneWinAppUtilPath to IntuneWinAppUtil.exe. When set, the script also builds the .intunewin. Leave it out for other MDMs.
-ProductVersionThe release version. The script prints it in the detection rule and records it.

The script verifies the Setup against -Sha256 (and, for Authenticode, its signer). It writes content\ with the Setup, config.yaml, Install-DefenseClawIntune.ps1 and intune-package.json, which holds the pins setup_sha256 and config_sha256, the trust mode and the allowed signers.

What the packager refuses

  • A config that is not config_version: 9, or that has an inline api_key.
  • A config that is not plain ASCII with LF or CRLF line endings: no tab, lone CR or non-ASCII byte, even in a comment. One UTF-8 byte order mark is allowed.
  • A top-level key that is not plain lowercase (a tag, anchor, escape or ? key).
  • A quoted value, {...} or [...] that continues on the next line.

The single app

With -ConfigPath, -BundlePath, -TrustAnchorPath and -RequireBundle the packager builds one app. Its install command runs Setup /ensure CONFIG= BUNDLE= TRUSTANCHORS=:

  • On a device without DefenseClaw, Setup installs from config.yaml with every service stopped and disabled, then applies the bundle, starts the services on it and confirms it. No service runs on config.yaml, and until the bundle applies a DefenseClaw hook refuses the call.
  • If the bundle is not applied, Setup removes that install and the app fails (1603), so the MDM retries the whole app.
  • On an installed device the app applies the bundle only. Deliver a later bundle version as a new version of the same app.

Use the generated detect-bundle.ps1 as its detection rule. Devices installed with a base app and a separate bundle app take the single app as it is: assign it, then remove the two earlier assignments.

With -BundlePath alone (a bundle-only app), copy other enforcement settings, such as asset_policy:, into the base config too if they must apply before the bundle app runs.

Simulate your MDM

You can check a recipe without a tenant. Reproduce the context the MDM agent runs in, then check the exit code, standard output (one result document, or the detection line), standard error, and the result document against the schema.

MDM agents run scripts as root with a minimal environment, no terminal and nothing on standard input:

sudo env -i /bin/sh ./defenseclaw-enterprise.sh --action status < /dev/null > result.json 2> stderr.txt
echo "exit=$?"
sudo env -i /bin/sh ./detect.sh --format value < /dev/null

For a script-only MDM, run your edited copy of the wrapper the same way with no arguments.

Intune and most Windows MDMs run as SYSTEM, often from a 32-bit process. Reproduce that with a scheduled task that runs the 32-bit Windows PowerShell (SysWOW64), then again with the 64-bit one (System32). Run this from an elevated PowerShell; C:\DcSim holds your copy of the script:

$sim = 'C:\DcSim'
$engine = Join-Path $env:WINDIR 'SysWOW64\WindowsPowerShell\v1.0\powershell.exe'
$command = "/c `"`"$engine`" -NoProfile -NonInteractive -ExecutionPolicy Bypass -File $sim\detect.ps1 -MinimumVersion X.Y.Z 1>$sim\stdout.txt 2>$sim\stderr.txt`""
$action = New-ScheduledTaskAction -Execute (Join-Path $env:WINDIR 'System32\cmd.exe') -Argument $command
$principal = New-ScheduledTaskPrincipal -UserId 'SYSTEM' -LogonType ServiceAccount -RunLevel Highest
Register-ScheduledTask -TaskName 'DefenseClaw MDM simulation' -Action $action -Principal $principal -Force | Out-Null
Start-ScheduledTask -TaskName 'DefenseClaw MDM simulation'
Start-Sleep -Seconds 3
while ((Get-ScheduledTask -TaskName 'DefenseClaw MDM simulation').State -eq 'Running') { Start-Sleep -Seconds 2 }
"exit=$((Get-ScheduledTaskInfo -TaskName 'DefenseClaw MDM simulation').LastTaskResult)"
Get-Content "$sim\stdout.txt", "$sim\stderr.txt"
Unregister-ScheduledTask -TaskName 'DefenseClaw MDM simulation' -Confirm:$false

Also try the failure paths your MDM must handle:

  • a wrong pin;
  • a config that other users can write;
  • two runs at once (expect 1618 or 75 from one);
  • a run with no user signed in.