Skip to content

sandbox-escape-ssh-self misses an ssh-to-self call after ; or && inside a command substitution #36949

Closed

Description

@buluoray

Existing issues

  • I searched open issues and this is not already reported.

KiroCrew version

main at 967f4e0 (source checkout, not a release build)

Release channel

Not sure

How is it installed?

From source

Platform

Not platform-specific

What happened

The ssh-to-self guard (sandbox-escape-ssh-self) lets an ssh-to-this-host call through when it is the second command of a ; or && chain inside a command substitution. Bash runs every command in the body, so the ssh runs.

from kiro_crew.security.deny_gate import is_denied
is_denied("echo hi; ssh -p 22 localhost id")            # refused
is_denied("echo $(true | ssh -p 22 localhost id)")      # refused
is_denied("echo $(echo hi; ssh -p 22 localhost id)")    # allowed
is_denied("echo $(echo hi && ssh -p 22 localhost id)")  # allowed
is_denied("echo `echo hi; ssh -p 22 localhost id`")     # allowed

The -p 22 keeps the rule's catalog pattern from matching, so only the argv floor judges these lines. The payload walk does find the body frame, but its tokens come out as ['echo', 'hi;', 'ssh', ...]: the floor reads the frame as one command and never splits it at the ; or &&.

Steps to reproduce

  1. On main, call kiro_crew.security.deny_gate.is_denied with the lines above.
  2. The top-level chain and the piped body are refused with rule=sandbox-escape-ssh-self component=argv-floor.
  3. The ; and && bodies are allowed, although bash runs the same ssh.

Anything else

Expected: a substitution body is split into its commands the same way a top-level line is, so each command in it is judged.

Found while working on #36903; the gap is the same on main and on that PR's head.

Activity

  1. buluoray commented on Nov 14, 2026

    @buluoray
    ContributorAuthor

    A second shape with the same symptom, also allowed on main at c275f70, will be fixed in the same PR:

    is_denied("echo `ssh -p 22 localhost id`")             # refused
    is_denied("echo $(date) $(ssh -p 22 localhost id)")    # refused
    is_denied("echo `date` `ssh -p 22 localhost id`")      # allowed

    The payload walk does produce the frame ssh -p 22 localhost id for the second backtick span, but the ssh floor does not refuse it when an earlier backtick substitution sits on the same line.

  2. added 6 commits that reference this issue on Nov 14, 2026
    a0d5243
    cab9292
    3ab3b56
    1447497
    0eae6f0
    ee004b9
  3. added 2 commits that reference this issue on Nov 15, 2026
    93dd8e8
    3229e2f
  4. added a commit that references this issue on Nov 15, 2026
    527f6cb
  5. added 3 commits that reference this issue on Nov 15, 2026
    b0f18ab
    dc66cee
    16a8b33
  6. 14 remaining items

  7. added 9 commits that reference this issue on Nov 16, 2026
    9d573f4
    428246e
    d2732df
    2c97dbe
    157438e
    0967b13
    b834d85
    aa6679b
    f6ba2fb
  8. added a commit that references this issue on Nov 17, 2026
    7d3c5e2
  9. added 4 commits that reference this issue on Nov 19, 2026
    2b44e4b
    d5b7ac3
    1d300a7
    0a49a60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething is not working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions