The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
fix(rules): flag every octal chmod mode that makes a file world-writable (#1021)
Rudy Mizrahi Celekli6a1dd081b5b4
diff --git a/rules/risky-command/world-writable-chmod.rule.yaml b/rules/risky-command/world-writable-chmod.rule.yamlindex 10ce4144..7fc223ca 100644--- a/rules/risky-command/world-writable-chmod.rule.yaml+++ b/rules/risky-command/world-writable-chmod.rule.yaml@@ -1,8 +1,9 @@id: world-writable-chmod-version: 3+version: 4title: chmod grants world-writable or full permissionsdescription: >- A command makes a file or tree world-writable — chmod 777 / 0777, or a symbolic mode+ A command makes a file or tree world-writable — an octal mode whose "other" digit+ grants write (777, 0777, 666, 0776, 1777), or a symbolic mode(via + or =) that grants write to other or all (e.g. o+w, a+rwx, a=rwx, o=rwx,ugo+rwx). Owner- or group-only grants (u+w, g=rw) are intentionally excluded becausethey are not world-writable. chmod is anchored to the acting command position so it@@ -16,7 +17,7 @@ taxonomy:match: >e.event.action == "command.executed" &&- e.command.command.matches("(?i)(^|[;&|]\\s*)chmod\\s+([^;&|]*\\s)?(0?777\\b|([ugoa]*[oa][ugoa]*)[+=][rwx]*w[rwx]*\\b)")+ e.command.command.matches("(?i)(^|[;&|]\\s*)chmod\\s+([^;&|]*\\s)?([0-7]?[0-7]{2}[2367](\\s|$)|([ugoa]*[oa][ugoa]*)[+=][rwx]*w[rwx]*\\b)")emit:reason: "chmod grants world-writable or fully permissive access"@@ -34,6 +35,18 @@ tests:- event: { action: command.executed }command: { command: "chmod 0777 evil.sh" }session: { id: s1 }+ - name: chmod_666_world_writable_file+ verdict: match+ events:+ - event: { action: command.executed }+ command: { command: "chmod 666 /etc/app/config" }+ session: { id: s1 }+ - name: chmod_0776_octal+ verdict: match+ events:+ - event: { action: command.executed }+ command: { command: "chmod -R 0776 /srv/app" }+ session: { id: s1 }- name: chmod_ugo_rwx_symbolicverdict: matchevents:@@ -64,12 +77,30 @@ tests:- event: { action: command.executed }command: { command: "cd /opt && chmod 777 ./run" }session: { id: s1 }+ - name: chmod_sticky_world_writable_dir+ verdict: match+ events:+ - event: { action: command.executed }+ command: { command: "chmod 1777 /srv/shared" }+ session: { id: s1 }- name: chmod_normal_modeverdict: no_matchevents:- event: { action: command.executed }command: { command: "chmod 644 README.md" }session: { id: s1 }+ - name: chmod_exec_on_numbered_script+ verdict: no_match+ events:+ - event: { action: command.executed }+ command: { command: "chmod +x 007.sh" }+ session: { id: s1 }+ - name: chmod_normal_mode_on_numbered_file+ verdict: no_match+ events:+ - event: { action: command.executed }+ command: { command: "chmod 644 002-setup.sh" }+ session: { id: s1 }- name: chmod_read_only_otherverdict: no_matchevents: