dcg

scp

remote.scp

Protects against destructive SCP operations like overwrites to system paths.

  • 10blocking rules
  • 5safe patterns
  • 5Critical
  • 5High
~/.config/dcg/config.toml
[packs]
enabled = ["remote.scp"]

Evaluated when a command contains scp, pscp.

Blocking rules

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

  1. scp-recursive-root

    Critical

    scp -r to root (/) is extremely dangerous.

    Explanation
    Recursive copy to the root filesystem can overwrite critical system files, potentially rendering the system unbootable. This affects all system directories including /etc, /bin, /lib, and /boot. Safer alternatives: - Specify a target subdirectory instead of / - Use rsync with --dry-run to preview changes - Copy to /tmp first and move files individually
  2. scp-to-bin

    Critical

    scp to /bin/ or /sbin/ can overwrite system binaries.

    Explanation
    The /bin and /sbin directories contain essential system binaries required for basic operation. Overwriting these can make the system unusable and require rescue mode recovery. Safer alternatives: - Install custom scripts to /usr/local/bin - Use package managers for system updates - Test binaries in user directories first
  3. scp-to-boot

    Critical

    scp to /boot/ can corrupt boot configuration.

    Explanation
    The /boot directory contains the kernel, initramfs, and bootloader configuration. Corrupting these files will prevent the system from booting, requiring rescue media to recover. Safer alternatives: - Use package manager for kernel updates - Keep backup kernels available - Test changes in a VM first
  4. scp-to-lib

    Critical

    scp to /lib/ can overwrite system libraries.

    Explanation
    The /lib and /lib64 directories contain shared libraries required by system binaries. Overwriting these can cause immediate system instability and prevent commands from running. Safer alternatives: - Use package managers for library updates - Install custom libraries to /usr/local/lib - Use LD_LIBRARY_PATH for testing
  5. scp-to-windows-system

    Critical

    scp/pscp targets a protected Windows system directory on the remote host.

    Explanation
    Copying into a remote drive root, Windows, Program Files, ProgramData, Boot, or EFI tree can overwrite operating-system files and make the destination host unusable. Stage the payload in a non-system directory and install it through a reviewed deployment mechanism.
  6. scp-destination-unverified

    High

    scp/pscp has a runtime-dependent or malformed destination that cannot be verified before execution.

    Explanation
    A shell variable, expression, malformed URI, or otherwise unverified final operand can resolve to a protected local path or an arbitrary remote host. Use a literal destination so dcg can determine direction and target before the transfer runs.
  7. scp-relative-traversal

    High

    scp/pscp uses parent-directory traversal in a remote relative destination.

    Explanation
    Remote relative paths and tilde paths are resolved by the remote account. A `..` component can escape the account's apparent home/staging directory and overwrite a protected system location. Resolve the remote absolute path first and use a traversal-free destination.
  8. scp-to-etc

    High

    scp to /etc/ can overwrite system configuration.

    Explanation
    The /etc directory contains critical system configuration files including passwd, shadow, fstab, and network settings. Overwriting these can lock you out of the system or cause services to fail. Safer alternatives: - Copy to a staging directory first - Back up existing files before overwriting - Use configuration management tools (Ansible, etc.)
  9. scp-to-usr

    High

    scp to /usr/ can overwrite system binaries.

    Explanation
    The /usr directory contains system binaries, libraries, and shared resources. Overwriting files here can break system utilities and installed applications. Safer alternatives: - Use /usr/local for custom installations - Use package managers for system updates - Install to user directories when possible
  10. scp-to-var

    High

    scp to /var/ can overwrite system data.

    Explanation
    The /var directory contains variable data including logs, databases, mail spools, and application state. Overwriting this data can cause data loss and service disruptions. Safer alternatives: - Use /var/tmp for temporary staging - Stop affected services before modifying their data - Back up existing data first

Safe patterns

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

  • scp-help
  • scp-download
  • scp-to-home
  • scp-to-tmp
  • scp-to-var-tmp