Repository navigation
Description
Problem
The security module (openhands-sdk/openhands/sdk/security/defense_in_depth/) relies on regex pattern matching against flattened shell command text. The terminal module (openhands-tools/openhands/tools/terminal/) uses bashlex for command splitting and escaping. Both approaches have fundamental limitations that a proper parser would solve.
Regex cannot understand shell syntax
The patterns in pattern.py (lines 70–107) and policy_rails.py (lines 78–94) are well-designed and hardened with normalization, but regex fundamentally cannot understand quoting, escaping, operators, or nesting. This creates bypass classes that no amount of regex refinement can close:
| Bypass | Why it works | Reference |
|---|---|---|
r"m" -rf / |
Quoted segment breaks \brm\b word boundary |
pattern.py:73 |
/bin/rm -rf / |
Path-qualified command breaks \brm\s+ anchor |
pattern.py:73 |
dd with of=/dev/ beyond 100 chars |
.{0,100} window is too small |
pattern.py:80, policy_rails.py:105 |
curl ... | node |
node not in hardcoded interpreter list (sh|bash|python|perl|ruby) |
policy_rails.py:82, documented xfail in test_adversarial.py:294–314 |
curl x|bash |
Escaped pipe is literal text, but regex sees | as pipe operator |
pattern.py:92 |
bash -c 'rm -rf /' |
Nested command inside -c argument is opaque to regex |
pattern.py:73 |
| Payload past 30KB | _EXTRACT_HARD_CAP truncates to prevent ReDoS |
utils.py:41, documented xfail in test_adversarial.py:241–259 |
rm --no-preserve-root -rf / |
Intervening flag breaks the strict ordering regex expects | pattern.py:73, policy_rails.py:87–94 (subject of PR #2718) |
bashlex is unmaintained and crashes on valid input
openhands-tools depends on bashlex>=0.18 (pyproject.toml:9). It's used in two functions in terminal/utils/command.py:
-
split_bash_commands()(lines 14–67): parses multi-command strings to enforce single-command execution. Catches four exception types (ParsingError,NotImplementedError,TypeError,AttributeError) because bashlex crashes on various valid shell constructs. On any failure, it silently returns the raw string — bypassing multi-command validation entirely. -
escape_bash_special_chars()(lines 70–151): walks the bashlex AST to escape unquoted operators. Uses regex on word text (lines 109–113) to detect quoted strings and command substitutions ("...",'...',$(...),`...`), because bashlex doesn't expose these as distinct node types. Same 4-exception catch-all with silent fallback.
bashlex was last meaningfully updated around 2020, has a single maintainer, and has no error recovery — any malformed input (common from LLM output) produces a ParsingError.
PR #2718 is heading in the right direction but adds complexity
PR #2718 improved rm -rf detection by replacing the regex with shlex tokenization + a hand-rolled shell segment splitter. This correctly fixes the flag-ordering bypass, but adds ~170 lines of new parsing code to utils.py: a 60-line char-by-char parser for ;/&&/||/|, a shlex.split() wrapper with fallback, regex-based redirection detection, and token-based flag inspection.
shlex is not a shell parser — it doesn't understand pipes, redirections, command substitution, or compound commands. Every new detection pattern will require more hand-rolled parsing on top of it.
The codebase parses bash three different ways
| Package | Module | Approach | Limitations |
|---|---|---|---|
openhands-sdk |
security/defense_in_depth/pattern.py |
Compiled regex patterns | Can't understand syntax |
openhands-sdk |
security/defense_in_depth/policy_rails.py |
Composed regex conditions | Same |
openhands-sdk |
security/defense_in_depth/utils.py (PR #2718) |
shlex + hand-rolled splitter |
Not a shell parser |
openhands-tools |
terminal/utils/command.py |
bashlex |
Crashes on valid input, unmaintained, no error recovery |
openhands-sdk |
context/skills/execute.py |
Regex for !`cmd` extraction |
No security check before subprocess.run(shell=True) |
Proposal
Replace all shell parsing with tree-sitter + tree-sitter-bash.
Why tree-sitter
- Full parse tree: commands, arguments, flags, operators, redirections, quoting — all understood structurally
- Error recovery: malformed shell (common from LLM output) still produces a partial AST with error nodes instead of raising exceptions. This directly solves the bashlex crash problem
- O(n) parsing: eliminates the 30KB hard cap (
utils.py:41) currently needed to prevent regex ReDoS (documented xfail intest_adversarial.py:241–259) - Actively maintained: used by GitHub (syntax highlighting for every repo), Neovim, Zed; the bash grammar is comprehensive and regularly tested
- Small footprint:
tree-sitter(~2 MB) +tree-sitter-bashgrammar
What changes
1. PatternSecurityAnalyzer (pattern.py)
Replace the HIGH-risk regex patterns (lines 70–101) with tree-sitter queries. Example for rm -rf:
import tree_sitter_bash as tsbash
from tree_sitter import Language, Parser
BASH = Language(tsbash.language())
parser = Parser(BASH)
def _has_rm_recursive_force(command: str) -> bool:
tree = parser.parse(command.encode())
for node in _walk_commands(tree.root_node):
words = [c.text.decode() for c in node.children if c.type == "word"]
if not words or not (words[0] == "rm" or words[0].endswith("/rm")):
continue
flags = set()
for w in words[1:]:
if w == "--":
break
if w == "--recursive":
flags.add("r")
elif w == "--force":
flags.add("f")
elif w.startswith("-") and w != "-":
flags.update(w[1:])
if {"r", "f"} <= flags or {"R", "f"} <= flags:
return True
return FalseThis immediately fixes:
/bin/rm -rf /—words[0].endswith("/rm")handles path-qualified commandsrm --no-preserve-root -rf /— flags in any positionrm / -rf— flags after positional args
Similarly for dd of=/dev/ (extract of= from word nodes, no char-count window), curl | sh (query pipeline nodes, check RHS command name — not a hardcoded list), and mkfs.
Patterns that are not shell-specific stay as regex:
- Injection patterns (
inject.override,inject.mode_switch,inject.identity) — NLP, not syntax - Python code patterns (
eval(),os.system(),subprocess.*()) — not bash
2. PolicyRailSecurityAnalyzer (policy_rails.py)
- Fetch-to-exec rail (lines 78–102): query the parse tree for
pipelinenodes. Check if LHS iscurl/wgetand RHS is any command — eliminates the hardcoded interpreter list. This fixes thecurl | nodexfail (test_adversarial.py:294–314) - Raw-disk-op rail (lines 104–112): parse
ddcommand, extractof=value from word nodes, check if it starts with/dev/. No fixed-width window - Catastrophic-delete rail (lines 114–128): reuse
_has_rm_recursive_forcefrom above, then check target arguments against the critical path list
3. Utils cleanup (utils.py)
If PR #2718 merges first, delete the hand-rolled parsing it adds:
_split_shell_segments()— replaced by tree-sitter's understanding of;,&&,||,|_tokenize_shell_segment()— replaced by tree-sitter node children_is_redirection_token()— tree-sitter has aredirectnode type_segment_has_rm_recursive_force()and_has_rm_recursive_force()— replaced by tree-sitter version
The normalization pipeline (_normalize, lines 310–338) stays — invisible char stripping and NFKC normalization are still valuable as pre-processing before tree-sitter parsing.
The extraction logic (_extract_exec_segments, _extract_content, etc.) stays — it controls which fields are scanned.
4. openhands-tools: replace bashlex (terminal/utils/command.py)
split_bash_commands() (lines 14–67):
- tree-sitter parses malformed input gracefully (partial AST with error nodes) instead of raising 4 exception types
- The catch-all fallback that silently bypasses multi-command validation disappears
- Multi-command detection becomes: walk the tree for top-level
commandnodes
escape_bash_special_chars() (lines 70–151):
- tree-sitter provides explicit node types for
string(double-quoted),raw_string(single-quoted),command_substitution,heredoc_body— no need to detect these via regex on string content (lines 109–113) - The recursive
visit_node()+ regex approach becomes a tree walk
Dependency change in openhands-tools/pyproject.toml:
- "bashlex>=0.18",
+ "tree-sitter>=0.24",
+ "tree-sitter-bash>=0.23",The public API of both functions stays the same — only the internal implementation changes.
5. Skill execution (context/skills/execute.py)
Currently, commands extracted via the !`command` regex (line 44–48) are executed directly via subprocess.run(shell=True) (line 66) with no security analysis. With tree-sitter available in openhands-sdk, extracted commands should be run through the security analyzer before execution.
6. Shared parser across packages
The key benefit: both packages share one parser. Today openhands-sdk (security) uses regex + shlex and openhands-tools (terminal) uses bashlex. With tree-sitter-bash, both share one dependency and one parsing strategy. Security checks can run on the same AST the terminal uses for command splitting.
What stays the same
- Normalization pipeline (
utils.py:310–338) — invisible char stripping, NFKC, whitespace collapse remain as pre-processing - Extraction architecture (
utils.py:75–157) — whitelisted field extraction, per-segment evaluation, hard cap (can be raised or removed with O(n) parsing) - Injection patterns (
pattern.py:112–132) — NLP patterns, not shell syntax; regex is appropriate - Python code patterns (
pattern.py:82–89) —eval(),os.system(),subprocess.*()are not bash - Per-segment evaluation (
policy_rails.py:68–130) — correct architecture, each segment is now parsed instead of regex-scanned - Terminal escape filtering (
openhands-tools/.../escape_filter.py) — byte-level ANSI patterns, not bash syntax
Out of scope
- Cyrillic homoglyph bypasses — charset problem, requires Unicode TR39 confusable tables (documented xfail in
test_adversarial.py:201–219) - Combining mark bypasses — requires diacritic stripping (documented xfail in
test_adversarial.py:221–239) - Variable indirection (
x=rm; $x -rf /) — requires runtime evaluation - Alias/function expansion — requires shell state
Test plan
- All existing tests in
test_pattern.py,test_policy_rails.py,test_adversarial.pymust pass - The hard-cap xfail (
test_adversarial.py:241–259) can be converted to a passing test if the cap is raised/removed - The
curl | nodexfail (test_adversarial.py:294–314) can be converted to a passing test with pipeline-based detection - Add regression tests for bypasses tree-sitter fixes:
/bin/rm -rf /(path-qualified command)bash -c 'rm -rf /'(nested command)dd if=/dev/zero of=/dev/sdawithof=beyond 100 chars
- All existing
openhands-toolstests forsplit_bash_commandsandescape_bash_special_charsmust pass
(cc. @csmith49 @Fieldnote-Echo )
Activity
Fieldnote-Echo commentedon Apr 6, 2026
@VascoSch92 Insightful. I fully support dropping the old bashlex (GPL) fallback in favor of a structural AST parser like Tree‑sitter. Tree‑sitter’s Bash grammar (MIT-licensed, actively maintained in v0.25+) provides comprehensive shell syntax parsing, so our analyzer sees the real command structure. Wrapping the parser to fail closed on any syntax error (ERROR nodes) instead of defaulting to raw text, preventing silent bypasses.
In practice, this means our normalized patterns (flag checks, banned commands, etc.) will now operate on a true AST. This change should eliminate bypasses caused by trick flags or nested bash -c calls, while still allowing us to handle complex cases safely.
VascoSch92 commentedon Apr 8, 2026
Hey @Fieldnote-Echo
Would you like to help with this proposal?
Fieldnote-Echo commentedon Apr 19, 2026
@VascoSch92, back from the flu and caught up on this thread, Kushal's #2718, and my own polish cycle.
The architectural call here is the maintainers', not mine. What I can offer as the original analyzer contributor is perspective on what it was trying to be and where tree-sitter amplifies or strains that intent.
Original design intent:
What tree-sitter amplifies:
bash -c, path-qualified commands, long operands.ParsingError / NotImplementedError / TypeError / AttributeErroratterminal/utils/command.py) is currently the weakest link in multi-command detection. Removing it is good independent of the security angle.What needs careful consideration:
bashexecutes another, the gap didn't exist in the regex world. A small fuzzing pass would surface it early.What gives hope:
Thank you for this. You're offering to make the security analyzer more robust, and it's clear you have the capability to execute it: the bypass catalog at the top of your proposal and the decision to keep injection/Python as regex demonstrate this. That's the harder half of proposing a migration like this, and volunteering to carry it is the rest.
I'm here during the design review if you need me, or on Slack if you want to brainstorm.
VascoSch92 commentedon May 13, 2026
Phased migration plan
Splitting this proposal into two stages so we can ship the license fix immediately and pace the security analyzer work normally.
Verified the licenses:
bashlextree-sitter(Python bindings + C core)tree-sitter-bash(Python package + grammar)This repo is MIT, so the
bashlextransitive dependency is a real license-compatibility concern, not just hygiene. That motivates pulling the license fix forward.The key observation:
bashlexis used in exactly one file —openhands-tools/openhands/tools/terminal/utils/command.py(two functions:split_bash_commands,escape_bash_special_chars) plus the dep line inopenhands-tools/pyproject.toml:9. The security analyzers inopenhands-sdkalready use regex and have zero dependency onbashlex. So removing GPL is a much smaller scope than the full proposal.Phase 1 — Drop
bashlex(one PR, ship ASAP)Goal: zero GPL code in the dependency tree. Tightly scoped, fast to review.
openhands-tools/pyproject.toml:9— replace"bashlex>=0.18"with"tree-sitter>=0.24"and"tree-sitter-bash>=0.23".split_bash_commandsinopenhands-tools/openhands/tools/terminal/utils/command.pyagainst tree-sitter, preserving the public signature and the silent-passthrough fallback semantics. Drop the 4-exception catch-all (ParsingError,NotImplementedError,TypeError,AttributeError) — tree-sitter recovers viaERRORnodes instead of raising.escape_bash_special_charssimilarly, using first-class node types (string,raw_string,command_substitution,heredoc_body) instead of the regex-on-word-text check at lines 109–113.Parserso grammar load happens once.tests/tools/terminal/test_terminal_parsing.pymust pass unchanged. That's the contract: same inputs → same outputs.Explicitly out of scope for Phase 1:
openhands-sdk/.../security/defense_in_depth/*— no GPL there.ERROR-node policy change, noUNKNOWNemission, no xfail conversions, no new bypass-class regression tests. Those all belong in Phase 2.bashlex.PR framing: lead with "Remove GPLv3 transitive dependency (
bashlex); replace with MIT-licensedtree-sitter-bash. Public API ofsplit_bash_commandsandescape_bash_special_charsunchanged. Security analyzer migration tracked in #2721."Phase 2 — Shared parser module + security analyzer migration
Once GPL is gone, the rest of the proposal at a normal pace, split into focused PRs:
openhands-sdk/openhands/sdk/security/shell_parser.py. Move tree-sitter deps fromopenhands-toolsintoopenhands-sdk/pyproject.toml(tools gets them transitively). Refactorcommand.py(from Phase 1) to call the shared module. No behavior change.pattern.py. Replace HIGH shell patterns (pattern.py:70–80, 91–100) with parser-backed detectors. Keep stable detector IDs. Keep Python-code patterns (pattern.py:82–89) and injection patterns (pattern.py:112–131) as regex — they're not bash. Decide ERROR-node policy here (proposed: emitUNKNOWNfrom the shell analyzer, letEnsembleSecurityAnalyzerdecide — picks up @Fieldnote-Echo's suggestion).policy_rails.py. Rewrite_evaluate_rail_segments(lines 68–130) using parser queries. Drop the hardcodedsh|bash|python|perl|rubyinterpreter list (fixes thecurl | nodexfail). Drop the.{0,100}window ondd of=/dev/(fixes the windowed-bypass xfail).utils.py. If fix(security): close rm flag-ordering bypasses #2718 has merged by this point, delete the ~170 lines of hand-rolled parsing it added. Raise or remove_EXTRACT_HARD_CAP = 30_000on the exec corpus (ReDoS motivation is gone with O(n) parsing). Keep_normalize,_extract_*,_walk_json_strings.context/skills/execute.py. Wire the parser-backed analyzer into the!`cmd`execution path beforesubprocess.run(shell=True)at line 66. New decision: refuse vs. log on HIGH risk during skill rendering.test_adversarial.py:241–259and:294–314to passing tests. Add regression tests for the bypass classes listed in the proposal (/bin/rm -rf /,bash -c 'rm -rf /',dd of=/dev/sdabeyond 100 chars, quoted segments). Add a small fuzz pass for parse-vs-execute divergence (per @Fieldnote-Echo's note).Open decisions for Phase 2
UNKNOWNvs fail-closed vs fail-scan. ProposingUNKNOWNso the ensemble fusion path handles it.tree-sitter-bashupgrade could change detection behavior. Pin to a fixed minor for security-critical pinning.VascoSch92 commentedon May 13, 2026
Hey @Fieldnote-Echo and @eeee2345,
I know you are both interested in these types of problems.
We would like to move away from
bashlexbecause of its license (as pointed out by @Fieldnote-Echo) and because it is no longer maintained. I’ve divided the issue into two parts. The first part is simply moving away from bashlex; I’ll handle that so it’s done.For the second part, let me know if you are interested in working on any of the points. We can also divide the scope of the second part even further.
Fieldnote-Echo commentedon May 19, 2026
@VascoSch92, surfacing the Slack ask for Phase 2c:
Have
parse()return aParseResultdataclass exposingroot_nodeas a public, read-only field alongside the convenience iterators (iter_simple_commands,iter_pipelines, etc.). Detectors that need structural context get it directly; others use the iterators. Detector classes can then live outsideshell_parser.pywithout private accessors. No re-parsing across composed analyzers.Adjacent design question: ERROR-node handling. Existing ensemble convention is
UNKNOWNon parse failure, notHIGH. Promoting parse errors toHIGHdistortsmax(concrete)fusion since sibling analyzers degrade toUNKNOWNwhen unconfigured. Design-intent context from #2472 if helpful./cc @csmith49.
test(security): xfail corpus for shell-parser bypass classes that clo…
test(security): xfail corpus for shell-parser bypass classes (#2721) (#…
eeee2345 commentedon May 19, 2026
@VascoSch92 — yes, interested in Phase 2. Given ATR's focus on security detection at the tool-call boundary, the points that make the most sense to take on are Phase 2b (integrating ATR pattern signatures as a concrete ShellAnalyzer implementation) and Phase 2c (ParseResult dataclass — @Fieldnote-Echo's write-up covers this well already).
Happy to open a draft PR for 2b once Phase 1 (bashlex replacement) lands, so the detection layer builds on the clean tree-sitter foundation. If you're dividing scope further, let me know which sub-points are already claimed.
refactor(sdk): introduce shared tree-sitter-bash entry point
refactor(sdk): introduce shared tree-sitter-bash entry point
6 remaining items
eeee2345 commentedon Jun 29, 2026
@VascoSch92 picking this back up now that Phase 1 and the shared _shell_ast view have all landed. Before I open the 2b draft I want to make sure I am not overlapping #3563, which already adds a parser-backed supply-chain analyzer on the same shared view. My read is that 2b proper is still open: replacing the HIGH shell patterns in pattern.py with parser-backed detectors, keeping the stable detector IDs, and leaving the injection and Python patterns as regex since they are not bash. Does that scoping still match what you want, or has part of it been folded into the work already in flight?
On the ERROR-node policy I agree with @Fieldnote-Echo: emit UNKNOWN from the shell analyzer and let the ensemble decide, rather than promoting parse errors to HIGH and distorting the max-of-concrete fusion.
I will keep it to a draft PR so it is easy to review in pieces. Disclosure: I maintain ATR, an open-source detection ruleset, which is where my interest in the tool-call boundary comes from.
VascoSch92 commentedon Jun 30, 2026
@eeee2345 please go haed. Tag me for a review. ;-)
eeee2345 commentedon Jul 1, 2026
@VascoSch92 opened #3944 — the scoped first cut we discussed: AST-backed command-name resolution on the shared
_shell_astview, closing the quoted (r"m" -rf /), path-qualified (/bin/rm), and nested--c(bash -c 'rm -rf /') bypasses, with the detector IDexec.destruct.rm_rfpreserved. Command-substitution and ANSI-C-quoting stay strict xfails for a follow-up (they need a runtime-decode-vs-fail-closed policy call). Unresolvable destructive-flag shapes emit UNKNOWN, benign text stays LOW.Full
tests/sdk/security/suite green (363 passed / 10 xfailed); pre-commit, whole-project pyright, and the import-layering check all clean. Tagged you for review whenever you have a moment.github-actions commentedon Aug 11, 2026
This issue is stale because it has been open for 40 days with no activity. Remove the stale label or leave a comment, otherwise it will be closed in 10 days.
test(security): xfail corpus for shell-parser bypass classes (OpenHan…
eeee2345 commentedon Aug 14, 2026
@VascoSch92 @Fieldnote-Echo — not idle, but the bot cannot see why, so here is the state against the six items in the proposal. Checked on
maintoday rather than from memory.Item 6, the shared parser view: landed.
openhands-sdk/openhands/sdk/security/_shell_ast.pyis onmain.Item 1,
pattern.py: in review, and it is one person away. #3944 does AST-backed command-name resolution for the HIGH destructive detectors — the quoted, path-qualified and nested-runner bypasses. @VascoSch92 approved it on 4 Aug and asked @Fieldnote-Echo whether it can merge. It has been sitting on that question for a week. Its only remaining red is theunresolved-review-threadsgate, which is stuck inaction_requiredrather than failing.Items 2 and 3: untouched.
policy_rails.pystill evaluates entirely by regex — sixre.search/re.compilecalls, zero AST — so the composed rails carry the same quoting and nesting blind spots #3944 closes for the pattern layer.utils.pyhas no AST usage either.So the plan is roughly one sixth landed, one sixth approved-and-waiting, and the rest open. That is a reason for this issue to stay open, but only if someone intends to pick up items 2 through 5.
@VascoSch92 — you said in May you did not have much time for this, which is completely fair. Two honest options:
policy_rails.py) once feat(security): AST-backed shell command-name resolution (#2721 Phase 2b) #3944 lands, since the rails are the layer with the same defect and the AST view is already there.Either is fine. What I would rather avoid is the bot deciding it on 21 Aug, with an approved PR still pointing at a closed issue.
VascoSch92 commentedon Aug 14, 2026
Hey @eeee2345
sorry for that. I merged the PR #3944
I will take this Issue open and continue with the points :-)
feat(security): AST-backed shell command-name resolution (#2721 Phase…
feat(security): AST-backed shell command-name resolution (#2721 Phase…
all-hands-bot commentedon Sep 18, 2026
[Automatic Post]: This issue has had no activity for 34 days (labels: proposal, security-related). @enyst @neubig @xingyaoww, could you take a look when you have a chance and help figure out next steps?
Generated by OpenHands automation on behalf of the user.
Fieldnote-Echo commentedon Oct 12, 2026
@VascoSch92 I can take the remaining work here. I will start by migrating
PolicyRailSecurityAnalyzerto the shared shell AST while preserving the current rail IDs and result ordering. I will keep the extraction-limit and skill-execution policy changes separate.Fieldnote-Echo commentedon Oct 13, 2026
@VascoSch92 I ran #5724 against 19,812 shell-call records from the public
OpenHands feedback and Data Agent Harbor datasets. The set contains 13,876
unique command strings. The harness passed command text to the analyzers. It
did not execute a corpus command.
At tested implementation commit
a8a4ef5, 37 records contain 42component-result changes from PR base
acca181a: 20 policy-rail changes fromLOWtoHIGH, 16 policy-rail changes fromLOWtoUNKNOWN, and sixpattern-analyzer changes from
LOWtoUNKNOWN.The projected default ensemble result changed for 25 records: 20 changed from
MEDIUMtoHIGH, and five changed fromLOWtoUNKNOWN. No analyzer erroroccurred. No concrete risk result in this corpus became lower.
HIGHMEDIUMLOWUNKNOWNAll 37 changed records came from the 2,697-record OpenHands feedback corpus,
which contains 1,252 unique command strings. The 17,115-record Data Agent
Harbor corpus contains 12,624 unique command strings and had no changed record.
The 20 promotions include 18 NodeSource installer occurrences across four
exact command strings. They also include one signing-key setup and one
curl | greppipeline. The five new combinedUNKNOWNresults contain dynamicevalinput.The component results are measured. The ensemble and confirmation counts are
computed projections, not observed user prompts. The corpus has no threat
labels or full task authorization context. It cannot establish precision or
recall.
The corpus found one implementation defect that belongs in #5724. Bash
command -vandcommand -Vare inspection modes, but the rail treated themas unsupported execution. The fix does not promote the inspected name to an
executed command. It still scans nested substitutions, later commands, normal
command -pexecution, and supported builtin wrapper chains. A related reviewalso found base-to-head regressions through
builtin commandandbuiltin exec; the same focused fix covers them.The remaining findings need separate policy decisions.
What should
fetch-to-execmean?Proposal: Replace regex-based shell command analysis with tree-sitter-bash #2721 specifies a fetch whose output reaches another command in the same
pipeline. This catches remote script execution, but it also makes
curl | grepHIGH. Fivecurl | python -m json.toolrecords were alreadyHIGHbefore this PR.I recommend a follow-up policy that distinguishes resolved code execution
or privileged mutation, unresolved downstream behavior, and resolved data
transformation. The rule must inspect arguments and execution structure. An
executable-name allowlist is not sufficient. I would keep Replace policy rail regexes with shell AST analysis #5724 aligned
with the current written rule until maintainers select a new policy.
The AST rail also does not track fetched values across separate statements.
For example,
v=$(curl -s URL); echo "$v" | python3remainsLOW.Segment-wide correlation is not a sound fix because it would also flag
curl x; echo y | python, where the fetched output does not reach Python.Cross-statement value tracking is a separate data-flow policy. It should not
be added as a special case to this parser migration. In
$(curl -s URL) | python3, fetched text becomes an unresolved command name.The rail returns
UNKNOWN. The default ensemble can replace that resultwith
LOW, which belongs to the separate ensemble decision below.Should a concrete analyzer result hide another analyzer's
UNKNOWN?The default ensemble filters
UNKNOWNwhen another child returns a concreteresult. Strict mode propagates it. With unknown confirmation enabled, the
projected
HIGH-threshold confirmations are 34 at base, 59 with the defaultfixed-head ensemble, and 60 with the strict fixed-head ensemble.
I recommend no ensemble default change in Replace policy rail regexes with shell AST analysis #5724. A default change affects
confirmation behavior and compatibility. It needs a separate decision with
an end-to-end prompt evaluation.
What does
LOWguarantee?For these analyzers,
LOWmeans that no configured detector matched and norelevant unresolved structure remained. It does not mean read-only,
authorized, or generally safe.
The sampled
LOWrecords include answer-file writes, package installation,Git push, migrations, and background service startup. State change alone
cannot be a threat rule because state change is normal agent work. General
effect and authorization policy should remain separate from this migration.
Which existing text rules need their own policy review?
Five unchanged Harbor
HIGHrecords came fromsubprocess.run()text.Similar direct package commands remained
LOW. Thesubprocess.run()textsignature caused this difference. The corpus did not measure a difference
in command effects. It is not a Replace policy rail regexes with shell AST analysis #5724 regression. I recommend a separate
issue for Python-code signatures and severity.
I will keep the bulk corpus outside normal SDK CI. Small sanitized cases can
remain as regression tests. Future corpus reports should show component
results, final ensemble results, and projected confirmation decisions
separately. They should also report record counts, unique commands, and each
corpus separately.