Repository navigation
In review
Copy link
Labels
assistant-briefedQuestion prepared and handed to the maintainerenhancementNew feature or requestfollow-up-pendingMerged work left follow-ups; the follow-ups workflow turns them into backlog issuessecurity
Milestone
Description
Goal
More commands that destroy data or disks get the red risk rating, and more files that typically hold credentials count as secret paths. Both lists are documented as starting points without a claim to completeness (THREAT-MODEL.md §6); this issue extends them with common families that are missing today.
Context
- Red server-risk patterns:
server_risk_patterns()incrates/core/src/risk/patterns.rs:295-390. Present:sftp-serverinvocation,rm -rf/-fr,dd if=… of=/dev/…,mkfs*, fork bombs,shutdown/reboot/poweroff/halt,iptables -F,chmod -R 777 /…. - Missing destructive families:
shred,wipefs,truncate(to a size),find … -delete, SQLDROP DATABASE/DROP TABLE/TRUNCATE TABLE,blkdiscard,sgdisk --zap/--zap-all/-Z,mke2fs,mkswap,lvremove/vgremove/pvremove,zpool destroy,zfs destroy.ddis only rated red whenif=comes beforeof=;dd of=/dev/sda if=…is not. - Patterns are checked against every lowercased variant of the command (each segment, the whole command, wrapper/sudo-resolved forms,
-ccode recursively;crates/core/src/risk/classifier.rs:103-178,best_matchat:223-232). Globs without a leading*are start-anchored. - Secret paths:
secret_path_patterns()inpatterns.rs:168-252. A match with a read command (SECRET_READ_COMMANDS,patterns.rs:85) always asks for confirmation (crates/app-logic/src/orchestration/action_exec/risk.rs:105-107); a subset also rates the data axis red (patterns.rs:442-556). - Missing secret paths:
*.tfstate(and*.tfstate.backup),*.kdbx,.s3cfg,~/.azure/token caches, gcloudapplication_default_credentials.jsonandlegacy_credentials/(the existing\bcredentials\bdoes not match after_),~/.terraform.d/credentials.tfrc.json. - Specs: 0026 (risk indicators), 0068 part 2 (secret paths), 0092 (red risk requires confirmation).
Requirements
- Add red server-risk patterns for:
shred,wipefs,truncatewith-s/--size,findwith-delete,blkdiscard,sgdiskwith--zap,--zap-allor-Z,mke2fs,mkswap,lvremove,vgremove,pvremove,zpool destroy,zfs destroy, andddwithof=/dev/…regardless of argument order. - Add a red pattern for the SQL statements
drop database,drop schema,drop tableandtruncate tableanywhere in the command (coversmysql -e "…",psql -c "…", here-strings), case-insensitive through the existing lowercasing. - Each new pattern has a reason text in the style of the existing entries.
- Add secret paths:
.tfstate(including.tfstate.backup),.kdbx,.s3cfg,.azure/,application_default_credentials.json,legacy_credentials/,credentials.tfrc.json. These escalate like the existing secret paths;.tfstate,.kdbx,.s3cfg,application_default_credentials.jsonand.azure/also rate the data axis red. - No existing pattern is removed or narrowed; nothing that is red today becomes yellow or green.
- No change to the filter engine (
crates/core/src/filter/), the hard blacklist or rule matching. - Specs 0026 and 0068 list the added families.
Acceptance Criteria
- Each new destructive family is rated red, also behind
sudo, insidebash -c "…"and as a later segment of a chain (tests in a newcrates/core/src/risk/tests_destructive_families.rs) -
dd of=/dev/sdb if=/tmp/imgis red -
mysql -e "DROP DATABASE shop"andpsql -c "truncate table orders"are red - Near misses stay as they are:
truncate --help,find . -name '*.log'(no-delete),zfs list,grep -i "drop table" migrations.sqlkeep their current rating (pin today's level in the test) -
cat terraform.tfstate,cat db.kdbx,cat ~/.s3cfg,cat gcloud/application_default_credentials.json,cat ~/.azure/msal_token_cache.jsonescalate as a secret-path read; the data axis is red for the five listed files - An allow rule matching one of these commands still ends in a confirmation (red risk / secret path), tested through the action pipeline for one destructive and one secret-path example
- Existing risk tests and property tests stay green
- Relevant automated tests pass
Technical Notes
- Security-critical module (risk classifier). Changes only add patterns; they can only make a rating stricter.
- Keep the mutation-test style of the existing tests: one positive and one near-miss case per family.
- User-visible as a security change (more confirmations): add a changelog fragment.
Files: crates/core/src/risk/patterns.rs, crates/core/src/risk/mod.rs, crates/core/src/risk/ (new tests_destructive_families.rs), crates/core/src/risk/tests.rs, crates/app-logic/src/orchestration/action_exec/tests_red_risk.rs, docs/specs/0026-command-risk-indicators.md, docs/specs/0068-security-hardening-prelaunch.md, changelog.d/
Spec impact: update 0026
Open questions
find … -delete: the pattern must also match when-deletefollows other predicates (find /x -mtime +7 -delete). Options: (a) globfind*-delete*, (b) a regex on thefindsegment. Recommendation: (b), anchored to afindcommand word sogrep -- -deleteis not matched.
Related Work
Metadata
Metadata
Assignees
Labels
assistant-briefedQuestion prepared and handed to the maintainerenhancementNew feature or requestfollow-up-pendingMerged work left follow-ups; the follow-ups workflow turns them into backlog issuessecurity
Type
Fields
Priority
P2 - Normal
Activity
feat(core): rate more destructive commands red and add secret paths (#…
smart-ssh-coder commentedon Dec 4, 2026
Implementation ready for review. PR #1732. Added red server-risk patterns for the listed destructive families (incl. dd of=/dev in any order and SQL drop/truncate with a SQL client word) and new secret paths with red data axis; tests in tests_destructive_families.rs and the action pipeline; specs 0026/0068 and changelog updated. CI green on PR #1732.
smart-ssh-reviewer commentedon Dec 4, 2026
Needs maintainer: Question: How should the red rating for destructive SQL statements (drop database/schema/table, truncate table) be scoped, given that the issue asks for 'anywhere in the command' but also requires
grep -i "drop table" migrations.sqlto keep its rating?Context: PR #1732 rates these statements red only when one of 14 SQL client words (mysql, mariadb, psql, sqlite3, sqlcmd, sqlplus, usql, mycli, pgcli, litecli, duckdb, cqlsh, clickhouse-client, snowsql) appears in the same command, in either order. As built, these drop data but stay unrated:
mysqlsh -e "drop database x",cockroach sql -e "drop database x",trino --execute 'drop table x',beeline -e 'drop table x',sqlite app.db 'drop table t'. Searches that happen to contain a client word turn red, e.g.grep -i 'drop table' mysql.log. Also not covered today:TRUNCATE orderswithoutTABLE,DROP/**/DATABASE,mysqladmin drop,dropdb. Independently of this question, the review asks the coder to fix sgdisk grouped flags (-Zo), quoteddd "of=/dev/…",truncate --siz=,lvm lvremove, and four code-shape points; those do not need a decision.Options:
truncate <table>without TABLE, SQL comments as separators,mysqladmin drop,dropdb). User effect: covers more real invocations than option 1, still misses clients nobody listed.Technical assessment:
grep x | psqlandecho "drop table t" | psqlstay red.smart-ssh-planner commentedon Dec 4, 2026
Maintainer brief: Product question: Should destructive SQL (drop database/schema/table, truncate table) be rated red for any command that contains it, or only when a known SQL client is present?
Now: PR #1732 rates it red only if one of 14 listed client words (mysql, psql, sqlite3, …) appears in the command. Not red today:
mysqlsh -e "drop database x",cockroach sql,trino --execute,beeline -e. A search likegrep -i 'drop table' mysql.logturns red. The issue says "anywhere in the command" but also requiresgrep -i "drop table" migrations.sqlto keep its rating.Options (numbering of the question kept):
echo,git commit -m "drop table"ask for confirmation); pipes likeecho "drop table t" | psqlstay red.truncate <table>, SQL comments,mysqladmin drop,dropdb) – effort: small to medium; risk: list needs upkeep, still misses unlisted clients.Recommendation: 2 – it implements the issue's "anywhere in the command" requirement and keeps the grep near miss. Product principle: safety before convenience, and the classifier only gets stricter. A few extra confirmations cost less than a missed one.
Not answered automatically because: it changes what the user sees (which commands force a confirmation) in the security-critical risk classifier.
smart-ssh-maintainer commentedon Dec 5, 2026
Decided by maintainer: option 2. Rate destructive SQL statements (drop database / drop schema / drop table, truncate table) red wherever they appear in the command, except when the first command word of the segment is a search or read tool (grep, rg, ag, less, more, cat, head, tail, sed -n, awk and similar). Commands that only mention such a statement (for example
echointo a file orgit commit -m "drop table …") asking for confirmation is accepted. Pipes into a client such asecho "drop table t" | psqlstay red. The other review points (sgdisk grouped flags, quoteddd "of=/dev/…",truncate --siz=,lvm lvremove, code-shape points) are fixed in the same round.smart-ssh-reviewer commentedon Dec 5, 2026
Review: Head dac5cae predates the maintainer's decision; nothing from it or from the previous review is implemented yet. 1. Implement option 2 for SQL (patterns.rs:334-341, :509-519): match drop database/schema/table and truncate table anywhere in the command; skip only a segment whose first command word (after sudo/wrapper resolution) is a search or read tool (grep, rg, ag, less, more, cat, head, tail, sed -n, awk, ...). The skip works per segment, and the whole-command match must not undo it. Rewrite the SQL comments. Tests: mysqlsh / git commit -m "drop table x" / echo "drop table t" | psql / grep x f | psql -c "drop table t" are Red; grep/rg/cat/... with the statement keep their level. 2. Spec 0026:81-83: describe the decided rule instead of the client-word rule. 3. Add an ADR: the SQL rule, the list of read tools, the accepted false positives and the find -delete regex choice (next free number 0166, check open PRs). 4. sgdisk -Zo / -oZ must be red (patterns.rs:473). 5. dd "of=/dev/sda" and dd 'of=/dev/sda' must be red (patterns.rs:506). 6. truncate --siz=0, --si 0 and -s-1G must be red (patterns.rs:456). 7. lvm lvremove / vgremove / pvremove must be red (~:489). Add a test for each of 4-7. 8. Move the credentials.tfrc.json secret-path entry above the generic \bcredentials\b entry; it never takes effect where it is now. 9. Drop the three redundant SECRET_PATH_HINTS entries. 10. Use #[expect(clippy::too_many_lines, reason = ...)] instead of #[allow] (patterns.rs:565). 11. Fix the 'each regex is anchored' comment at patterns.rs:439. 12. Update the PR description (Summary/Assumptions) to the decided SQL rule. CI is green.
fix(core): rate destructive SQL anywhere except read tools, close rev…
refactor(core): split data risk pattern table instead of a lint excep…
style(core): shorten comment to stay under the file size limit (#1725)
smart-ssh-coder commentedon Dec 5, 2026
Implementation ready for review. PR #1732. Implemented the decided SQL rule (match anywhere, per-segment exemption for search/read tools), fixed sgdisk/dd/truncate/lvm gaps, secret-path ordering, hints, lint exception, spec 0026 and ADR 0167. Core tests pass and CI is green.
smart-ssh-reviewer commentedon Dec 5, 2026
Review: Review of 964776b: the maintainer's option 2, spec 0026, ADR 0167 and most of the last review's points are done. Three gaps remain. 1. The read-tool exemption also covers a read tool that pipes the statement into a client:
cat <<< "drop table users" | psqlandawk 'BEGIN{print "drop table t"}' | psqlare rated None. This contradicts the decision that pipes into a client stay red, and the issue's requirement that here-strings are covered (both were red at dac5cae). Fix: exempt a read-tool segment only when its output does not go into a non-read-tool segment; add both commands as Red tests and say so in ADR 0167 and spec 0026. 2. dd:dd of="/dev/sda" if=xanddd if=x of='/dev/sda'are still None (patterns.rs:518). Use["']?of=["']?/dev/and add tests. 3. truncate:truncate --s=0 fandtruncate --s 0 fare None (patterns.rs:467). GNU truncate accepts--s. Use--s(?:i(?:ze?)?)?and add tests. CI is green.fix(core): rate piped read tools, quoted dd of=, truncate --s as dest…
style(core): satisfy clippy in destructive_sql (#1725)
test(core): compare only filter decisions for find -delete, risk is r…
refactor(core): move destructive SQL check into its own module (#1725)
smart-ssh-coder commentedon Dec 5, 2026
Implementation ready for review. PR #1732. Fixed the three review gaps (piped read tools, quoted dd of=, truncate --s) with tests, spec 0026 and ADR 0167 updated; merged develop, CI green.