cryptex-ai

πŸ” Cryptex - Temporal Isolation Engine for AI/LLM Applications. Bulletproof secrets isolation middleware for FastMCP servers and FastAPI applications.

https://github.com/anthemflynn/cryptex-ai

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
Last synced: 6 months ago · JSON representation ·

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
Created 8 months ago · Last pushed 6 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation Security Authors

README.md

Cryptex-AI

**Zero-config temporal isolation for AI/LLM applications** *Bulletproof secrets isolation with zero cognitive overhead* [![Package](https://img.shields.io/pypi/v/cryptex-ai?label=PyPI)](https://pypi.org/project/cryptex-ai/) [![Python Support](https://img.shields.io/pypi/pyversions/cryptex-ai)](https://pypi.org/project/cryptex-ai/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![CI](https://github.com/AnthemFlynn/cryptex-ai/actions/workflows/main.yml/badge.svg)](https://github.com/AnthemFlynn/cryptex-ai/actions) [![Coverage](https://codecov.io/gh/AnthemFlynn/cryptex-ai/branch/main/graph/badge.svg)](https://codecov.io/gh/AnthemFlynn/cryptex-ai) [**Documentation**](https://anthemflynn.github.io/cryptex-ai/) | [**Examples**](./examples/) | [**PyPI**](https://pypi.org/project/cryptex-ai/) | [**Changelog**](./CHANGELOG.md)

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:

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

**Made with ❀️ for the AI/LLM community** [⭐ Star us on GitHub](https://github.com/AnthemFlynn/cryptex-ai) | [πŸ“– Read the Docs](https://anthemflynn.github.io/cryptex-ai/) | [πŸ’¬ Join Discussions](https://github.com/AnthemFlynn/cryptex-ai/discussions)

Owner

  • Login: AnthemFlynn
  • Kind: user

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

  • Versions: 4
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 45 Last month
Rankings
Dependent packages count: 8.8%
Average: 29.2%
Dependent repos count: 49.6%
Maintainers (1)
Last synced: 6 months ago

Dependencies

.github/workflows/ci.yml actions
  • 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
.github/workflows/codeql.yml actions
  • 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
.github/workflows/dependency-review.yml actions
  • actions/checkout v4 composite
  • actions/dependency-review-action v4 composite
.github/workflows/pre-release.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v5 composite
  • astral-sh/setup-uv v4 composite
  • peter-evans/create-pull-request v6 composite
.github/workflows/release.yml actions
  • 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
.github/workflows/update-deps.yml actions
  • 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
examples/fastapi/requirements.txt pypi
  • 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
examples/fastmcp/requirements.txt pypi
  • 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
pyproject.toml pypi
  • typing-extensions >=4.8.0