AstrBot-Desktop/docs/decisions/ADR-0003-rust-owned-native-security-boundary.md
YokiiroBW 353a439b41
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
docs(p00): record spike results and unresolved boundaries
2026-07-18 21:00:49 +08:00

2.3 KiB

ADR-0003: Keep Native Security-Critical Capabilities in Rust

  • Status: Accepted
  • Date: 2026-07-18
  • Scope: Credentials, diagnostics, local actions, and file transactions

Context

AstrBot Desktop needs Windows Credential Manager access, bounded diagnostics, UI Automation, window capture, event-log queries, and recoverable NAS file transactions. Remote model output, screen content, and file content are untrusted. Exposing generic operating-system execution or unrestricted paths would violate the project security model.

Options considered

  1. Expose broad filesystem or command APIs to React and enforce safety in the UI.
  2. Add a generic command runner and restrict it through prompts or string validation.
  3. Expose only typed, bounded Tauri commands backed by Rust policy checks and Windows-native APIs.

Decision

All credentials, operating-system inspection, local policy decisions, and filesystem mutations remain in Rust.

React receives only display-safe results, opaque credential references, bounded path-selection tokens, and explicit operation states. It never receives credential values or unrestricted filesystem access.

The product does not include a shell plugin or any generic PowerShell, CMD, shell, registry-write, keyboard-script, or arbitrary-path execution API.

Local actions follow schema validation, tool allowlisting, profile and slot validation, path-scope validation, risk classification, authorization, execution, and audit.

P00 NAS validation uses plan, dry run, temporary copy, size and SHA-256 verification, and atomic destination commit. Source files are preserved; source cleanup is represented only as a non-executed plan field.

Rationale

  • Makes security enforcement independent of UI state and remote prompts.
  • Limits the native attack surface to explicit operations.
  • Keeps secret values out of React, SQLite ordinary fields, logs, and snapshots.
  • Preserves source data during an interrupted or failed NAS operation.

Consequences

  • Windows-native behavior requires Windows-specific tests and cannot be certified by Linux CI.
  • Unsupported or elevated targets must fail safely without privilege escalation.
  • New native tools require an explicit schema, allowlist entry, risk level, tests, and audit behavior.
  • Destructive cleanup, updater signing, and broader desktop control require separate decisions and authorization.