Skip to content

Security Layer: ABAC, RLS, and Encryption #789

Closed

Description

@malibio

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 role and type_grants fields
  • Key-Ring pattern for O(1) permission lookups
  • Type grant wildcards (hr_*) supported

Phase 3: RLS Definitions

  • PERMISSIONS clauses on node table
  • PERMISSIONS clauses on edge table
  • 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

Activity

  1. malibio commented on May 18, 2026

    @malibio
    CollaboratorAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions