cryptex-ai
π Cryptex - Temporal Isolation Engine for AI/LLM Applications. Bulletproof secrets isolation middleware for FastMCP servers and FastAPI applications.
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
βCITATION.cff file
Found CITATION.cff file -
βcodemeta.json file
Found codemeta.json file -
β.zenodo.json file
Found .zenodo.json file -
βDOI references
-
βAcademic publication links
-
βAcademic email domains
-
βInstitutional organization owner
-
βJOSS paper metadata
-
βScientific vocabulary similarity
Low similarity (14.4%) to scientific vocabulary
Repository
π Cryptex - Temporal Isolation Engine for AI/LLM Applications. Bulletproof secrets isolation middleware for FastMCP servers and FastAPI applications.
Basic Info
- Host: GitHub
- Owner: AnthemFlynn
- License: mit
- Language: Python
- Default Branch: main
- Size: 672 KB
Statistics
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 2
- Releases: 5
Metadata Files
README.md
Cryptex-AI
The Problem
AI/LLM applications face an impossible choice: - Expose secrets to AI β Security nightmare π - Hide secrets completely β Broken functionality π₯
The Solution
Cryptex-ai provides true temporal isolation - AI services receive safe placeholders while your functions use real secrets through automatic call interception.
```python from cryptexai import protectsecrets
Works immediately - no config files required!
@protectsecrets(["openaikey"]) async def aitool(prompt: str, apikey: str) -> str: # Function receives: real API key for processing # AI service receives: {{OPENAIAPIKEY}} (intercepted) import openai return await openai.chat.completions.create( model="gpt-4", messages=[{"role": "user", "content": prompt}], apikey=apikey # Real key for function, placeholder to AI ) ```
One decorator line = complete temporal isolation β¨
π Key Features
- π§ Zero Configuration: Works immediately, no setup required
- β‘ Built-in Patterns: OpenAI, Anthropic, GitHub, file paths, databases
- π‘οΈ Security First: Zero dependencies, no config files, no parsing vulnerabilities
- π High Performance: <5ms sanitization, <10ms resolution
- π Universal: Works with any Python function - FastMCP, FastAPI, Django, Flask, etc.
- π― True Isolation: Monkey-patches AI libraries to intercept actual calls
- π Simple API: 95% of users need zero config, 5% get simple registration
π¦ Installation
Using pip (recommended)
bash
pip install cryptex-ai
Using uv (modern Python package manager)
bash
uv add cryptex-ai
Requirements: Python 3.11+ β’ Zero dependencies
β‘ Quick Start
Zero-Config Protection (95% of users)
Cryptex works immediately with built-in patterns for common secrets:
```python from cryptexai import protectsecrets
Protect OpenAI API calls
@protectsecrets(["openaikey"]) async def aicompletion(prompt: str, apikey: str) -> str: # AI context: "{{OPENAIAPIKEY}}" # Function execution: "sk-real-key-here..." return await openai.chat.completions.create( model="gpt-4", messages=[{"role": "user", "content": prompt}], apikey=apikey )
Protect file operations
@protectsecrets(["filepath"]) async def readfile(filepath: str) -> str: # AI context: "/{USERHOME}/.../{filename}" # Function execution: "/Users/alice/secrets/document.txt" with open(filepath, 'r') as f: return f.read()
Protect multiple secrets at once
@protectsecrets(["githubtoken", "filepath", "databaseurl"]) async def processdata(repopath: str, token: str, dburl: str) -> dict: # All secrets automatically protected data = await fetchfromgithub(repopath, token) result = await processaidata(data) await savetodatabase(result, db_url) return result ```
Convenience Decorators
For common patterns, use convenience decorators:
```python from cryptexai import protectapikeys, protectfiles, protect_all
@protectapikeys() # Protects OpenAI + Anthropic keys async def aifunction(openaikey: str, anthropic_key: str) -> str: # Both API keys automatically protected pass
@protectfiles() # Protects file system paths async def filefunction(file_path: str) -> str: # File paths automatically protected pass
@protectall() # Protects all built-in patterns async def comprehensivefunction(apikey: str, filepath: str, db_url: str) -> str: # Everything automatically protected pass ```
π οΈ Built-in Patterns
Cryptex includes battle-tested patterns that handle 95% of real-world usage:
| Pattern | Detects | Example | Placeholder |
|---------|---------|---------|-------------|
| openai_key | OpenAI API keys | sk-... | {{OPENAI_API_KEY}} |
| anthropic_key | Anthropic API keys | sk-ant-... | {{ANTHROPIC_API_KEY}} |
| github_token | GitHub tokens | ghp_... | {{GITHUB_TOKEN}} |
| file_path | User file paths | /Users/..., /home/... | /{USER_HOME}/.../{filename} |
| database_url | Database URLs | postgres://..., mysql://... | {{DATABASE_URL}} |
No configuration required - patterns work out of the box! π¦
π§ Custom Patterns (Advanced - 5% of users)
For edge cases, register custom patterns programmatically:
```python from cryptexai import registerpattern, protect_secrets
Register custom pattern once
registerpattern( name="slacktoken", regex=r"xoxb-[0-9-a-zA-Z]{51}", placeholder="{{SLACK_TOKEN}}", description="Slack bot token" )
Use immediately in decorators
@protectsecrets(["slacktoken"]) async def slackintegration(token: str) -> str: return await slackapi_call(token)
Bulk registration
from cryptexai import registerpatterns registerpatterns([ ("discord_token", r"[MNO][A-Za-z\d]{23}.[\w-]{6}.[\w-]{27}", "{{DISCORDTOKEN}}"), ("customkey", r"myapp-[a-f0-9]{32}", "{{CUSTOMKEY}}") ]) ```
ποΈ Framework Examples
FastMCP Tools
```python from fastmcp import FastMCPServer from cryptexai import protectsecrets
server = FastMCPServer("my-server")
@server.tool() @protectsecrets(["openaikey"]) async def aitool(prompt: str, apikey: str) -> str: # MCP sees: aitool("Hello", "{{OPENAIAPIKEY}}") # Tool gets: real API key for execution return await openaicall(prompt, api_key) ```
FastAPI Endpoints
```python from fastapi import FastAPI from cryptexai import protectsecrets
app = FastAPI()
@app.post("/api/process") @protectsecrets(["databaseurl", "openaikey"]) async def processendpoint(data: dict, dburl: str, apikey: str): # Request/response logs show placeholders # Endpoint gets real secrets for execution return await processwithsecrets(data, dburl, apikey) ```
Django Views
```python from django.http import JsonResponse from cryptexai import protectsecrets
@protectsecrets(["databaseurl"]) async def djangoview(request, dburl: str): # Django logs show placeholders # View gets real database URL return JsonResponse(await querydatabase(dburl)) ```
Any Python Function
```python from cryptexai import protectsecrets
@protectsecrets(["githubtoken"]) def syncfunction(token: str) -> str: # Works with sync functions too! return githubapi_call(token)
@protectsecrets(["openaikey"]) async def asyncfunction(apikey: str) -> str: # And async functions return await openaicall(apikey) ```
β‘ Performance
Cryptex is designed for production workloads:
| Metric | Performance | Context | |--------|-------------|---------| | Sanitization | <5ms | 1KB payloads | | **Resolution** | <10ms | 10 placeholders | | **Memory Overhead** | <5% | vs unprotected apps | | **Startup Time** | 0ms | Zero dependencies | | **Throughput** | >1000 req/s | Typical workloads |
Benchmarked on MacBook Pro M1, Python 3.11
ποΈ Architecture
Three-Phase Temporal Isolation
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Raw Secrets β β AI Processing β β Tool Execution β
β β β β β β
β sk-abc123... βββββΆβ {{OPENAI_KEY}} βββββΆβ sk-abc123... β
β /Users/alice/ β β /{USER_HOME}/ β β /Users/alice/ β
β ghp_xyz789... β β {{GITHUB_TOKEN}} β β ghp_xyz789... β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
Phase 1: Phase 2: Phase 3:
Sanitization AI sees safe Resolution for
for AI context placeholders tool execution
Zero-Config Philosophy
- π« No Attack Surface: No config files to inject, no parsing to exploit
- β‘ Lightning Fast: Zero file I/O, zero parsing overhead
- π― Decorator Focused: Lightweight, predictable, zero dependencies
- π¨βπ» Developer Friendly: Works immediately, no setup friction
- π Security First: Configuration in version-controlled code only
π Examples
Explore comprehensive examples in the examples/ directory:
- Basic Usage: Zero-config protection patterns
- FastAPI Integration: Web API protection
- Real World Usage: Complex multi-pattern scenarios
Run examples locally:
```bash git clone https://github.com/AnthemFlynn/cryptex-ai.git cd cryptex-ai
See working temporal isolation
python simplelivetest.py
Compare protected vs unprotected
python comparison_test.py
Run basic examples
python examples/basic_usage.py ```
π‘οΈ Security
Cryptex follows security-first principles:
- Zero Dependencies: No external packages, no supply chain attacks
- Zero Config Files: No TOML parsing, no injection attacks
- Minimal Attack Surface: No file I/O, pure Python standard library
- Secure by Default: Built-in patterns tested against real-world secrets
- Audit Trail: Full temporal isolation with context tracking
- Pattern Validation: Runtime regex validation and comprehensive error handling
Security Policy: See SECURITY.md for vulnerability reporting.
π§ͺ Testing
Using pip
```bash
Install dependencies
pip install -e ".[dev]"
Run test suite
make test
Run with coverage
make test-coverage
Performance benchmarks
make test-performance
Security tests
make test-security ```
Using uv
```bash
Install dependencies
uv sync --dev
Run test suite
uv run make test
Run with coverage
uv run make test-coverage
Performance benchmarks
uv run make test-performance
Security tests
uv run make test-security ```
π€ Contributing
We welcome contributions! Cryptex follows a zero-config philosophy - keep it simple.
Quick Development Setup
```bash
Install uv first (if not already installed)
curl -LsSf https://astral.sh/uv/install.sh | sh
Clone and set up the project
git clone https://github.com/AnthemFlynn/cryptex-ai.git cd cryptex-ai make dev-setup # Creates venv and installs dependencies with uv make test # Run test suite make lint # Code quality checks make format # Code formatting ```
Development Guidelines
- Zero-Config First: No configuration files in middleware libraries
- Security First: Every change requires security review
- Performance Matters: <5ms sanitization, <10ms resolution
- Test Everything: Every bug gets a test, every feature gets tests
- SOLID Principles: Clean architecture and abstractions
See CONTRIBUTING.md for detailed guidelines.
π Roadmap
- v0.3.1 β : Repository migration, documentation site, CI/CD improvements
- v0.4.0: Enhanced pattern validation and error reporting
- v0.5.0: Advanced caching and performance optimizations
- v0.6.0: Plugin system for custom secret sources
- v1.0.0: Production hardening and stability guarantees
π License
MIT License - see LICENSE file for details.
π Acknowledgments
- FastMCP Community: For excellent MCP server patterns
- FastAPI: For inspiring clean API design
- Python Community: For async/await and type system excellence
- Security Researchers: For temporal isolation concepts
Owner
- Login: AnthemFlynn
- Kind: user
- Repositories: 1
- Profile: https://github.com/AnthemFlynn
Citation (CITATION.cff)
cff-version: 1.2.0
message: "If you use this software, please cite it as below."
type: software
title: "Cryptex: Bulletproof Secrets Isolation for AI/LLM Applications"
abstract: "Cryptex provides temporal isolation that allows AI to process data safely while ensuring secrets are only resolved during execution. It implements a three-phase security architecture: Sanitization β AI Processing β Secret Resolution."
authors:
- name: "Cryptex Team"
version: "1.0.0"
date-released: "2024-07-16"
url: "https://github.com/AnthemFlynn/cryptex"
repository-code: "https://github.com/AnthemFlynn/cryptex"
license: MIT
keywords:
- ai
- llm
- security
- secrets
- isolation
- temporal-isolation
- middleware
- fastapi
- fastmcp
- mcp
preferred-citation:
type: software
title: "Cryptex: Bulletproof Secrets Isolation for AI/LLM Applications"
authors:
- name: "Cryptex Team"
version: "1.0.0"
url: "https://github.com/AnthemFlynn/cryptex"
year: 2024
GitHub Events
Total
- Create event: 4
- Issues event: 8
- Release event: 4
- Delete event: 5
- Issue comment event: 8
- Push event: 21
- Pull request event: 3
Last Year
- Create event: 4
- Issues event: 8
- Release event: 4
- Delete event: 5
- Issue comment event: 8
- Push event: 21
- Pull request event: 3
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 5
- Total pull requests: 12
- Average time to close issues: about 15 hours
- Average time to close pull requests: 1 day
- Total issue authors: 1
- Total pull request authors: 2
- Average comments per issue: 1.0
- Average comments per pull request: 1.67
- Merged pull requests: 3
- Bot issues: 0
- Bot pull requests: 8
Past Year
- Issues: 5
- Pull requests: 12
- Average time to close issues: about 15 hours
- Average time to close pull requests: 1 day
- Issue authors: 1
- Pull request authors: 2
- Average comments per issue: 1.0
- Average comments per pull request: 1.67
- Merged pull requests: 3
- Bot issues: 0
- Bot pull requests: 8
Top Authors
Issue Authors
- AnthemFlynn (5)
Pull Request Authors
- dependabot[bot] (8)
- AnthemFlynn (4)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 45 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 4
- Total maintainers: 1
pypi.org: cryptex-ai
Zero-config temporal isolation for AI/LLM applications - Bulletproof secrets isolation with zero cognitive overhead
- Homepage: https://github.com/AnthemFlynn/cryptex-ai
- Documentation: https://anthemflynn.github.io/cryptex-ai/
- License: MIT
-
Latest release: 0.3.3
published 7 months ago
Rankings
Maintainers (1)
Dependencies
- actions/checkout v4 composite
- actions/setup-python v5 composite
- actions/upload-artifact v4 composite
- astral-sh/setup-uv v4 composite
- codecov/codecov-action v4 composite
- actions/checkout v4 composite
- actions/setup-python v5 composite
- astral-sh/setup-uv v4 composite
- github/codeql-action/analyze v3 composite
- github/codeql-action/init v3 composite
- actions/checkout v4 composite
- actions/dependency-review-action v4 composite
- actions/checkout v4 composite
- actions/setup-python v5 composite
- astral-sh/setup-uv v4 composite
- peter-evans/create-pull-request v6 composite
- actions/checkout v4 composite
- actions/setup-python v5 composite
- astral-sh/setup-uv v4 composite
- pypa/gh-action-pypi-publish release/v1 composite
- softprops/action-gh-release v2 composite
- actions/checkout v4 composite
- actions/github-script v7 composite
- actions/setup-python v5 composite
- actions/upload-artifact v4 composite
- astral-sh/setup-uv v4 composite
- aiocache >=0.12.0
- aiofiles >=23.0.0
- aiohttp >=3.8.0
- aioredis >=2.0.0
- alembic >=1.12.0
- anthropic >=0.7.0
- asyncpg >=0.29.0
- azure-storage-blob >=12.19.0
- bcrypt >=4.0.0
- black >=23.0.0
- boto3 >=1.29.0
- cachetools >=5.3.0
- celery >=5.3.0
- cryptex >=1.0.0
- cryptography >=41.0.0
- fastapi >=0.104.0
- fastapi-mail >=1.4.0
- fastapi-socketio >=0.0.10
- flower >=2.0.0
- google-cloud-storage >=2.10.0
- httpx >=0.25.0
- mkdocs >=1.5.0
- mkdocs-material >=9.4.0
- motor >=3.3.0
- openai >=1.0.0
- opentelemetry-api >=1.20.0
- opentelemetry-sdk >=1.20.0
- orjson >=3.9.0
- passlib >=1.7.0
- prometheus-client >=0.16.0
- psycopg2-binary >=2.9.0
- pydantic >=2.0.0
- pydantic-settings >=2.0.0
- pymongo >=4.3.0
- pytest >=7.0.0
- pytest-asyncio >=0.21.0
- pytest-cov >=4.0.0
- python-dotenv >=1.0.0
- python-jose >=3.3.0
- python-multipart >=0.0.6
- python-oauth2 >=1.1.0
- python-socketio >=5.9.0
- redis >=4.5.0
- ruff >=0.1.0
- sqlalchemy >=2.0.0
- starlette >=0.27.0
- structlog >=23.0.0
- toml >=0.10.0
- uvicorn >=0.24.0
- websockets >=11.0.0
- aiofiles >=23.0.0
- aiohttp >=3.8.0
- anthropic >=0.7.0
- asyncio-mqtt >=0.11.0
- black >=23.0.0
- cryptex >=1.0.0
- cryptography >=41.0.0
- openai >=1.0.0
- passlib >=1.7.0
- prometheus-client >=0.16.0
- psutil >=5.9.0
- psycopg2-binary >=2.9.0
- pydantic >=2.0.0
- pymongo >=4.3.0
- pytest >=7.0.0
- pytest-asyncio >=0.21.0
- pytest-cov >=4.0.0
- python-dotenv >=1.0.0
- python-jose >=3.3.0
- redis >=4.5.0
- ruff >=0.1.0
- structlog >=23.0.0
- toml >=0.10.0
- typing-extensions >=4.8.0