Security
This page is for security reviewers and administrators operating Patchwork.
Authentication & Session Model
Section titled “Authentication & Session Model”- Passwords: Hashed with
argon2id. Complexity rules are enforced server-side fromSecuritySettingsSchema. - Sessions: Stored in PostgreSQL (
sessions), delivered viaHttpOnlycookies, and validated against bothexpiresAtand optionalsessionIdleTimeoutMs. - CSRF Protection: State-changing API requests require a matching
x-csrf-tokenheader checked against the session’scsrfToken. - Authorization: Every route verifies organization and team RBAC roles server-side (
src/lib/rbac.ts).
Admin Setup Token & TOKEN_ENCRYPTION_KEY
Section titled “Admin Setup Token & TOKEN_ENCRYPTION_KEY”During installation, scripts/setup.mjs encrypts the one-time Admin Setup Token with AES-256-GCM using TOKEN_ENCRYPTION_KEY and deletes the ciphertext as soon as /setup verifies it. Never regenerate TOKEN_ENCRYPTION_KEY while an unconfirmed setup token is pending.
File Upload Validation & Headers
Section titled “File Upload Validation & Headers”- Uploads validate MIME type, extension, and byte size against
StorageSettingsSchemaandMAX_ATTACHMENT_BYTES. - Exported filenames pass through
sanitizeFilename(). - Security headers (
X-Frame-Options,X-Content-Type-Options,Referrer-Policy, etc.) are applied across responses.
Reporting a Vulnerability
Section titled “Reporting a Vulnerability”See SECURITY.md at the repository root: do not file public issues for security bugs. Open a private GitHub Security Advisory or email security@example.com.
Related Pages
Section titled “Related Pages”Binary Download Verification
Section titled “Binary Download Verification”When the installer downloads MinIO (RELEASE.2025-09-07T16-13-09Z), it enforces fail-closed verification:
- Downloads only over HTTPS (honoring
HTTPS_PROXYandNO_PROXY). - Displays binary name, size, and source URL for user confirmation before downloading (unless
--yes/--non-interactiveis passed). - Fetches the official
.sha256sumfile over HTTPS, streams into a.partfile inside./data/cache/, verifies byte length and SHA-256 digest, and deletes any mismatched or truncated file before copying to./bin/. - Never executes an unverified binary and re-verifies cached binaries against
.sha256sumbefore reuse.
Notifications, Webhooks & Privacy Note
Section titled “Notifications, Webhooks & Privacy Note”- Read-time authorization: Watcher lists, notifications, digests, SSE streams, and presence rooms enforce current ticket/team access at read and send time. If access is revoked, notifications redact to
"You no longer have access to this ticket". - Encrypted secrets: SMTP passwords and webhook signing secrets are encrypted at rest with AES-256-GCM (
TOKEN_ENCRYPTION_KEY), write-only in the UI, and never returned in API responses or logs. - SSRF protection: Outbound webhooks resolve DNS at connect time, block loopback/private/link-local/metadata/multicast IPv4 and IPv6 ranges, pin the resolved IP, and never follow redirects (unless an admin explicitly enables private-network webhooks).
- What is stored & who can see what:
ticket_watchers: storesticket_id,user_id,source, andmutedstate; visible (names and avatars only, never emails) to users who can view the ticket.notifications: stores minimal event metadata and up to 140-character snippets for mentions/comments; visible only to the recipient.email_outbox&webhook_deliveries: delivery logs mask recipient emails (al***@example.com) and redact secrets/errors; visible to organization admins only.- Presence & typing: strictly in-memory (
presenceHub) andLISTEN/NOTIFYephemeral messages; never written to the database and never contains draft text.