Repository navigation
fix(security): deny mutating tailscale subcommands (replaces #8262) - #21149
iamwhatever wants to merge 2 commits into
Conversation
Sensitive Change ReviewSensitive files changed:
|
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that the operator-facing deny guidance for these rows points the agent at [DESIGN-REVIEWED] e85340b Description read[DESCRIPTION-READ] ed12aea40dd7438a536abedcf757adc7cf29239ee3d23168eff383c7696046f2 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The Not justified as shipped
What this change shipsInventory (8 items) — 6 justifiedIntent: stop the agent's bash from exposing this host through the raw
[FIRST-PRINCIPLES-REVIEWED] e85340b Description read[DESCRIPTION-READ] 09d95f8f97d148cf044202696b708878a328f32b956f4073c181a829ffe946bf That sha256 names the PR description this verdict read. Recompute it with |
GPT 6.1 Review — 🔴 changes requested (blocking)GPT 6.1 found at least one blocking issue that must be resolved before merging This comment is updated in place on each push. BLOCKING -- src/kiro_crew/security/exposure_floor.py:159 -- Brace-expanded global flags bypass exposure denial Adjudication (Opus 5.5) — is blocking on each finding proportionate?F1 (fenced): UPHOLD-FENCED. This is a governance-ceiling bypass. The construction is ordinary bash, not an extreme condition.
False positive or not applicable? A repository writer can comment: |
Opus 5.5 Review — 🔴 changes requested (blocking)Reviewed Brace expansion in the new tailscale floor is handled wrong, so BLOCKING — src/kiro_crew/security/exposure_floor.py:159 [BLOCK-MERGE] e85340b Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
Security Scope Review -- 🔴 BLOCK (blocking)Which legitimate operations does Verdict basis: a script-confirmed newly-refused operation. Security scope review -- adjudicated candidates
Newly refused (confirmed by the real classifier at both refs)
Each row above is an operation that the base ref ALLOWS and this change REFUSES. Narrow the rule at the tier named. Withdrawing a row is not the way to green: that is its own pull request, on its own merits. Scope-Verdict: CONCERNS TIGHTENING: A new argv-structural floor, ADJUDICATED: 37 candidates, 0 confirmed newly-refused (no harness verdicts reached this review, so no row is confirmed) PLATFORM COVERAGE:
UNADJUDICATED: Nothing outside the shell deny composite is touched. Two things still lack a verdict.
[SCOPE-REVIEWED] e85340b The confirmed rows, in the committed corpus's own shape{
"golden_paths": [
{
"kind": "shell",
"command_or_flow": "cat > /tmp/commit-message.txt <<'EOF'\nfeat(security): refuse raw tailscale serve and funnel from bash\nEOF",
"platform": "posix",
"reason": "The maintainers' own commit flow (golden row `git commit -F /tmp/commit-message.txt`) for this very feature; a quoted heredoc to a file is data."
}
]
} |
8548306 to
055ac3b
Compare
055ac3b to
f0e04f2
Compare
Sensitive change review
|
38c82ec to
430afae
Compare
Sensitive change review
|
430afae to
f0bb5b4
Compare
Sensitive change review
|
f0bb5b4 to
c9b284f
Compare
Sensitive change review
|
1 similar comment
Sensitive change review
|
… exposure Putting the dashboard on the tailnet is an owner-only, SEL-audited action honouring capabilities.tailnet_origin. Nothing stopped the agent's own bash from reaching the CLI underneath that seam, so six rows deny the raw paths: serve and funnel mutations, the node-state verbs (up, down, set, login, logout, switch, cert, web), drive mutations, file cp, and exit-node connect/disconnect. Read carve-outs keep status, serve status, funnel status, drive list, exit-node list/suggest, file get, netcheck, ping and whois allowed, each \b-anchored so a subcommand merely starting with a read's name is still a mutation. Three things the first pass got wrong, all found by measuring rather than reading. The rows knew only the bare program name, so `tailscale.exe funnel 3000` was ALLOWED while `tailscale funnel 3000` was denied -- all six defeated on Windows by four characters, with the Denied Commands panel still reading "blocked". That is the worse-than-no-rule outcome this family's own scope note warns about. The infinite-spellings argument that justified leaving it covers spellings an attacker COMPOSES; it does not cover the program's own name on another platform, which is finite and which the catalog already enumerates in sandbox-escape-ssh-self. The flag-run sits before the verb, so a post-verb read was not reachable by the existing carve-outs: `tailscale serve --help`, `tailscale set --help` and `tailscale switch --list` were all refused. The last is this family's own way of asking which tailnet a node is on. And the flag-run nests \S+ inside a starred group, so a long run of flags that never reaches a verb backtracks exponentially: 16.7ms at 24 flags, 123ms at 28, 34.9 SECONDS at 40, on a pattern the PreToolUse gate evaluates for every command against input the agent chooses. Quantifying it possessively takes the worst case to 0.01ms. The primitive is shared with 97 other rows which are left alone, so that cost is still present catalog-wide; it is a separate question from this family. The `.*` prefix is kept. Anchoring the rows at a segment start closes the two remaining false refusals (a grep whose ARGUMENT reads as the subcommand), but it also drops `sudo tailscale serve ...` and `/usr/bin/tailscale funnel ...`, both of which the suite pins as denied. Trading real coverage for two false refusals is a maintainer's call and is not made here. The scope note states the boundary rather than implying containment: the tier needs the name adjacent to the verb, so a parameter expansion or a command substitution defeats it, as it defeats every rule in the catalog. Each row's description carries that caveat, because it is the string the Denied Commands UI renders. The six rows carry no quantifier of their own. `_linearize_deny_pattern` rewrites the flag run into its linear-time equivalent before `_DenyMatcher` compiles it, and that rewrite is what executes: measured on the linearized forms, a 40-flag non-matching input costs 0.22 ms against the pattern and 1.9 ms through the full `is_denied` path. A possessive quantifier on top of that is redundant, and it made these six rows the only flag-run rows in the file shaped differently from every other one. (cherry picked from commit aec20bf)
The six network-exposure rows matched command text. Matched anywhere, they refused commands that only NAME a subcommand (grep, git log --grep, commit messages, PR titles); a text pattern also cannot see shell grammar around a real invocation (if true; then tailscale funnel 3000; fi, a variable in program position). exposure_floor._tailscale_exposure_rule mirrors the self-protection subcommand floor on the unchanged shared payload walk: every token whose basename is tailscale is a candidate unless it is an argument of a data consumer, and its leading operands are read against a verb table with exact read carve-outs. It is position-blind and fails closed, like the floors already on main, so glued separators, leading redirects, reserved words and heredocs fed to a shell cannot move the program out of view; it inherits their over-refusals (git grep, docker compose, heredoc and single-quoted backtick bodies read as commands), which are shared-walk gaps. It is handed the raw command so assignments resolve case-sensitively (ts and TS differ), scans past a disabled row, cuts a redirect glued to the verb, and brace-expands the first two operands with a depth cap, failing closed when an expansion cannot be computed. A read is the word right after the verb; there is no --help carve-out. The family is narrowed to what WIDENS exposure: the exit-node row and the down verb are dropped (they narrow exposure or move egress). Like git-publish, is_denied records which rows are enabled and removes their patterns from the regex tier: the floor is the only enforcement, gated per row. The spec paragraphs and the package line budget follow. Replaces #8262
c9b284f to
e85340b
Compare
Sensitive change review
|
|
Closing this parked draft. The description says no further pushes are planned, and the AI review blocked the brace-expansion floor four times. The remaining shell-parsing gaps are tracked in #21345, so that issue is the place to pick this up again. The branch stays, so this can be reopened if the approach comes back. Thanks for the work here. |
Status: parked
This PR is parked as a draft at head
e85340b54by the owner's decision. No further pushes are planned.What it does. It adds
network-exposuredeny rows for thetailscalesubcommands that widen this machine's network exposure (serve,funnel, node-state verbs,drive,file cp). They are enforced by an argv floor (security/exposure_floor.py) that mirrors the self-protection subcommand floor on the unchanged shared shell walk.Why it is parked. GPT and Opus blocked the floor's brace-expansion code four times. Each fix round found a new way around it.
Open findings on
e85340b54:tailscale {file,cp} /etc/passwd peer:,tailscale {,--socket} /var/run/tailscale/tailscaled.sock serve --bg …andtailscale {--socket,/sock} funnel 3000are allowed.cat > /tmp/commit-message.txt <<'EOF'with a line namingtailscale serveis refused. This is the inherited quoted-heredoc class.file cpis egress rather than exposure, andlogoutnarrows exposure the way the droppeddownverb does. Both are scope questions for the Goal.Shared gaps. The shell-walk gaps that every argv floor inherits are tracked in #21345.
Replaces #8262
Carries over @GoZippy's #8262 with authorship kept (commit 1,
git cherry-pick -x), rebased onto current main, plus one commit that moves the family's enforcement from pattern text to an argv-structural floor. Thank you, @GoZippy.Problem / Motivation
Goal: The agent's own bash cannot widen this machine's network exposure by running the raw
tailscaleCLI.No
DeniedCommandRuleinBUILTIN_DENIED_RULESnamestailscale. Putting the dashboard on the tailnet is a governed action:tailnet_serve.publish()is owner-only, SEL-audited and honourscapabilities.tailnet_origin. That governance lives at the dashboard/CLI seam. The rawtailscaleCLI sits below it, and the agent has a bash tool. So from bash the agent can runtailscale serveto publish the dashboard,tailscale funnelto expose a local service to the public internet, ortailscale up/setto enable an SSH server or advertise this node as an exit or subnet router, all bypassingpublish()and its pin.Why it matters
"The agent can never widen its own network exposure" is the invariant the governed publish path exists to uphold, and today one bash call defeats it.
tailscale funnelis the sharpest case: a local service becomes reachable from the open internet with no gate in the path. On Windows there is no OS sandbox under the bash tool to catch it either.Not a goal
r=rm; $r -rf /behaves as it does on main.tailscale downandtailscale exit-node: they narrow exposure or move egress, so they are outside the Goal (possible follow-up).What changed (motivation → approach → change)
Root cause. Governance for tailnet exposure is enforced at
publish(), not at the command layer, and the denied-command gate (the one place that does sit on the agent's bash) had no rule fortailscale.Commit 1 (@GoZippy): the rows. A
network-exposurecategory of catalog rows:serve,funnel, node-state (up/set/login/logout/switch/cert/web),drive,file cp. Commit 2 drops GoZippy'sexit-noderow and thedownverb so the rows match the Goal exactly: they narrow exposure or move egress rather than widen it (a possible follow-up, judged on its own). Reads stay allowed,configure kubeconfigis outside the family, and Kiro Crew's own publish path (tailnet_serve._run,subprocess.run) never passes through the gate.Why not a text pattern. As text, the rows either refuse commands that only NAME a subcommand (the Security Scope Review confirmed
grep -rn "tailscale serve" docs/,git log --grep="tailscale funnel", commit messages, PR titles,pytest -k "tailscale serve",echo "Run: sudo tailscale set …"), or, anchored, miss shell grammar the anchor does not model (if true; then tailscale funnel 3000; fi). That is the same loop that closed the regexddrule in #17894.Commit 2: an argv floor.
security/exposure_floor.py::_tailscale_exposure_ruleis a thin mirror of the self-protection subcommand floor (argv_floor._matches_self_subcommand) on the UNCHANGED shared walk (shell_normalizer._shell_payload_walk, no hooks;shell_normalizer.pyis identical to main):$( ), backtick, process substitution,sh -candevalpayload, tokenized with quoting resolved and same-line literal assignments substituted.tailscale/tailscale.exe(any case, either path separator, or a glob that could expand to it) is a candidate unless_data_consumer_exemptsays it is an argument of a data consumer (echo,grep,rg,cat, …)._operands_lead_with) with exact read carve-outs, each the word right AFTER the verb (serve status,serve get-config,funnel status,drive list,switch --list). There is no--helpcarve-out: a mutating verb with a help flag is refused, as the self-protection floor refuseskirocrew restart --help.--sockettakes a value, and a redirect glued to the verb (up>/tmp/log) is cut off. The first two operands are brace-expanded with a depth cap ({funnel,},file {cp,}). A word the expansion leaves unchanged ('{status}') is a literal, and an expansion that cannot be computed fails closed.ts=tailscale; TS=echo; "$ts" funnel 3000is refused.is_deniedremoves the five patterns from the regex tier, so the floor is the only enforcement, gated per row.git grep -e git -e push origin main,git grep -n kirocrew restartare refused on main):git grep -e tailscale -e up,docker compose up -d tailscale web, a wrapper beforegrep, and a heredoc body or single-quoted backtick naming a subcommand. They are shared-walk gaps, tracked in shell-normalizer shared gaps #21345 and pinned with their sibling bytest_the_floor_inherits_the_shared_walks_over_refusals.Review history
8548306c5.*tailscale)055ac3b0dsudo a/a/…;if …; then tailscalebypass; lowercase resolver mergedts/TS; backtick/heredoc refusals430afae7atimeout 30 bash <<EOF; F3'{status}'recursion; F4git grep -e tailscale -e uprefused; mypyf0bb5b491echo ready;tailscale funnel,2>&1 tailscale funnel,((1<<shift))then funnel,"$s" <<EOF,$(echo tailscale funnel …); plus Opus'stailscale up>/tmp/logandcat <<EOF | bash_matches_self_subcommandon the unchanged shared walk. All seven are must-refuse tests. The glued-verb redirect is cut in the floor's own operand readerf0bb5b491echo "Run \tailscale serve status`"` refusedf0bb5b491.result(timeout=10)tripped the wait-discipline ratchetf0bb5b491c9b284f29tailscale funnel --bg 3000&&echo --help(help carve-out read across a glued&&);tailscale file {cp,}; brace overflow read as a literal--helpcarve-out removed, a read is only the word right after the verb; first two operands brace-expanded; an expansion that cannot be computed denies. Tests for eachc9b284f29tailscale serve get-config --allrefusedget-configis a serve readc9b284f29docker compose/kubectl/gharguments)c9b284f29exit-nodeanddownoutside the Goalexit-noderow anddownverb droppedRebase onto main. Conflicts resolved in the
deny_guidance.pycategory list, the rule-count pin (113 -> 119) and the golden fixture (main's order kept, six rows appended). The spec paragraphs now describe the floor._PACKAGE_LINE_BUDGETis raised to the measured package total (29,866).Backwards compatibility
Compatible: the six rows only add refusals, and each is an ordinary user-disableable catalog row.
shell_normalizer.pyis unchanged, so no other floor's input changes.Removes nothing: the change adds deny rows and a floor for those rows only; no path, record, key or public function is removed or renamed.
Tests
test_tailscale_network_exposure_family,test_the_windows_spelling_is_covered,test_reading_the_help_is_not_a_mutation: the deny/allow matrix for all six rows (GoZippy's, unchanged).test_tailscale_is_judged_as_the_program_through_shell_grammar: every refused spelling, including the seven bypass shapes from the last two GPT/Opus rounds,if true; then …; fi, both orders ofts/TS,$(echo tailscale) funnel,{tailscale,} funnel,tailscale {funnel,},bash <<EOFandtimeout 30 bash <<'EOF'.test_tailscale_named_as_data_is_not_refused: the Security Scope false positives from the first head (grep/rg/git log/commit/PR title/pytest -k/echo, a multi-line quoted--body).test_the_floor_inherits_the_shared_walks_over_refusals: each inherited over-refusal next to the sibling main's own floors already refuse.test_tailscale_rows_never_reach_the_regex_tier: the six patterns never run; each row toggles only its own verbs; a disabledservedoes not hidefunnel.test_a_literal_brace_operand_is_answered_not_recursed:tailscale '{status}'returns and is allowed;file {cp,}and a 257-comma overflow are refused (30 s bound).test_a_help_flag_does_not_excuse_a_mutating_verb:serve --help,funnel --bg 3000&&echo --helpandswitch other&&echo --listare refused;switch --listand bare--helpare allowed.test_a_long_flag_run_is_read_as_flags.TMPDIR=/tmp/r8262 PYTHONPATH=src pytest -n 8over every test file that touchesis_deniedor the catalog, plus the line-budget and wait-discipline ratchets -> 13021 passed. The 5 failures intest/test_terminal_handler.pyfail the same way on clean main (host shells). flake8, isort and mypy are clean.check_comment_history.pyandcheck_file_line_cap.pypass (0 failures).Manual verification
N/A — unit coverage sufficient: the change is a pure command-text decision in
is_denied, exercised directly by the tests above.Related Issues
Replaces #8262. Shared shell-walk gaps this floor inherits: #21345.
Pattern harvest
Rule candidate: review-prompt
Pattern: a deny rule written as a text pattern over a shell command; judge the argv program instead (as git-publish, ssh-to-self and the self-protection floors do).
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributed under the project's Apache-2.0 license.