https://github.com/clawshell/clawshell
The Security Layer for OpenClaw, the essential safety harness for PII & sensitive credentials protection.
https://github.com/clawshell/clawshell
ai credentials harness moltbot openclaw pii rust secuirty
Last synced: 2 months ago
JSON representation
The Security Layer for OpenClaw, the essential safety harness for PII & sensitive credentials protection.
- Host: GitHub
- URL: https://github.com/clawshell/clawshell
- Owner: clawshell
- License: apache-2.0
- Created: 2026-02-13T19:19:42.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2026-02-19T07:16:56.000Z (2 months ago)
- Last Synced: 2026-02-19T12:52:35.221Z (2 months ago)
- Topics: ai, credentials, harness, moltbot, openclaw, pii, rust, secuirty
- Language: Rust
- Homepage: https://clawshell.org
- Size: 23.6 MB
- Stars: 36
- Watchers: 4
- Forks: 4
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-agent-runtime-security - clawshell - keys, DLP, Unix-permissions | Drop-in sidecar proxy for OpenClaw that maps virtual API keys to real provider credentials (stored in a Unix-permission-protected config), with regex-based DLP scanning that can block or redact PII in request/response bodies before they reach upstream LLM APIs. | (Secrets Management & Isolation)
README
# ClawShell π‘οΈ

> **Powered by Runta. The essential safety harness for OpenClaw's PII & Sensitive Credentials.**
[](LICENSE)
[](https://github.com/clawshell/clawshell/actions)
[](https://www.npmjs.com/package/@clawshell/clawshell)
[](https://crates.io/crates/clawshell)
## π Introduction
**ClawShell** is a security-privileged process for the **OpenClaw** ecosystem. It sits between OpenClaw and upstream LLM API providers (OpenAI, Anthropic, OpenRouter), performing virtual-to-real API key mapping and DLP (Data Loss Prevention) scanning on request and response bodies. It can also expose an Email read endpoint with sender allowlist/denylist filtering.
OpenClaw never holds real API keys, only virtual keys that ClawShell swaps for real ones before forwarding requests upstream. Real keys are stored in a privileged config directory (`/etc/clawshell`) protected by Unix file system permissions.
## Key Features
### 1. API Token Secure Binding
ClawShell maps virtual API keys to real provider keys so that OpenClaw never has direct access to real credentials.
- **Key Isolation**: Real API keys are stored in `/etc/clawshell/clawshell.toml`, readable only by the `clawshell` system user. OpenClaw holds only virtual keys.
- **Multi-Provider Support**: Maps keys to OpenAI or Anthropic, injecting the correct authentication header format (`Authorization: Bearer` for OpenAI, `x-api-key` for Anthropic).
### 2. PII Safety Net (DLP)
ClawShell scans HTTP request and response bodies for sensitive data using configurable regex patterns.
- **Request Scanning**: Detects PII (SSNs, credit card numbers, emails, etc.) in outbound requests. Patterns can be configured to either block the request or redact the matched text before forwarding.
- **Response Scanning**: Optionally scans upstream responses and redacts detected PII before returning to OpenClaw. Streaming (SSE) responses are passed through without scanning.
- **Custom Patterns**: Define sensitive data patterns using regex in the TOML config, each with a `block` or `redact` action.
### 3. Sensitive Email Isolation
ClawShell supports sender-based email filtering so each virtual key only sees mailbox content based on sender rules.
- **Sender Filtering**: Filter emails by sender.
- **Key Isolation**: IMAP credentials are stored in `/etc/clawshell/clawshell.toml`, readable only by the `clawshell` system user. OpenClaw holds only virtual keys.
- **Provider Support**: Built-in Gmail and Outlook presets, with manual IMAP setup for other providers.
### 4. Seamless Integration
- **Drop-in Sidecar**: Deploys alongside OpenClaw without requiring re-install β the `clawshell onboard` command automatically configures OpenClaw to point at ClawShell's address and forwards all requests upstream.
- **No External Dependencies**: Uses Unix file system permissions to protect secrets. No IdP, Vault, or external key management service required.
### 5. Ultra Lightweight and Scalable
- Runs in under 10MB of memory.
- Written in Rust with Tokio.
## Architecture
```
β security boundary (Unix File System Permissions)
β
β βββββββββββββββββββββββββββββ
β β /etc/clawshell β
β β β real API keys β
β β β DLP patterns β
β β β email sender rules β
β β β IMAP account creds β
β ββββββββββββ¬βββββββββββββββββ
β reads β
β ββββββββββββ΄βββββββββββββββββ
ββββββββββββββββ REQUEST β β β REQUEST ββββββββββββββ
β βββ(virtualββββ«ββΊβ ClawShell βββ-(real key,ββββΊβ β
β OpenClaw β key) β β β PII redacted) β OpenAI / β
β β β β DLP scan β β Anthropic/ β
β holds only β RESPONSE β β real-key mapping β RESPONSE β OpenRouter β
β virtual keys ββββββββββββββββββ€ email sender filtering βββββββββββββββββββ€ β
β β β β β ββββββββββββββ
β β EMAIL GET β β β IMAP fetch ββββββββββββββ
β ββββ(virtualβββ | |βββ(real key)ββββΊ| |
β β key) β β β β IMAP β
β β β β β | Provider β
β β β β β RESPONSE β Gmail / β
β β filtered β β βββββββββββββββββββ Outlook / β
β βββββββββββββββββ| | β custom β
ββββββββββββββββ β | | ββββββββββββββ
β βββββββββββββββββββββββββββββ
```
OpenClaw only holds virtual keys and cannot access the real API keys stored in the privileged config.
ClawShell swaps virtual keys for real ones and scans for PII before forwarding requests upstream.
ClawShell also enforces sender-based filtering before returning email data.
## Installation
### Cargo
```bash
cargo install clawshell --locked
# Requires privilege to set up the security boundary
sudo clawshell onboard
```
### NPM
```bash
npm install -g @clawshell/clawshell
# Requires privilege to set up the security boundary
sudo clawshell onboard
```
### Build from Source
```bash
cargo build --release
ls -al target/release/clawshell
```
#### Cross-compile on Linux/arm64
```bash
wget https://musl.cc/x86_64-linux-musl-cross.tgz -O /tmp/musl-cross.tgz
tar -xzf /tmp/musl-cross.tgz -C /tmp
CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER="/tmp/x86_64-linux-musl-cross/bin/x86_64-linux-musl-gcc" \
cargo build --release --target x86_64-unknown-linux-musl
```
## Advanced Usage
### Onboarding
The `onboard` command is an interactive setup wizard that must be run with `sudo`. It:
1. Creates the `clawshell` system user.
2. Creates and secures `/etc/clawshell` (mode 700) and `/var/log/clawshell`.
3. Walks you through provider selection, API key entry, and virtual key generation.
4. Writes the ClawShell config to `/etc/clawshell/clawshell.toml`.
5. Updates your OpenClaw configuration to route through ClawShell.
6. Starts the ClawShell daemon.
```bash
sudo clawshell onboard
```
### More Commands
```bash
# Start (daemonizes by default)
sudo clawshell start
# Start in the foreground
sudo clawshell start --foreground
# Start with a custom config file
sudo clawshell start -c /path/to/clawshell.toml
# Check status
clawshell status
# View logs
clawshell logs
clawshell logs --level error
clawshell logs --follow
# Restart / Stop
sudo clawshell restart
sudo clawshell stop
# Migrate config schema to current version
sudo clawshell migrate-config
```
By default ClawShell listens on `127.0.0.1:18790`.
### Customized Configuration
ClawShell reads its config from `/etc/clawshell/clawshell.toml`. You can view or edit it with:
```bash
sudo clawshell config # print current config
sudo clawshell config --edit # open in $EDITOR
```
A minimal config looks like this:
```toml
version = "0.1.1"
log_level = "info"
[server]
host = "127.0.0.1"
port = 18790
[upstream]
openai_base_url = "https://api.openai.com"
anthropic_base_url = "https://api.anthropic.com"
# Virtual-to-real API key mappings
[[keys]]
virtual_key = "vk-alice-001"
real_key = "sk-your-real-openai-key-here"
provider = "openai"
[[keys]]
virtual_key = "vk-claude-001"
real_key = "sk-ant-your-real-anthropic-key-here"
provider = "anthropic"
# Data Loss Prevention (DLP)
# action = "block" -> reject the request with 400
# action = "redact" -> replace matches with [REDACTED:] and forward
[dlp]
scan_responses = false
patterns = [
{ name = "ssn", regex = '\b\d{3}-\d{2}-\d{4}\b', action = "redact" },
{ name = "visa_card", regex = '\b4[0-9]{12}(?:[0-9]{3})?\b', action = "redact" },
{ name = "amex_card", regex = '\b3[47][0-9]{13}\b', action = "redact" },
]
# Email secure endpoint
[email]
enabled = true
mode = "allowlist"
allow_senders = ["alice@example.com", "@trusted.org"]
deny_senders = []
default_max_results = 50
[[email.accounts]]
virtual_key = "vk-email-001"
email = "bot@gmail.com"
app_password = "abcd efgh ijkl mnop"
imap_host = "imap.gmail.com"
imap_port = 993
# Outlook preset example:
# imap_host = "imap-mail.outlook.com"
```
If `start`, `restart`, `stop`, `config --edit`, `onboard`, or `uninstall` reports that migration is required, run:
```bash
sudo clawshell migrate-config --config /etc/clawshell/clawshell.toml
```
See [`clawshell.example.toml`](clawshell.example.toml) for a full example.
### Uninstall
```bash
sudo clawshell uninstall
```
## License
This project is licensed under the [Apache License 2.0](LICENSE).