Repository navigation
Closed
Description
Overview
Implement the security layer for NodeSpace including ABAC (Attribute-Based Access Control), RLS (Row-Level Security), and encryption strategy. This prepares NodeSpace for cloud sync while maintaining local-first security.
Architecture Reference
See docs/architecture/architecture-target-state.md Section 5: Security & Access
Components
1. ABAC with Key-Ring Pattern
Permissions compiled onto User record for O(1) lookups:
user: {
id: "user-123",
role: "member",
type_grants: {
"task": "write",
"invoice": "read",
"hr_*": "none"
}
}2. Row-Level Security (RLS)
Cloud database enforces security before data leaves the server:
DEFINE TABLE node SCHEMAFULL
PERMISSIONS
FOR select, update, delete WHERE
$auth.role = 'owner'
OR ($auth.type_grants[node_type] != NONE);3. Type Field Protection
Prevent permission bypass via type mutation:
DEFINE FIELD node_type ON node TYPE string
PERMISSIONS FOR update WHERE $auth.role = 'admin' OR node_type = $value;4. Encryption Strategy
| Layer | Approach |
|---|---|
| Local DB | Rely on OS encryption (FileVault, BitLocker) |
| Secrets | OS Keychain (macOS Keychain, Windows Credential Manager) |
| In transit | TLS 1.2+ via SurrealDB Cloud |
| Exports | Optional AES-256 encryption with user password |
Acceptance Criteria
Phase 1: Local Security
- OS Keychain integration for storing secrets (Tauri plugin)
- Secure storage for API keys, cloud tokens
- No plaintext secrets in config files or logs
Phase 2: ABAC Implementation
- User record with
roleandtype_grantsfields - Key-Ring pattern for O(1) permission lookups
- Type grant wildcards (
hr_*) supported
Phase 3: RLS Definitions
- PERMISSIONS clauses on
nodetable - PERMISSIONS clauses on
edgetable - Type field protection (prevent mutation for permission bypass)
- Schema nodes protected (admin-only modification)
Phase 4: Export Encryption
- Optional password-protected export
- Argon2id key derivation
- AES-256-GCM encryption
- Clear UX warnings about password recovery
Phase 5: Quality
- Security tests (permission bypass attempts)
- Code passes
bun run quality:fix - Tests pass (
bun run test:all) - Documentation updated
Technical Notes
OS Keychain Integration
Use Tauri's keyring plugin or platform-specific APIs:
- macOS: Security.framework / Keychain Services
- Windows: Credential Manager
- Linux: libsecret / Secret Service API
Why Not Custom DB Encryption
- Key management complexity
- Potential data loss from forgotten passwords
- OS-level encryption is transparent and hardware-accelerated
- Industry standard (Notion, Obsidian don't encrypt local DBs either)
Dependencies
- SurrealDB Cloud PoC (validates RLS works as expected)
Related Issues
- Sync Policy Infrastructure #784 - Sync Policy Infrastructure
- Policy Evaluation Engine #785 - Policy Evaluation Engine
- Epic Epic: Universal Graph Architecture Transition #783 - Universal Graph Architecture (closed, but related context)
Activity
docs: Add encryption strategy and expand backup section
docs: Add encryption strategy and expand backup section
docs: Add encryption strategy and expand backup section
malibio commentedon May 18, 2026
Implementation of this feature belongs in the nodespace-sync repo (nodespace-pro). Architecture and technical decisions are documented in nodespace-docs: see ADR-025 (cloud sync architecture with Stamped ACL), ADR-017 (sync strategy), and architecture/cloud-sync.md. Closing in nodespace-core.