Edge Connector policies
Write Edge Connector policies with capability sequences, destination rules, and canary thresholds.
Preview. Edge Connector policies are YAML files compiled into binary DFA tables by the policy compiler. The compiled tables are either statically linked into the binary or distributed via OTA.
Policy structure
name: my-device-policy
version: 1
skill_actions:
critical:
runtime: disable # BLOCK
high:
runtime: disable # BLOCK
medium:
runtime: warn # ALLOW + log
iot_extensions:
capability_sequences:
- sequence: [net_fetch, exec_shell]
action: block
destination_allowlist:
- "1.1.1.1" # illustrative; replace with an approved public IP
canary:
baseline_blocks_per_min: 5Capability sequences
Define dangerous multi-step patterns. When a session completes a configured sequence, the final tool call is blocked.
iot_extensions:
capability_sequences:
- sequence: [net_fetch, exec_shell]
action: block
- sequence: [net_fetch, actuate]
action: block
- sequence: [sensor_read, net_fetch, exec_shell]
action: blockThe compiler turns these into DFA tables, evaluated in constant time per input symbol. Sequences are tracked per session_id.
| Rule | Limit |
|---|---|
| Capabilities per sequence | One to four known capabilities |
action | allow, block, warn or escalate |
| Unknown capabilities, actions, severity names, malformed values | Rejected before any output is written; exit code 65 |
| Unreadable input file | Short error; exit code 1 |
Destination rules
iot_extensions:
destination_allowlist:
- "1.1.1.1" # illustrative public IP; replace with one approved for your service
- "2606:4700:4700::1111" # illustrative public IPv6, written without brackets1.1.1.1 and the IPv6 address are examples. Replace them with addresses approved for your service.
How the device matches a destination:
- Hostname destinations are blocked on every build profile. Network tools need a nonempty destination, so list a public IPv4 or globally scoped IPv6 literal.
- Write an IPv6 entry without brackets (
2606:4700:4700::1111, not[2606:4700:4700::1111]); the compiler refuses a bracketed one. The device takes the host out of each destination, removes any brackets and compares it with the entries as text, ignoring case. Sohttps://[2606:4700:4700::1111]:443/matches the unbracketed entry. - Write the address in the form the tool sends. The parser does not prove the address is routable.
- Private, loopback and link-local addresses, numeric aliases (octal, hex or decimal forms) and malformed ports are blocked even if listed.
- A destination that is not on the allowlist is blocked.
What policy cannot change
These are fixed in the C build. The compiler rejects the matching YAML keys, so a policy cannot appear to turn on a control the device would ignore.
| Fixed behavior | Rejected keys |
|---|---|
| Rate limits: 60 tool calls, 30 network requests and 10 actuations per minute (Stage 2) | iot_extensions.rate_limits |
| Escalation mode per capability (Stage 7) | iot_extensions.escalation_mode |
| Content patterns for secrets, credentials, PII, exfiltration, injection text and dangerous commands | content_inspection and custom regex settings |
| The SSRF guard for private and metadata addresses | destination_denylist, ssrf_protection, hostname entries |
By default an undecided call stays blocked when the gateway is unreachable. DCLAW_STRICT_MODE=0 allows speculative execution on builds that support it, also when the MQTT publish fails; keep the default in production.
Compile the policy
python3 edge-connector/tools/policy_compiler.py \
--input ~/.defenseclaw/policy.yaml \
--profile standard \
--version 1 \
--output-header policy_tables.h \
--output-binary policy.bin| Output | Use |
|---|---|
C header (policy_tables.h) | Static linking into the binary. |
Binary blob (policy.bin) | An unsigned development stub when no signing key is given. Do not publish it to production devices. |
For production, push the policy with defenseclaw edge-connector policy push or the Fleet policy-push API, which compiles it and HMAC-signs the update with DCLAW_OTA_HMAC_KEY. The C receiver does not accept the compiler's optional Ed25519 --signing-key output.
Canary deployment
Each device that receives a new policy starts its own ten-minute canary window. The Fleet policy endpoint publishes to the whole tenant/fleet topic; it does not select a subset of devices.
iot_extensions:
canary:
baseline_blocks_per_min: 5The device restores its previous policy if its block count exceeds five times the per-minute baseline for three consecutive minutes in that window. The device decides this; the gateway does not start a rollback.
After a rollback:
- Signed heartbeats carry a persistent
CANARY_ROLLBACKflag until a newer signed policy installs. - The reported
policy_versionstays at the highest accepted version (the anti-rollback watermark), not the version now active. - So check the flag and the device's active policy before you read the Fleet version count as policy adoption.
Edge Connector architecture
Learn how the Edge Connector evaluates calls: local checks, verdict caching, Fleet escalation over MQTT, HMAC-chained audit trail and OTA policy updates.
Fleet API Reference
REST API reference for DefenseClaw IoT fleet device registration, policy and emergency distribution, threat intelligence, and observability.