Security

Snip includes multiple security measures for safe deployment.

Security Headers

Snip automatically sets these headers on all responses:

HeaderValuePurpose
X-Content-Type-OptionsnosniffPrevents MIME type sniffing
X-Frame-OptionsDENYPrevents clickjacking
Referrer-Policystrict-origin-when-cross-originControls referrer information
Permissions-Policygeolocation=(), microphone=(), camera=()Disables unnecessary APIs
Content-Security-PolicyRestricted sourcesPrevents XSS and data injection

Rate Limiting

All endpoints are rate-limited to 120 requests per minute per IP. When exceeded, the server returns HTTP 429.

The rate limiter uses an in-memory map with automatic cleanup of expired entries.

Password Protection

Paste passwords are hashed with bcrypt (cost factor 12). The plaintext password is never stored.

API Token Security

Input Validation

Privacy

Production Best Practices

Checklist for production deployment:
  1. Use HTTPS -- Always deploy behind a reverse proxy with TLS
  2. Set SNIP_JWT_SECRET -- Use a strong random string (openssl rand -hex 32)
  3. Set SNIP_BASE_URL -- Match your public URL exactly
  4. Regular backups -- Use the backup API or copy the SQLite file
  5. Monitor logs -- Check for unusual activity patterns
  6. Keep updated -- Watch the GitHub repo for security updates
  7. Restrict network -- Use firewall rules to limit access
  8. Run as non-root -- Use the Docker image or create a dedicated user

Responsible Disclosure

If you discover a security vulnerability, please report it responsibly. Do not open a public GitHub issue.

Send an email to the maintainer with:

Response timeline:

Security Architecture

Architecture
Client Request
    |
    v
[Rate Limiter] -- 429 if exceeded
    |
    v
[Security Headers] -- CSP, X-Frame-Options, etc.
    |
    v
[CORS] -- For API routes only
    |
    v
[Body Size Limit] -- 413 if too large
    |
    v
[Auth Middleware] -- JWT or API token (protected routes)
    |
    v
[Handler] -- Business logic
    |
    v
[Service Layer] -- Validation, password checking
    |
    v
[Store Layer] -- SQLite with parameterized queries