Skip to content

Policy: hold logins, setuid bits, cron spool writes and startup-file reverse shells (#750; carries #752) - #788

Merged
LoopGlitch26 merged 4 commits into
mainfrom
agent/carry-pr752
Nov 13, 2026
Merged

LoopGlitch26 merged 4 commits into
mainfrom
agent/carry-pr752

Conversation

@LoopGlitch26

Copy link
Copy Markdown
Member

This carries #752 by @jay23606. Their two commits are here as they wrote them, with author and sign-off kept. My commits on top finish the review of #752 (#752 (review)). A push to their branch was blocked, so this is a separate PR from main.

The bug

On main, the coding pack lets a shell command create a login, set the setuid or setgid bit, write the cron spool, or append a network shell (/dev/tcp/, nc -e, ncat -e, socat) to a shell startup file. Each of these keeps access to a machine after the agent's session ends, and each was allowed or only flagged.

The change

The coding pack's ask section now holds these commands so a person can decide. The rules cover account creation and group changes (useradd, adduser, usermod, dscl), writes to /etc/passwd, /etc/shadow and sudoers, setuid and setgid modes, cron spool writes, and network shells appended to startup files. Ordinary startup-file edits, crontab -l, chmod 755 and id stay allowed.

How it was tested

  • PYTHONPATH=.:tests .venv/bin/python -m unittest test_signer_policy.CodingPack.test_a_login_setuid_cron_or_network_shell_is_held_and_its_lookalikes_are_not: passes on the fix. On the base coding pack it fails with AssertionError: 'allow' != 'ask'.
  • PYTHONPATH=.:tests .venv/bin/python -m unittest test_signer_policy: OK.

Regression test: fails on base three times (/AssertionError: 'allow' != 'ask'/), passes on fix three times (PYTHONPATH=.:tests .venv/bin/python -m unittest test_signer_policy.CodingPack.test_a_login_setuid_cron_or_network_shell_is_held_and_its_lookalikes_are_not)

What the carry adds (the review's remaining items)

Their second commit (8b968ac) bounded TK-A069's options and read tee's words in TK-A070. TK-A070 still scanned to the end of the line from every /dev/tcp/: 2,086 ms on the speed test's fillers on the fallback engine. These patterns replace both.

  • Removed the committed bash.exe.stackdump.
  • Speed (item 4): TK-A070 now reads the shell and the write within 128 characters of each other instead of to the end of the line, and its path scan stops at >. TK-A069 reads up to eight options before the mode. On the fallback engine an unbounded option list, and a greedy run before a character class, backtracked quadratically. TK-A067's -[a-zA-Z]*[Gg][a-zA-Z]* took about 7 s on usermod -gggg…. Its letters before G can't be G now, and its words are bounded to 16. Each of these limits has a lean: comment.
  • Item 5: TK-A070 uses field: line, so tee ${X}-a is read as tee -a.
  • Item 6, TK-A069: 7755, 5755, 3755, 04755, =4755, u+sx, +sx, g+s,u+x, u=rwxs and u-x+s are held. u-s, 1777 and 0755 aren't.
  • Item 7, TK-A070: nc host port -e, nc -nv host port -e, nc -c, ncat --exec and --sh-exec, netcat, /dev/udp/, and TK-F011's startup files.
  • Item 8: TK-A067 holds gpasswd -a/-M/-A into sudo, wheel or admin, usermod -u 0 (with or without -o), -g and --gid, and -Gsudo. TK-A068 holds writes to /etc/group and /etc/gshadow.
  • Item 9, TK-A011: /etc/cron* (cron.daily, cron.hourly, …), and a copy into /var/spool/cron/crontabs/<user>.
  • Tests: test_other_spellings_of_a_login_setuid_cron_or_network_shell_are_held runs on every pack and both engines. It fails on 89ddb52. I added 17 deny rows and 6 benign rows.
  • Items 2, 3 and 10: coding pack 2026.11-v2-87 (we settle the final number at merge). E17, E21 and E21's rewrites are recorded again and the docs quote them. The persistence count and the policy lint result are below.

Results

  • E21, held out: the server pack stops 26 of the 33 persistence calls (21 on main): 14 denied, as on main, and 12 held for a person (7 on main). Privilege escalation: 19 of 27 stopped (8 on main). No benign call in the held-out pool, the blind pools or the 130 developer-session calls is newly held.
  • E17: all 873 harmful calls stopped, 1 false alarm in 906 benign (the draft email to a list address, as on main). strict.yaml also holds three of the new benign startup-file edits through TK-F011, as it holds every startup-file edit; no new rule holds them.
  • tracekit policy lint: ok for coding.yaml, dev.yaml, server.yaml and strict.yaml.
  • The coding pack is 2026.11-v2-87 for now; other open policy PRs also take numbers, so the final one is settled at merge.
  • E17, E21 and E21's rewrites were recorded again on Linux, and README.md, docs/evaluation.md and docs/limits.md quote the new numbers (this changes the E17 and E21 numbers in README.md).

How the carry was tested

I ran everything in a sealed Linux container (python 3.11, no network):

  • the new test test_other_spellings_of_a_login_setuid_cron_or_network_shell_are_held, run on every pack and both engines: it fails on 89ddb52 and passes here;
  • tests/test_policy2.py::Speed::test_every_pack_pattern_searches_64_kib_within_budget and TimedAndBraced::test_a_word_of_only_expansions_is_also_read_as_gone: both fail on 89ddb52 and pass here;
  • tests/test_eval_docs.py, tests/test_e21_policy.py, tests/test_e21_robustness.py, test_signer_policy.py::ServerCorpora and pyflakes: pass.

The tree is the same one tested there, and CI runs the full matrix.

Fixes #750. Carries #752.

jay23606 and others added 4 commits November 13, 2026 01:05
Signed-off-by: jay23606 <4602056+jay23606@users.noreply.github.com>
… an expansion

TK-A069's option run backed off quadratically under the regex fallback, over the speed budget on CI. TK-A070 now reads tee options of any shape (a glued ${X}-a too), so an unset variable in a tee option is read both ways.

Regenerated the E17 and E21 results and the docs that quote them.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Signed-off-by: jay23606 <4602056+jay23606@users.noreply.github.com>
…tern linear

- TK-A067: gpasswd -a/-M/-A into sudo, wheel or admin; usermod -u 0 (with or
  without -o); -g and --gid; a group option joined to its value (-Gsudo).
  The cluster read was `-[a-zA-Z]*[Gg][a-zA-Z]*`, which the fallback engine
  took seconds over on `usermod -gggg…`; now the letters before G can't be G.
- TK-A068: /etc/group and /etc/gshadow.
- TK-A069: modes starting with 3, 5 or 7, leading zeros (04755), + or =
  before a number, an s among other letters (u+sx, +sx), in any clause
  (g+s,u+x) and after = (u=rwxs). u-s and 1777 stay unheld. Up to eight
  options before the mode: the unbounded option list was quadratic on the
  fallback engine (315-509 ms on `chmod -a -a …`).
- TK-A070: read with field: line, so `tee ${X}-a` is read as `tee -a`;
  nc/ncat/netcat with -e, -c, --exec or --sh-exec after up to four words,
  /dev/udp/, and TK-F011's startup files. The shell and the write are read
  within 128 characters of each other: the lazy scan to the end of the line
  rescanned it from every /dev/tcp/ (965-1660 ms on 64 KiB).
- TK-A011: cron's /etc/cron* (cron.daily, cron.hourly, ...) and a copy two
  parts under /var/spool/cron (Debian's crontabs/<user>).
- Remove the committed bash.exe.stackdump.
- Coding pack 2026.11-v2-87 (settled at merge).

Signed-off-by: LoopGlitch26 <53336715+LoopGlitch26@users.noreply.github.com>
Recorded on Linux (python 3.11) in a sealed container. The docs quote the new
numbers: E17 873 harmful and 906 benign calls (1 benign held), E21 held out
272 of 420 caught by the server pack (persistence 26 of 33, was 21), and
strict now holds 3 of E17's new startup-file edits through TK-F011, as it
holds every startup-file edit.

Signed-off-by: LoopGlitch26 <53336715+LoopGlitch26@users.noreply.github.com>
@LoopGlitch26

Copy link
Copy Markdown
Member Author

This lands in #799 (a merge train of the policy PRs), which renumbers rule ids and re-records the evals once; your commits stay as they are and this PR will show as merged.

@LoopGlitch26
LoopGlitch26 merged commit 3fc5e78 into main Nov 13, 2026
34 checks passed
@LoopGlitch26
LoopGlitch26 deleted the agent/carry-pr752 branch November 13, 2026 08:49
tylrcc pushed a commit to tylrcc/Tracekit that referenced this pull request Nov 13, 2026
Rule ids: Cygnux-Labs#780's TK-A063 to TK-A066 become TK-A071 to TK-A074, and Cygnux-Labs#788's
TK-A067 to TK-A070 become TK-A075 to TK-A078 (Cygnux-Labs#778 keeps TK-A063 to
TK-A065 and Cygnux-Labs#787 TK-A067 and TK-A068; TK-A066, TK-A069 and TK-A070 stay
unused, so no id names two rules across the members), in the coding
pack, its tests and docs.

Packs: coding 2026.11-v2-82, strict 2026.11-strict-11 and dev
2026.11-dev-5, one step above main's each. dev maps Claude Code's
Workflow to `harness` (TK-A062 held it as an unmapped tool given a
script), with a benign test.

Harness lists: gptme, OpenHands, Copilot CLI, CodeBuddy Code and Cline
in AGENTS.md, README (badge 39, the --agent list, "another of the 17"),
docs/coding-agents.md's init lines, docs/doctor.md, docs/integrations.md
and docs/support.md; gptme's paths in TK-F009's comment.

Docs: a limits row for Cygnux-Labs#788's known gaps; two bare | in Cygnux-Labs#781's limits
row escaped. The plugin's SKILL.md is tracekit-skills 4bda57a.

Evals re-recorded once: E17 (901 harmful stopped, 1 false alarm in 944),
E21 policy robustness (held-out 279 / 420 default, 305 / 420 strict;
latency rows kept as main's) and E21 robustness (901 originals and
2,701 rewrites contained).

Signed-off-by: LoopGlitch26 <53336715+LoopGlitch26@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Policy: adding a login, a setuid shell or a reverse shell that runs at startup waits for a person

2 participants