Skip to content

Security Model

Federico Conticello edited this page Mar 25, 2026 · 4 revisions

Security Model

FerrisPad plugins run in a sandboxed environment with strict resource limits and permission controls.

Lua Sandbox

The following Lua standard libraries are removed from the plugin environment:

  • os — no OS-level access
  • io — no direct file I/O (use the Filesystem API instead)
  • debug — no debug introspection
  • loadfile, dofile, require, load — no dynamic code loading
  • package — no module system

Available standard libraries:

  • string, table, math — data manipulation
  • pairs, ipairs, next, select — iteration
  • type, tonumber, tostring — type conversion
  • pcall, xpcall, error, assert — error handling
  • print — output (goes to stderr)
  • rawget, rawset, getmetatable, setmetatable — table access

Forbidden: Any access to the global table _G is prohibited. All plugins share one Lua runtime, and modifying _G can break other plugins. The static scanner blocks rawset(_G, ...) and rawget(_G, ...) automatically. Direct _G access (e.g., _G.foo = bar) is caught during security review. See Plugin Lifecycle for details.

Resource Limits

Resource Limit On Exceed
Instructions per hook call 1,000,000 Hook aborted, error logged, plugin stays loaded
Memory per plugin 16 MB Hook aborted (Lua allocator error), plugin stays loaded
Command execution timeout 30 seconds Process killed (SIGKILL on Unix, taskkill on Windows)

Instruction count is checked every 1,000 instructions to minimize overhead.

Filesystem Sandbox

All filesystem operations are restricted to the project root directory:

  • Relative paths are resolved against the project root
  • Absolute paths must be within the project root or they are rejected
  • Path traversal (../../../etc/passwd) is blocked — paths are canonicalized and verified
  • Symlinks are resolved to their real path before validation
  • Write operations fail if the target is outside the sandbox

Command Execution Security

Permission Flow

  1. Plugin declares commands in plugin.toml under [permissions] execute
  2. First time a plugin tries to run a command, FerrisPad shows an approval dialog
  3. User can Allow or Deny
  4. Decision is remembered per-plugin in settings

Argument Validation

All command arguments are checked for shell injection characters. These are blocked:

; & | ` $ ( ) { } < > \n \r \ * ? [ ]

This prevents plugins from constructing shell commands that escape the intended execution.

Trust Tiers

Official Plugins

  • Cryptographically signed with ed25519
  • Signature covers: init.lua checksum + plugin.toml checksum + version
  • Verified on install — any tampering invalidates the signature
  • Distributed via the plugin registry

Community Plugins

  • SHA-256 checksums for init.lua and plugin.toml
  • Pinned to immutable git tags (no race conditions)
  • Listed in community-plugins.json in the plugin registry
  • Source code publicly available for review

Manual Plugins

  • No verification — installed by copying to the plugins directory
  • User takes full responsibility
  • Still subject to all sandbox and permission rules

Clone this wiki locally