Documentation

Security Architecture

How TypeDock minimizes attack surface in the AI era: static Go binary, declarative code-free themes, goja JS sandbox, and Tiptap 3 AST.

TypeDock is built for a world where automated scanners and AI agents continuously probe production websites. Rather than bolting security plugins onto an unrestricted runtime, TypeDock removes entire classes of vulnerabilities by architecture.

1. Single Static Binary, Minimal Attack Surface

  • Compiled as a single static Go binary (CGO_ENABLED=0) with no PHP interpreter, no runtime package manager, and no eval-based plugin loader.
  • Upgrading core means replacing one binary and running migrations — no transitive dependency tree to patch on production hosts.

2. Declarative Themes with Zero Code Execution

  • Themes consist strictly of theme.json, Pongo2 templates, and static CSS/JS assets.
  • Themes cannot execute arbitrary Go or shell code, read environment variables, or query the database directly.
  • All dynamic data enters templates through typed core providers, declared slots, and manifest-driven configuration. This makes it safe to generate or iterate on client themes with AI coding agents.

3. Sandboxed JavaScript Plugins (goja)

  • Drop-in plugins run inside an isolated goja ES runtime — never with direct OS, filesystem, or unrestricted SQL access.
  • Every plugin invocation is bounded by a strict execution timeout and panic/exception isolation so a faulty plugin cannot crash the host process.
  • Database access is guarded by db_guard, HTTP requests go through a controlled client, capability conflicts are caught via manifest provides declarations, and plugin admin pages render inside sandboxed iframes with configurable CSP (admin_csp).

4. Structured Content AST (No Raw HTML Storage)

  • Editorial content is stored as structured Tiptap 3 JSON rather than arbitrary pasted HTML.
  • Server-side TiptapRenderer, BlockRenderer, and UnsafeBlockFilter convert JSON into sanitized HTML and clean Markdown (/{postsSlug}/{slug}.md).

5. Authentication, Sessions & Transport Hardening

  • RBAC: Four built-in roles with granular permission checks across admin routes and REST API endpoints.
  • TOTP 2FA: Built-in authenticator app enrollment (with QR code) and verification.
  • Brute-force protection: Login lockout policies and CSRF token verification on all state-changing admin forms.
  • HTTPS awareness: Automatic Secure cookie flags behind TLS, Cloudflare (Cf-Visitor), reverse proxies (X-Forwarded-Proto), and FastCGI (HTTPS=on).
  • Storage isolation: In FastCGI mode, .htaccess returns 403 Forbidden for storage/, config.json, .secrets.json, .git, and database/backup files, and the installer recommends storing data outside public_html/ whenever writable.