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.1.tar.gz (67.9 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.1-py3-none-any.whl (37.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aperion_fsal-1.2.1.tar.gz
  • Upload date:
  • Size: 67.9 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.1.tar.gz
Algorithm Hash digest
SHA256 8048dfdcd5c96bd608b38fb01a3ae86d957eddb421e6d886065155d177cb5bea
MD5 7ded8a15c59102946240fe97f237b913
BLAKE2b-256 ca443f3af88c8024abf2edc598ac09493f4109735802780573e61ad1d781971e

See more details on using hashes here.

Provenance

The following attestation bundles were made for aperion_fsal-1.2.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: aperion_fsal-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 37.3 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 68c29e30d863e391084f23f883ea4aa857a5b6083076f826708223df85e7c2df
MD5 844d37a78474aae5f0f6b531f28fdd79
BLAKE2b-256 a64e4632ce4c6094daf1dc45d16d39cacb49ef8896250211bc35508edc6e46bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for aperion_fsal-1.2.1-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