Skip to main content

The Iron Vault - Secure Filesystem Agent Layer for Aperion

Project description

The Iron Vault - Aperion FSAL

The absolute boundary between AI agents and the underlying operating system.

Python 3.11+ FastAPI License: MIT

Overview

The Iron Vault is a hardened filesystem access layer that enforces Constitution B3 (Sandbox Boundaries) and guarantees file integrity via atomic operations. It serves as the exclusive I/O gateway for AI agents in the Aperion system.

Key Security Guarantees

  • ๐Ÿ”’ Sandbox Isolation: All paths are rigidly constrained to FSAL_ROOT
  • โš›๏ธ Atomic Writes: Write-temp-then-rename pattern with fsync prevents corruption
  • ๐Ÿšซ Traversal Prevention: ../, null bytes, symlinks, and absolute paths are blocked
  • ๐Ÿ”‘ Bearer Token Auth: Production mode enforces authentication
  • ๐Ÿ“‹ Audit Ready: Structured logging for all operations

Quick Start

Installation

pip install aperion-fsal

# From source
pip install -e .

# With dev dependencies
pip install -e ".[dev]"

Running the Service

# Development mode (CWD fallback allowed)
APERION_ENV=dev aperion-fsal

# Production mode (FSAL_ROOT required)
FSAL_ROOT=/data/sandbox FSAL_TOKEN=secret aperion-fsal

Docker

# Build
docker build -t aperion-fsal .

# Run
docker run -d -p 4848:4848 \
  -e FSAL_TOKEN=your-secret-token \
  -v /path/to/sandbox:/data \
  aperion-fsal

API Reference

All endpoints require Bearer token authentication when FSAL_TOKEN is set.

Endpoint Method Description
/healthz GET Health check
/metrics GET Prometheus metrics
/auth/status GET Auth configuration (public)
/v1/fs/list POST List directory contents (supports recursive)
/v1/fs/read POST Read file content
/v1/fs/write POST Write file (base64 encoded)
/v1/fs/move POST Move/rename file or directory
/v1/fs/copy POST Copy file or directory
/v1/fs/mkdir POST Create directory
/v1/fs/delete POST Delete file or directory
/v1/fs/hash POST Calculate file hash
/v1/fs/exists POST Check if path exists
/v1/fs/stat POST Get detailed file/directory info

Example: Write a File

curl -X POST http://localhost:4848/v1/fs/write \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-token" \
  -d '{
    "path": "hello.txt",
    "content_b64": "SGVsbG8sIFdvcmxkIQ==",
    "make_dirs": true
  }'

Example: Read a File

curl -X POST http://localhost:4848/v1/fs/read \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-token" \
  -d '{
    "path": "hello.txt",
    "as_text": true
  }'

Environment Variables

Variable Required Default Description
FSAL_ROOT Yes (prod) CWD (dev) Sandbox root directory
FSAL_TOKEN Recommended None Bearer token for authentication
FSAL_HOST No 127.0.0.1 Host to bind to
FSAL_PORT No 4848 Port to listen on
APERION_ENV No production Set to dev for development mode
FSAL_MAX_FILE_SIZE No 104857600 Max file size in bytes (100MB)
FSAL_MIN_FREE_SPACE No 104857600 Min free disk space required (100MB)
FSAL_REQUEST_TIMEOUT No 30 Request timeout in seconds
FSAL_TRACING_ENABLED No false Enable OpenTelemetry tracing

Security Model

Asymmetric Behavior (Constitution B)

  • Server: Logs warning if FSAL_TOKEN not set, but allows startup in dev mode
  • Client/Scripts: Must fail immediately if tokens are missing

Sandbox Enforcement

  1. All paths are normalized to relative paths
  2. Absolute paths have their root stripped
  3. .. components are resolved BEFORE path construction
  4. Symlinks are rejected by default
  5. Null bytes in paths are always rejected
  6. FSAL_ROOT MUST be set in production mode

Atomic Write Guarantee

1. Write to temp file in SAME directory as target
2. fsync() to ensure data hits disk
3. Atomic rename() to move temp to target
4. Cleanup temp file in finally block

This guarantees that on power loss:

  • Either the OLD content is preserved, OR
  • The NEW content is fully written
  • Never a partial/corrupt file

Testing

# Run all tests
pytest

# Run with coverage
pytest --cov=aperion_fsal --cov-report=html

# Run security tests only
pytest tests/security/

# Run unit tests only
pytest tests/unit/

Development

# Install dev dependencies
pip install -e ".[dev]"

# Run linter
ruff check src/

# Run type checker
mypy src/

# Format code
ruff format src/

Project Structure

aperion-fsal/
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ aperion_fsal/
โ”‚       โ”œโ”€โ”€ __init__.py
โ”‚       โ”œโ”€โ”€ core/
โ”‚       โ”‚   โ”œโ”€โ”€ safeio.py      # The atomic I/O kernel
โ”‚       โ”‚   โ””โ”€โ”€ sandbox.py     # Path resolution & traversal prevention
โ”‚       โ”œโ”€โ”€ service/
โ”‚       โ”‚   โ”œโ”€โ”€ app.py         # FastAPI application
โ”‚       โ”‚   โ”œโ”€โ”€ models.py      # Pydantic schemas
โ”‚       โ”‚   โ””โ”€โ”€ auth.py        # Token validation logic
โ”‚       โ””โ”€โ”€ main.py            # Entry point
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ conftest.py
โ”‚   โ”œโ”€โ”€ unit/
โ”‚   โ”‚   โ””โ”€โ”€ test_safeio.py
โ”‚   โ””โ”€โ”€ security/
โ”‚       โ””โ”€โ”€ test_traversal.py  # Red Team attacks
โ”œโ”€โ”€ pyproject.toml
โ”œโ”€โ”€ Dockerfile
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ ref/                       # Reference documentation
    โ”œโ”€โ”€ GAP_ANALYSIS.md        # Security gaps & improvements
    โ”œโ”€โ”€ SECURITY_BEST_PRACTICES.md
    โ”œโ”€โ”€ INTEGRATION_GUIDE.md   # Aperion integration
    โ”œโ”€โ”€ IMPLEMENTATION_ROADMAP.md
    โ””โ”€โ”€ KNOWN_ISSUES.md

Reference Documentation

The /ref directory contains detailed documentation for development and integration:

Document Description
GAP_ANALYSIS.md Security gaps and prioritized improvements
SECURITY_BEST_PRACTICES.md Industry security guidance and citations
INTEGRATION_GUIDE.md How to integrate with Aperion Legendary AI
IMPLEMENTATION_ROADMAP.md Phased implementation plan with code samples
KNOWN_ISSUES.md Current bugs, edge cases, and limitations

License

MIT License - see LICENSE for details.


"Trust but verify." - The Iron Vault

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aperion_fsal-1.2.2.tar.gz (68.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aperion_fsal-1.2.2-py3-none-any.whl (37.2 kB view details)

Uploaded Python 3

File details

Details for the file aperion_fsal-1.2.2.tar.gz.

File metadata

  • Download URL: aperion_fsal-1.2.2.tar.gz
  • Upload date:
  • Size: 68.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aperion_fsal-1.2.2.tar.gz
Algorithm Hash digest
SHA256 a4a520e28f1e27c95fb7a3e2abd1f09be7b6f6151b84050408cda64c2f27e933
MD5 8e3336fa0f41f72ddf86ad9b0f553e9a
BLAKE2b-256 f14017d74b50356caf80f2a5fec54210b8f60aab6c78db2f64bc67042b287493

See more details on using hashes here.

Provenance

The following attestation bundles were made for aperion_fsal-1.2.2.tar.gz:

Publisher: release.yml on invictustitan2/aperion-fsal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aperion_fsal-1.2.2-py3-none-any.whl.

File metadata

  • Download URL: aperion_fsal-1.2.2-py3-none-any.whl
  • Upload date:
  • Size: 37.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aperion_fsal-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3d163ec8e7a7ac3d528bf5416f39073a1c6beab7a214113e17adc20f51dbca2c
MD5 8225a1a1f42f6ffcf9b58501f62d3dca
BLAKE2b-256 43ee09fd27c03c49d482a76d5655d2ba71af885525cff427ea7308dc314d3fc8

See more details on using hashes here.

Provenance

The following attestation bundles were made for aperion_fsal-1.2.2-py3-none-any.whl:

Publisher: release.yml on invictustitan2/aperion-fsal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page