Security Model
Paperclip enforces security at multiple layers:- Deployment modes -
local_trustedvsauthenticated - Authentication - Session-based (Better Auth) for board, API keys for agents
- Authorization - Company-scoped access, role-based permissions
- Secrets management - Encrypted storage, strict mode enforcement
- Audit logging - Immutable activity log for all mutations
Deployment Modes
local_trusted
Security profile:- ✅ Localhost-only binding (
127.0.0.1) - ✅ No network exposure
- ❌ No authentication required
- ❌ Not suitable for multi-user or remote access
- Local development
- Single-operator workflows
- Trusted local environment
authenticated
Security profile:- ✅ Login required for all board access
- ✅ Session-based authentication
- ✅ Agent API key validation
- ✅ Multi-user support
Private
- For: VPN, Tailscale, LAN
- Auto URL detection
- Lower setup friction
- Private-host trust policy
Public
- For: Internet-facing deployments
- Explicit public URL required
- Stricter validation
- Enhanced security checks
Authentication
Board Authentication
Paperclip uses Better Auth for session management. Bootstrap flow:- Deploy in
authenticatedmode - System creates board claim URL (in startup logs)
- User signs in
- User visits claim URL
- User promoted to instance admin
- Users stored in
authUserstable - Sessions in
authSessionstable - Instance roles in
instance_user_roles - Company access in
company_memberships
Agent Authentication
Agents authenticate via:- API Keys - Long-lived tokens for external agents
- JWTs - Short-lived tokens for local agents
API Keys
Create an API key: Via UI: Agent > Settings > Create API Key Via CLI:- Keys hashed with SHA-256 before storage
- Stored in
agent_api_keystable - Can be revoked anytime
lastUsedAttimestamp tracked
server/src/middleware/auth.ts:11.
Agent JWTs
For local agent runs: System generates short-lived JWTs for agents running on the same machine. JWT claims:server/src/agent-auth-jwt.js.
Authorization
All API endpoints enforce: Company access:board- Human user via sessionagent- Agent via API key or JWTnone- Unauthenticated
Secrets Management
Paperclip securely stores secrets like API keys and tokens.How It Works
- Secrets encrypted with AES-256-GCM
- Encrypted values stored in
company_secret_versions - References used in agent configs (e.g.,
$secret:openai-key) - Master key encrypts/decrypts secrets
Secrets Provider
Current provider:local_encrypted
pnpm paperclipai onboard or doctor --repair.
Manually create:
Strict Mode
Prevent inline secrets in environment variables:*_API_KEY*_TOKEN*_SECRET*_PASSWORDAUTHORIZATIONBEARERJWT
server/src/services/secrets.ts:11.
Secret Migration
Migrate existing inline secrets:Secret Storage Schema
Tables:company_secrets- Secret metadata (name, company)company_secret_versions- Encrypted values, versioned
- Algorithm: AES-256-GCM
- Key derivation: PBKDF2 (from master key)
- IV: Random per secret version
packages/db/src/schema/secrets.ts.
API Key Security
Agent API Keys
Best practices:Use short-lived keys for testing
Use short-lived keys for testing
Create temporary keys, revoke after testing.
Rotate keys regularly
Rotate keys regularly
Create new key, update agent config, revoke old key.
Use separate keys per agent
Use separate keys per agent
Don’t share keys across agents - isolate blast radius.
Store keys in secret manager
Store keys in secret manager
Use 1Password, AWS Secrets Manager, etc.
Monitor key usage
Monitor key usage
Check
lastUsedAt for anomalies.Key Format
Revoke a Key
Via UI: Agent > Settings > Revoke Key Via database:Network Security
HTTPS
Always use HTTPS in production:Firewall Rules
Restrict database access: Only allow connections from application servers:CORS
CORS is handled automatically for same-origin deployments. For custom UI deployments, configure allowed origins inserver/src/index.ts.
Data Security
Company Isolation
All entities are company-scoped:server/src/routes/authz.ts:27.
Audit Logging
All mutations logged toactivity_log:
Sensitive Data Handling
Never log secrets:- Secret values
- API keys
- Passwords
- Tokens
server/src/services/company-portability.ts:31.
Production Hardening
Checklist
Security Validation
Run the doctor command:- Deployment mode configuration
- Authentication readiness
- Database connectivity
- Secret provider setup
- Storage configuration
Incident Response
Suspected Key Compromise
- Revoke compromised key immediately
- Check
activity_logfor unauthorized actions - Review
lastUsedAttimestamps - Create new key with different secret
- Update agent configuration
- Monitor for anomalous behavior
Database Breach
- Rotate master encryption key
- Rotate all agent API keys
- Force session logout (clear
authSessions) - Review audit logs
- Restore from backup if needed
Session Hijacking
- Clear affected user sessions
- Force re-authentication
- Review access logs
- Enable additional auth factors (future feature)
Compliance
Data Retention
Configure retention policies:GDPR / Data Deletion
Delete user data:Security Updates
Stay updated:Reporting Vulnerabilities
Report security issues to:- Email: security@paperclip.ing
- GitHub: Private security advisory
Next Steps
Production Deployment
Deploy securely to production
Configuration
Configure deployment and runtime options