dcg

Permissions

system.permissions

Protects against dangerous permission changes like chmod 777, recursive chmod/chown on system directories

  • 11blocking rules
  • 4safe patterns
  • 3Critical
  • 8High
~/.config/dcg/config.toml
[packs]
enabled = ["system.permissions"]

Evaluated when a command contains chmod, chown, chgrp, setfacl, icacls, cacls, takeown.

Blocking rules

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

  1. chmod-recursive-root

    Critical

    chmod -R on system directories can break system permissions.

    Explanation
    Recursively changing permissions on system directories can render the system unbootable, break package management, and disrupt every running service. Many system files require specific permission bits to function correctly. Check current permissions first: ls -la /path/to/directory Apply changes to a specific subdirectory instead of the whole tree.
  2. icacls-recursive-system

    Critical

    icacls /t on a Windows system tree rewrites ACLs recursively and can break the system.

    Explanation
    `/t` applies the ACL change to every file and subdirectory. Across `C:\Windows`, `C:\Program Files` or the drive root that rewrites the access control the OS and every installed product depend on, and Windows does not keep an undo: the previous ACLs are gone once the walk starts. Service accounts lose the rights they were granted at install time, and SFC/DISM will not restore ACLs. Inspect first: icacls <path> Save the current ACLs before changing anything: icacls <path> /save acl.txt /t icacls <path> /restore acl.txt Apply the change to the specific subdirectory that needs it instead of the whole tree.
  3. setfacl-all

    Critical

    setfacl -R on system directories can modify access control across the filesystem.

    Explanation
    Recursively modifying ACLs on system directories changes fine-grained access control for every file in the tree. This can override traditional Unix permissions and grant or revoke access in unexpected ways, breaking services and security boundaries. Review current ACLs first: getfacl <path> Apply to a specific file instead of recursively: setfacl -m u:<user>:rwx <specific-file>
  4. chgrp-recursive-root

    High

    chgrp -R on system directories can break system group ownership.

    Explanation
    Recursive group changes on system directories can disrupt services that rely on group-readable or group-writable files, break package-managed ownership, and be difficult to undo. Start with a single path or a shallow find before applying broader changes. Check current ownership first: ls -la /path/to/directory
  5. chmod-777

    High

    chmod 777 makes files world-writable. This is a security risk.

    Explanation
    chmod 777 grants read/write/execute to everyone. This can expose sensitive files and allow unauthorized modification. Prefer least-privilege permissions that only grant the specific access needed.
  6. chmod-setgid

    High

    Setting setgid bit (chmod g+s) is a security-sensitive operation.

    Explanation
    The setgid bit on an executable causes it to run with the file group's privileges. On a directory, new files inherit the directory's group. Misapplication can grant unintended group access to sensitive resources. Check current group ownership: ls -la <file> Find existing setgid files: find / -perm -2000 -type f 2>/dev/null
  7. chmod-setuid

    High

    Setting setuid bit (chmod u+s) is a security-sensitive operation.

    Explanation
    The setuid bit causes a program to run with the file owner's privileges regardless of who executes it. If set on the wrong binary, any user can gain elevated access. This is a common privilege escalation vector. Verify the file and owner first: ls -la <file> Find existing setuid files: find / -perm -4000 -type f 2>/dev/null
  8. chown-recursive-root

    High

    chown -R on system directories can break system ownership.

    Explanation
    Recursive ownership changes on system directories can disrupt services, break package-managed files, and be difficult to undo. Start with a single path or a shallow find before applying broader changes.
  9. chown-to-root

    High

    Changing ownership to root should be done carefully.

    Explanation
    Transferring file ownership to root makes the files inaccessible to normal users and may break applications that need to write to those files. Services running as non-root users will lose access. Check the current owner first: ls -la <path> Consider using group ownership instead: chgrp <group> <path>
  10. icacls-grant-everyone

    High

    granting Everyone full/modify/write access makes the target world-writable.

    Explanation
    `Everyone` includes every authenticated and guest principal on the machine, so an `F` (full), `M` (modify) or `W` (write) grant lets any local account replace the contents -- and `F` additionally lets it rewrite the ACL, so the grant cannot be relied on to stay as set. This is the Windows spelling of `chmod 777`. Grant the specific principal the specific right it needs: icacls <path> /grant "DOMAIN\user":(RX) If a service needs write access, grant it to that service's account rather than to Everyone. Read-only sharing (`:R` / `:RX`) is unaffected by this rule.
  11. takeown-recursive-system

    High

    takeown /r on a Windows system tree seizes ownership recursively and is hard to undo.

    Explanation
    `takeown /r` makes the current user the owner of every file in the tree. On a system tree that displaces `TrustedInstaller`, which is what Windows Update and the servicing stack rely on to replace protected files, so updates and repair operations begin to fail. Restoring the original owner is manual and per-file. Check the current owner first: icacls <path> Take ownership of the single path that needs it rather than the tree, and record what it was so it can be handed back.

Safe patterns

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

  • stat
  • ls-perms
  • getfacl
  • namei