Security defaults, exposure policy, and security-relevant environment settings. Storage compatibility lives in storage.md, service operations in deployment.md, runtime-provider toggles in language-detection.md, and build/run commands in dev/devlog.md.
- Default Security Settings
- Environment Variables
- Public Exposure (Not Recommended)
- Security Best Practices
- Threat Model
- Reporting Security Issues
- Compliance Notes
LocalPaste.rs is designed for local use and comes with secure defaults:
- Localhost-only binding: Server binds to
127.0.0.1by default - CORS restrictions: In strict mode, only accepts loopback origins that match the active listener port
- Security headers: CSP, X-Frame-Options, X-Content-Type-Options
- Request size limits: Enforced at transport layer (default: 10MB)
- Storage durability: defined in storage.md
- Single-writer owner lock: semantics in dev/locking-model.md
| Variable | Default | Description |
|---|---|---|
PORT |
38411 |
Listener port used when BIND is unset |
BIND |
127.0.0.1:38411 |
Server bind address (non-loopback requires ALLOW_PUBLIC_ACCESS=1) |
ALLOW_PUBLIC_ACCESS |
disabled | Enable CORS for all origins and allow non-loopback bind |
MAX_PASTE_SIZE |
10485760 |
Max accepted paste size (bytes) for write paths (API and GUI backend) |
AUTO_BACKUP |
disabled | Create DB backup on startup when existing DB is present |
LOCALPASTE_VERSION_INTERVAL_SECS |
300 |
Minimum seconds between persisted historical snapshots (>= 1) |
LOCALPASTE_PASTE_VERSION_INTERVAL_SECS |
unset | Legacy fallback key for LOCALPASTE_VERSION_INTERVAL_SECS |
localpaste startup fails fast on malformed BIND/PORT/size/boolean/snapshot-interval env values so invalid deployment configuration is explicit.
Reference defaults/examples: .env.example.
The following headers are automatically set:
Content-Security-Policy: Restricts resource loading to same-originX-Content-Type-Options: nosniff: Prevents MIME-type sniffingX-Frame-Options: DENY: Prevents clickjacking
To add a referrer policy, configure your reverse proxy or extend the Axum middleware layer.
Operational recovery is documented in deployment.md.
Lock semantics are documented in dev/locking-model.md.
DB_PATH single-writer contract is documented in storage.md.
Treat uncertain lock ownership as unsafe.
If you need to expose LocalPaste publicly, follow these steps:
Warning
Setting ALLOW_PUBLIC_ACCESS=1 relaxes loopback-only protections. Use it only behind a firewall/reverse proxy you control.
Build/run mechanics are documented in deployment.md and dev/devlog.md. This section only defines the security-relevant overrides:
# Bind to all interfaces (requires ALLOW_PUBLIC_ACCESS)
export BIND=0.0.0.0:38411
# Allow cross-origin requests and non-loopback bind
export ALLOW_PUBLIC_ACCESS=1Before exposing publicly, ensure:
- Firewall rules configured to limit access
- Consider adding authentication (not built-in)
- Use HTTPS proxy (nginx/caddy) for encryption
- Monitor access logs
- Regular security updates
- Backup strategy in place
server {
listen 443 ssl http2;
server_name paste.example.com;
ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/key.pem;
# Security headers
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "DENY" always;
location / {
proxy_pass http://127.0.0.1:38411;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# WebSocket support (if needed)
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}-
Regular Updates: Keep dependencies updated
cargo update cargo audit
-
Monitoring: Watch logs for unusual activity Use the service/logging patterns in deployment.md.
-
Backups: Regular database backups Use the backup and retention procedures in deployment.md.
-
Access Control: Use firewall rules
# Allow only specific IPs (example with ufw) ufw allow from 192.168.1.0/24 to any port 38411 -
Keep broad-list payloads bounded by design
GET /api/pastesandGET /api/searchreturn metadata rows. Fetch full content withGET /api/paste/:idonly for selected records.
LocalPaste is designed for trusted local environments. The main security considerations:
- Prevents unauthorized remote access (localhost binding)
- Prevents XSS attacks (CSP headers, input sanitization)
- Prevents large payload DoS (size limits)
- Prevents clickjacking (X-Frame-Options)
- No built-in authentication/authorization
- No encryption at rest (use disk encryption)
- No rate limiting (add reverse proxy if needed)
- No audit logging (basic access logs only)
If you discover a security vulnerability, please:
- Do not create a public GitHub issue
- Email details to the maintainer
- Allow time for a fix before disclosure
LocalPaste stores all data locally and does not:
- Transmit data to external services
- Include analytics or tracking
- Store personal information beyond paste content
- Use cookies or local storage for tracking
This makes it suitable for environments with strict data residency requirements.