Skip to content

feat(security): RubberBand - static command pattern detection for exec pipeline#8023

Closed
jeffaf wants to merge 8 commits intoopenclaw:mainfrom
jeffaf:feat/rubberband-integration
Closed

feat(security): RubberBand - static command pattern detection for exec pipeline#8023
jeffaf wants to merge 8 commits intoopenclaw:mainfrom
jeffaf:feat/rubberband-integration

Conversation

@jeffaf
Copy link

@jeffaf jeffaf commented Feb 3, 2026

Summary

Adds a lightweight static detection layer to the exec pipeline that catches dangerous commands (credential access, exfiltration, reverse shells, persistence) as defense-in-depth against prompt injection.

RFC Discussion: #4981

What it does

Pre-exec hook that analyzes commands before execution:

  • 🔐 Credential access - SSH keys, AWS creds, API tokens
  • 📤 Data exfiltration - outbound data transfers
  • 🐚 Reverse shells - various shell callback techniques
  • ⚙️ Config tampering - writes to protected config files
  • 🧠 Memory poisoning - writes to agent memory files
  • Persistence - scheduled task creation
  • 🔄 Indirect execution - piped shell commands, eval

Key differentiators

This PR improves on prior approaches (Shield-Shell #4684, #7604 proposal) with:

  • Zero external dependencies - works fully offline, no API keys or cloud services required
  • Bypass mitigations: Unicode normalization (NFKC), URL decoding, shell escape expansion
  • Context-aware scoring: stripped content + execution pattern = higher risk
  • Configurable thresholds: alert vs block based on score
  • Tested against 134 bypass techniques (98.5% detection, 0 false positives)
  • Modes: off | log | alert | block | shadow
  • Channel notifications: Optional alerts to configured channel when commands are blocked/flagged

Performance

~0.005ms overhead per command (effectively invisible vs 10-50ms exec spawn time).

Configuration

tools:
  exec:
    rubberband:
      enabled: true
      mode: "alert"  # off | log | alert | block | shadow
      notifyChannel: true
      thresholds:
        alert: 40
        block: 60

Related work

AI Disclosure

Developed with Claude (Opus 4.5) running in OpenClaw. Fully tested on live fork. I understand the code and can answer questions.

🦞 Like the bands on lobster claws — keeps the agent from pinching the operator.

@openclaw-barnacle openclaw-barnacle bot added the agents Agent runtime and tooling label Feb 3, 2026
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@jeffaf jeffaf force-pushed the feat/rubberband-integration branch 11 times, most recently from 70ed9f4 to e942f01 Compare February 10, 2026 12:06
@jeffaf jeffaf force-pushed the feat/rubberband-integration branch 2 times, most recently from ffc483e to 3c1da6e Compare February 12, 2026 18:42
@jeffaf jeffaf force-pushed the feat/rubberband-integration branch 3 times, most recently from 53160fc to 183532f Compare February 15, 2026 13:41
@jeffaf jeffaf force-pushed the feat/rubberband-integration branch from 183532f to 85ab5d1 Compare February 16, 2026 17:32
Adds RubberBand, a static analysis layer that catches dangerous command
patterns before execution. Designed to detect prompt injection attacks
that trick the agent into running malicious commands.

Key features:
- Pattern-based detection for credential access, exfiltration, reverse
  shells, persistence, config tampering, and more
- Normalization layer catches encoding bypasses (Unicode, hex, octal,
  URL encoding, shell escapes)
- Context-aware preprocessing reduces false positives (git commit
  messages, echo statements)
- Score stacking across categories for compound threats
- Configurable thresholds and modes (block/alert/log/shadow)
- Cross-platform patterns for Unix, macOS, and Windows

Configuration:
- tools.exec.rubberband.enabled: true/false
- tools.exec.rubberband.mode: block|alert|log|shadow|off
- tools.exec.rubberband.notifyChannel: alert user on block

Patterns use [^;|&\n]* to prevent matching across command separators,
avoiding false positives on legitimate commands like:
  cat file 2>/dev/null || cat other/file.md
The system/prompt pattern was matching any command containing echo/cat/printf
with the words 'system' and 'prompt' anywhere in the line. This caused false
positives when posting GitHub comments or other API calls that discussed
prompt injection in their body text.

Now requires a redirect (>) between the command and the system/prompt path,
consistent with the other patterns in the same rule group.
Heredoc writes (cat >> file << EOF) were triggering false positives
for config_tampering and agent_memory_tampering because the heredoc
body contained keywords like AGENTS.md, SOUL.md, MEMORY.md.

Fix: detect heredoc syntax (<< DELIM) in stripContextSafeContent and
treat the entire command as a safe data write operation. Heredocs
piped to interpreters (cat << EOF | bash) are still flagged.

Added rubberband.test.ts with 10 test cases covering:
- Heredoc false positive (the triggering case)
- Heredoc to memory files
- Malicious heredoc piped to bash (still caught)
- Direct redirects without heredoc (still caught)
- Context-safe stripping (git commit, echo)
- Real threats (SSH keys, reverse shells, cred dumps, config tampering)
Add negative lookahead to prevent false positives when agent
operates on files within its own workspace directory. Actual
config paths outside workspace/ are still protected.

14 tests passing (4 new workspace exclusion tests).
Deduplicate RubberBand BLOCK/ALERT handling from three inline blocks
into a single runRubberBandCheck() helper in security/rubberband.ts.
Reduces bash-tools.exec.ts by ~63 lines.
Reset schema.ts to match upstream (removes 798 lines of duplicated
code from rebase conflict resolution). RubberBand field labels and
descriptions now live in schema.hints.ts where upstream refactored
all config UI metadata.
@jeffaf jeffaf force-pushed the feat/rubberband-integration branch from 85ab5d1 to 56975bf Compare February 18, 2026 13:34
@openclaw-barnacle
Copy link

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

26 similar comments
@openclaw-barnacle
Copy link

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui channel: bluebubbles Channel integration: bluebubbles channel: discord Channel integration: discord channel: feishu Channel integration: feishu channel: googlechat Channel integration: googlechat channel: imessage Channel integration: imessage channel: irc channel: matrix Channel integration: matrix channel: msteams Channel integration: msteams channel: nextcloud-talk Channel integration: nextcloud-talk channel: nostr Channel integration: nostr channel: signal Channel integration: signal channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: tlon Channel integration: tlon channel: twitch Channel integration: twitch channel: voice-call Channel integration: voice-call channel: whatsapp-web Channel integration: whatsapp-web channel: zalo Channel integration: zalo channel: zalouser Channel integration: zalouser cli CLI command changes commands Command implementations docker Docker and sandbox tooling extensions: device-pair extensions: diagnostics-otel Extension: diagnostics-otel extensions: llm-task Extension: llm-task extensions: lobster Extension: lobster extensions: memory-lancedb Extension: memory-lancedb extensions: phone-control gateway Gateway runtime scripts Repository scripts size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant