Secure subprocess secret injection for AI agents
Project description
secretsh
Secure subprocess secret injection for AI agents.
Beta. Core functionality is stable and tested. Read What it does NOT before deploying in sensitive environments.
AI agents write commands with {{PLACEHOLDER}} tokens. secretsh resolves them from an encrypted vault at exec time and scrubs any secrets that leak back through output.
Agent writes: curl -u admin:{{API_PASS}} https://internal/api
Child runs: curl -u admin:hunter2 https://internal/api
Agent sees: curl -u admin:[REDACTED_API_PASS] https://internal/api
What it does and does NOT
Does
| Keeps secrets out of LLM context | Agent only ever sees {{PLACEHOLDER}}, never the value |
| Keeps secrets out of shell history | secretsh reads from an encrypted vault, not the command line |
| Keeps secrets out of spawn errors | command not found: "[REDACTED]" — never the raw value |
| Scrubs output (best effort) | Aho-Corasick substring redaction on stdout/stderr — raw, base64, URL-encoded, hex |
| Blocks shell oracle attacks | --no-shell rejects sh/bash/zsh/etc. before any child runs |
| Encrypts at rest | AES-256-GCM + Argon2id + HKDF — key names and values both encrypted |
Does NOT
| Stop prompt injection | If the agent is tricked into running a malicious command, secretsh executes it |
| Stop a child reading its own argv | Secret is in the process's argv for its lifetime — visible in /proc/<pid>/cmdline |
| Handle common-value false positives | If your secret is 123456, every 123456 in output is redacted — including unrelated content |
| Fully close the redaction oracle | echo {{KEY}}==guess leaks one bit per probe — if ==guess is also redacted, the guess matched |
| Replace a secrets manager | No access control, no audit trail beyond local stderr JSON, no rotation |
| Protect against a compromised passphrase | If SECRETSH_KEY is stolen, the vault is open |
In short: secretsh gives your AI agent the ability to use credentials without the credentials appearing in its context, history, or output — it does not stop a sufficiently adversarial agent from probing or exfiltrating. Use
--no-shellto raise the bar.
Install
# Homebrew
brew tap lthoangg/tap && brew install secretsh
# PyPI
uv add secretsh
# From source
cargo install secretsh
Pre-built binaries for x86_64/aarch64 on macOS and Linux: GitHub Releases.
Quick Start
# 1. Set passphrase (silent, not saved to history)
read -rs SECRETSH_KEY && export SECRETSH_KEY
# 2. Create vault and import secrets
secretsh init
secretsh import-env -f .env
# 3. Run commands — secrets injected and scrubbed
secretsh run --no-shell -- curl -u "{{API_USER}}:{{API_PASS}}" https://api.example.com
# 4. List what's stored (values never shown)
secretsh list
Commands
| Command | Description |
|---|---|
secretsh init |
Create a new encrypted vault |
secretsh set <KEY> |
Store a secret (interactive hidden input) |
secretsh delete <KEY> |
Remove a secret |
secretsh list |
List key names (never values) |
secretsh run -- <cmd> |
Execute with secret injection + output redaction |
secretsh export --out <path> |
Export vault to encrypted backup |
secretsh import --in <path> |
Import entries from a backup |
secretsh import-env -f <path> |
Bulk import from a .env file |
All commands read the passphrase from SECRETSH_KEY by default. Use --master-key-env <VAR> to override.
Key run flags
| Flag | Default | Purpose |
|---|---|---|
--no-shell |
off | Block sh/bash/zsh/dash/fish/ksh/tcsh/csh as argv[0]. Recommended for AI agents. |
--timeout |
300s | Kill child after N seconds |
--max-output |
50 MiB | Kill child if stdout exceeds this |
--quiet |
off | Suppress audit JSON on stderr |
Python API
import secretsh
with secretsh.Vault(master_key_env="SECRETSH_KEY") as vault:
result = vault.run("curl -H 'Authorization: Bearer {{API_KEY}}' https://api.example.com")
print(result.stdout) # Bearer [REDACTED_API_KEY]
print(result.exit_code) # 0
See docs/python-api.md for the full API reference.
Documentation
| Doc | Content |
|---|---|
| docs/cli.md | All flags, exit codes, vault location |
| docs/threat-model.md | Full security model, oracle attacks, known limitations |
| docs/architecture.md | Execution pipeline, crypto, memory hardening |
| docs/testing.md | Test inventory, known gaps |
| examples/ | Runnable CLI and Python examples |
Exit Codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1–125 | Child exit code (passthrough) |
| 124 | Timeout or output limit exceeded |
| 125 | secretsh error (vault, tokenization, shell blocked) |
| 126 | Command not executable |
| 127 | Command not found |
| 128+N | Child killed by signal N |
Development
cargo test # 233 tests (220 unit + 13 integration)
cargo clippy -- -D warnings # must be zero warnings
cargo fmt --check
# Python bindings
maturin develop --features python
python -m pytest tests/ -v
License
MIT · Contributing · Security
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file secretsh-0.1.5-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: secretsh-0.1.5-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 483.1 kB
- Tags: PyPy, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0110c41161fdf5c21156b96c1cda3427ddb4dee585a2a1cae349a6cc26429007
|
|
| MD5 |
6e429e66d19b89b58a5ec54bae8ba13d
|
|
| BLAKE2b-256 |
d04079ca41305c6fcf90c2b4814860953513c46522bf17af1cfe288d972cc9c5
|
File details
Details for the file secretsh-0.1.5-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: secretsh-0.1.5-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 421.9 kB
- Tags: PyPy, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81a81c8c845f87b2afc40a8d54234f4c9a5f2c25dd11205c5699c528a492e75a
|
|
| MD5 |
e368d7044889727a6af6ea88206e0de4
|
|
| BLAKE2b-256 |
464eb987a6edcfed35e285c3dd3d0d6a1bde312ce4b2fa315eb5a7d9d4c55110
|
File details
Details for the file secretsh-0.1.5-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: secretsh-0.1.5-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 483.2 kB
- Tags: CPython 3.14, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7d8ed6aed50b0d489d549105d2add0120d039faf00376f8ce115b5adc85650e
|
|
| MD5 |
837237a711697c4c7c93c9200964bdb0
|
|
| BLAKE2b-256 |
f7f6eed67e9dfc685437796238b7050d701c52837a6542ab33c449f011ecb95f
|
File details
Details for the file secretsh-0.1.5-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: secretsh-0.1.5-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 421.0 kB
- Tags: CPython 3.14, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94c233209fe885830d21d0f5207ad7c075455b562afb5a3fe7fa03a3fcab67a6
|
|
| MD5 |
96e50495370909efca6718a955958a18
|
|
| BLAKE2b-256 |
5a62cb73d113a63f1fd277ebcf9391ca7cdeb8ed7d619488c5b12564f0077ea6
|
File details
Details for the file secretsh-0.1.5-cp314-cp314-macosx_11_0_arm64.whl.
File metadata
- Download URL: secretsh-0.1.5-cp314-cp314-macosx_11_0_arm64.whl
- Upload date:
- Size: 401.0 kB
- Tags: CPython 3.14, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8c34950024857569c4784ee008e24dddcb86aed2e58ae9956488755137ef77d
|
|
| MD5 |
8b3005245f126915aa455c51f980f105
|
|
| BLAKE2b-256 |
254ea16b5d6027c4cb2e74d9446f853993364838469fc2f248dd6741bfbd7f5c
|
File details
Details for the file secretsh-0.1.5-cp314-cp314-macosx_10_12_x86_64.whl.
File metadata
- Download URL: secretsh-0.1.5-cp314-cp314-macosx_10_12_x86_64.whl
- Upload date:
- Size: 461.5 kB
- Tags: CPython 3.14, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d63d826df2603f033ba5a64815cdc7f01998c28a509606e496dd669e8019f51
|
|
| MD5 |
6e4202b105904c9137d0dcaaa80e58e4
|
|
| BLAKE2b-256 |
179405ef4f739b5cc8a7f6122ca29fe21fa6b99a64de706bb610743bf58db17e
|
File details
Details for the file secretsh-0.1.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: secretsh-0.1.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 482.9 kB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ed2394c6af36177ac4d1e8c8a2ea6eae6b3af6403556992e914b805472da4e2
|
|
| MD5 |
ab14c84d4dcc74ab913b47170afe6ab0
|
|
| BLAKE2b-256 |
e982756e963e6befe847fcd0d91cfef7f8f3739f2eb773e8b62e94136ecfd1c4
|
File details
Details for the file secretsh-0.1.5-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: secretsh-0.1.5-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 421.0 kB
- Tags: CPython 3.13, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e95508f33a311f46af374e80e39b685a160878cf092fac1fb3b39298e1bedc93
|
|
| MD5 |
667ab190f34071ccbbe9f580efc00162
|
|
| BLAKE2b-256 |
f865d3e82851cf1906fb6c04d1b5da1e2878bdaf226a8c53cdae76effbf1d5a3
|
File details
Details for the file secretsh-0.1.5-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: secretsh-0.1.5-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 401.1 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6926f3034204e055ed6dd737ee2386305f68a7d1ca85d73b66734433a40e41c
|
|
| MD5 |
9329682b411c2c37397dded06a87384d
|
|
| BLAKE2b-256 |
d3347c66a007f978d985efbfc5fc9c5c78cb5a6525150dbc9cb3dd2343c9900c
|
File details
Details for the file secretsh-0.1.5-cp313-cp313-macosx_10_12_x86_64.whl.
File metadata
- Download URL: secretsh-0.1.5-cp313-cp313-macosx_10_12_x86_64.whl
- Upload date:
- Size: 461.5 kB
- Tags: CPython 3.13, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ef04f4bf0758948531f51595f24d21404215f5bda9bc065ed1dc036851de2e1
|
|
| MD5 |
1efce32e63bcc3df3eafd1e18089e4e7
|
|
| BLAKE2b-256 |
fd05f1a803d2b7526b351e0406f459ea44cb5aa479f19e1e6a7d6d2c62f5ce01
|
File details
Details for the file secretsh-0.1.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: secretsh-0.1.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 483.1 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
efabef8bea306f6e6e495295db1db06c0240191300d203f18f39d2e19e033f2e
|
|
| MD5 |
239b8c909a680e9132ce0da89ef7f04e
|
|
| BLAKE2b-256 |
317213980e1a8bc823d6117d71bac3b3fce3ea6c931af91a993e61548cabbf0c
|
File details
Details for the file secretsh-0.1.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: secretsh-0.1.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 421.7 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d0cd9acf97aa6e2a6fd58e9cfd135cb4a55be824b08f466f323c1a1426b04b0
|
|
| MD5 |
04f4eaba6081ccb935fa9feb4ae11322
|
|
| BLAKE2b-256 |
dc113f688b4bb056bc7aee1c929f6ae172cf221ee18545b3f319c9ddd4b7379d
|
File details
Details for the file secretsh-0.1.5-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: secretsh-0.1.5-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 401.4 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25641a02c1c3daf6a95baa13f6dcf802cb019edd4ff32495e7a5948bbe3c2cf0
|
|
| MD5 |
c6432ee49e6c26b844e7383d818a10d5
|
|
| BLAKE2b-256 |
dfc6647fc79199d95a259cb4f5a6542325e8733241cf5f67bb44938b706bf550
|
File details
Details for the file secretsh-0.1.5-cp312-cp312-macosx_10_12_x86_64.whl.
File metadata
- Download URL: secretsh-0.1.5-cp312-cp312-macosx_10_12_x86_64.whl
- Upload date:
- Size: 461.5 kB
- Tags: CPython 3.12, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd255db3bc1352eaa910467a76ad01c833640170ff0d9d53fcdbcbf1b8797fb8
|
|
| MD5 |
ddd0fc53f35c4c0f1461a84482a356b3
|
|
| BLAKE2b-256 |
43142ac6b4e11eb888180d6dfa3474b8b4c1d040155cce565195d0f5e56474d5
|
File details
Details for the file secretsh-0.1.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: secretsh-0.1.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 482.8 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
813cf18fc7888ba891be280ccebcdf3e92a9fb9fa46419f511acd38f32b9f4d3
|
|
| MD5 |
b2fdb2641c6f705837ab1278f2425f25
|
|
| BLAKE2b-256 |
39a4e0058ee350b23a59863c41cd7a020f46191834525c55a23932f9fb825bc1
|
File details
Details for the file secretsh-0.1.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: secretsh-0.1.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 421.5 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dca1e53dde59309406d857251c321281b7940d095304c8fb588cc0dd38cf0492
|
|
| MD5 |
d359364fed95011d2807bed21b2525ed
|
|
| BLAKE2b-256 |
23902abd94c68ae57374c80aad2de08beabf9882ac1303d9d38879948c5165b4
|
File details
Details for the file secretsh-0.1.5-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: secretsh-0.1.5-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 402.4 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2900bd183698a9f5825b22ceb91c5ae3d68625d2d1b2e30b8d3fdfbcd907f943
|
|
| MD5 |
22159a436d1457bdf2b1d77e8cfeae7d
|
|
| BLAKE2b-256 |
ffb1fbc4f89aac8ee4bb91b4d0837608bbd632c3dae9920c4b515cd5d035c122
|
File details
Details for the file secretsh-0.1.5-cp311-cp311-macosx_10_12_x86_64.whl.
File metadata
- Download URL: secretsh-0.1.5-cp311-cp311-macosx_10_12_x86_64.whl
- Upload date:
- Size: 463.0 kB
- Tags: CPython 3.11, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ece8898b679284feb8e00c5535c29c7102fd8a6470063490a2537dd5981a813e
|
|
| MD5 |
3c739f2c58f857f5426df7e1c2cd5a3b
|
|
| BLAKE2b-256 |
23bb9b74ac8332c25d414c1b7177e79da0a2c37019f45298e7b8379a26b5e7d8
|
File details
Details for the file secretsh-0.1.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: secretsh-0.1.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 482.7 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2830602dc7bd91b4878059a993ce49f5c94613a8570dc6b7aca0e9462204651
|
|
| MD5 |
aa5718e791c41d3bb839b25ecc0ba721
|
|
| BLAKE2b-256 |
e31f266f44bbc9f0832825fa6680d864afb9ffd8f326165ee8e93b3275b8bf5d
|
File details
Details for the file secretsh-0.1.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: secretsh-0.1.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 421.5 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d41298226c4744ec42b5dd5c49f4aae2e1f8d67c0709691565392ec06df05e75
|
|
| MD5 |
60df0f250dd0468c2dd3a366901e09ef
|
|
| BLAKE2b-256 |
c858efbaae098cab0d11ae6fa270b767b7a9fd9c2f2ea07a1c54fa51f9df095d
|