Bilinc implements defense-in-depth security for memory operations.
All inputs pass through InputValidator before reaching the storage layer:
from bilinc.security.validator import InputValidator
# Key validation
key = InputValidator.validate_key("my_memory_key")
# Allowed: alphanumeric, hyphens, underscores, dots, colons
# Max length: 256 characters
# Value validation
value = InputValidator.validate_value({"data": "sensitive_content"})
# Check: JSON serializable, max 1MB
# Sanitization for KGraph node names
clean = InputValidator.sanitize_for_kg("<script>alert('xss')</script>RealNode")
# Result: "alert('xss')RealNode" (tags removed)- Path Traversal:
../,/tmp/evil,\etc\passwd - XSS Injection:
<script>,javascript:,<style> - Null Bytes:
\x00injection - Empty Keys:
""," ",None
| Resource | Limit | Action on Exceed |
|---|---|---|
| Working Memory | 16 entries | Reject new commits |
| Episodic | 50,000 entries | Reject new commits |
| Semantic | 25,000 entries | Reject new commits |
| KG Nodes | 100,000 | Reject new nodes |
| KG Edges | 500,000 | Reject new edges |
| Value Size | 1MB | Reject commit |
| Audit Log | 1,000,000 entries | Rotation recommended |
Enable API key authentication for MCP servers:
export STATEMEL_API_KEY="your-secure-key-here"from bilinc.mcp_server.server_v2 import create_mcp_server_v2
server = create_mcp_server_v2(plane, auth_token="your-secure-key-here")Authentication uses constant-time comparison (hmac.compare_digest) to prevent timing attacks.
Default: 10 requests burst, 1 request/second refill per client.
server = create_mcp_server_v2(plane, max_tokens=20, refill_rate=2.0)When enable_audit=True, every operation is logged to a Merkle chain:
plane = StatePlane(enable_audit=True)
# All creates, updates, deletions, consolidations → audit trailThe audit trail includes:
- Timestamp
- Operation type (CREATE, UPDATE, DELETE, CONSOLIDATE)
- Key and value diff
- Source identifier
- Always validate keys: Use
InputValidator.validate_key()for user-provided keys. - Enable audit in production:
enable_audit=Truefor compliance. - Set appropriate API keys: Rotate
STATEMEL_API_KEYperiodically. - Monitor metrics: Use
/healthendpoint to detect anomalies. - Backup database: Regular SQLite/PostgreSQL backups for persistent storage.