New
Apps 6,419Makers 6,403This week 7
Promote your app−30%
2views in
the last 30 days

Darkreel

Encrypted media storage & streaming.
Your server stores opaque blobs. Your browser holds the keys.

Website • Threat Model • Features • Cryptography • Deploy • Hardening • Scalability • API


Threat model

What the server sees

data/
  darkreel.db                      # rows of ciphertext
  f47ac10b-58cc/
    a3d9c8e2-7b14/
      000000.enc   [4.00 MB]       # could be anything
      000001.enc   [2.00 MB]       # padded to bucket size
      000002.enc   [1.00 MB]       # random fill hides real size
      thumb.enc    [256 KB]        # encrypted thumbnail

Every media file and directory in the data directory has its modification/access time set to 2024-01-01T00:00:00Z (directory mtimes are reset after each upload and deletion; darkreel.db itself is not). The inode change time (ctime) and, on filesystems that record one, the birth time cannot be set from userspace, so they still show roughly when each item was uploaded — see Disk encryption for why an encrypted volume is recommended. Every chunk is padded to 1, 2, 4, 8 or 16 MB (then whole MB), every thumbnail to 256 KB. Upload dates are coarsened to year only (delegation records use date granularity — see below). An attacker with root on your server sees uniform blobs with no meaningful metadata beyond chunk counts, bucket sizes and those inode times.

Data Visible to server?
File content no - AES-256-GCM, per-file key
File names, types, MIME no - encrypted metadata blob
File sizes, dimensions, duration no exact values (encrypted metadata); approximate size only, from chunk count × bucket size
Thumbnails no - separate encrypted key
Folder structure no - encrypted blob
Passwords not stored - Argon2id hash only. Sent to the server at login, registration, password change and recovery, where the KDF runs (see note)
Master key / private key not stored in usable form - wrapped at rest. Held in plaintext only for the duration of a login, password-change or recovery request, then cleared (see note)
Usernames, public keys yes
File count per user yes (database row count)
Storage used per user yes - sum of padded on-disk sizes, which the disk shows anyway
Upload timestamps year only (coarsened)
Connected apps yes - the name and URL the app supplied; authorize / last-used dates at day granularity (see "Timestamps are coarsened")

What "zero-knowledge" means here — and where it stops. Everything above describes what the server holds at rest: a stolen darkreel.db, a disk image, or a backup yields only Argon2id hashes and ciphertext, with no way to derive a key. That property is real and is the threat model Darkreel is built for.

It is not the same as the server never seeing the material. Web Crypto has no Argon2id, so the browser cannot run the KDF; the password is sent over TLS and the server performs the derivation (see "Concurrent logins" under Known limitations). During a login the server necessarily holds your password and, briefly, your decrypted master key — it is cleared as soon as it has been re-wrapped for the client. Registration and admin-created accounts likewise generate the master key and X25519 keypair server-side. A password change or recovery goes further: the server unwraps the old private key, opens every item's sealed keys to re-seal them, and generates the new keys, all within that one request.

So: a passive operator, a database thief, or anyone with the disk after the fact learns nothing. An operator running modified server code can capture the password of anyone who logs in (and the keys of anyone who changes their password), and — because the server also serves the web app — can ship JavaScript that exfiltrates keys from the browser. If that is in your threat model, the mitigation is to run the binary you built from source yourself — which is the intended deployment anyway.

Features

  • End-to-end encrypted - AES-256-GCM chunk encryption under random per-file keys; your account keys are wrapped under your password (Argon2id) and a recovery code. The server stores only opaque blobs.
  • Zero-knowledge metadata - File names, types, exact sizes, dimensions, and durations are encrypted into a single blob. The server cannot read any of it.
  • Encrypted streaming - Videos stream via MSE with chunk-level decryption in a Web Worker. No server-side decryption. Playback starts after the first chunk.
  • Size fingerprinting resistance - Clients pad every chunk inside the encryption (chunk format 2), so each chunk's ciphertext is exactly 1, 2, 4, 8 or 16 MB (then whole MB) and every thumbnail exactly 256 KB — the server and the network only ever see bucket sizes, never exact lengths (which would fingerprint known videos). Metadata and the folder tree are padded before encryption too. Quota usage is recorded as the padded on-disk size, so the database holds nothing more precise than what the disk already shows.
  • Secure deletion - Deleted files are overwritten with random data, fsynced, then unlinked. The data is already AES-256-GCM encrypted and the encryption keys are deleted first, making the ciphertext computationally unrecoverable. The overwrite is defense-in-depth. Best-effort on SSDs due to wear leveling.
  • Multi-user - Each user has an isolated, encrypted library with their own master key. Admin panel for user management; accounts an admin creates must choose their own password at first login.
  • Hash modification - A random nonce is injected into JPEG (COM segment) and PNG (tEXt chunk) images before encryption, and by the CLI also into MP4s it doesn't remux (a free box appended at the end), so the file you get back doesn't hash-match the original. Other formats and remuxed videos are stored unmodified. The nonce is never sent to or stored by the server — a stored copy would let anyone with database access link a leaked image back to the account that uploaded it.
  • Chunk integrity verification - The chunk count lives in the encrypted metadata, and each chunk carries an encrypted "last chunk" flag. Clients check the flag against the count, so dropping chunks from the end of an item is detected rather than yielding a silently short file. Every chunk is bound to its item and position by AAD.
  • Owner verification - Anyone who holds your public key — a connected app, or someone with write access to the server's database — can create items that decrypt correctly. Uploads from your own browser or CLI carry an owner tag (an HMAC under a key derived from your master key, covering the item ID and its sealed keys) that nobody else can produce. Items without a valid tag are marked APP in the gallery and [not your upload] in darkreel-cli list; renaming or moving one marks it as yours.
  • Generic file storage - Not just media. Upload any file type — PDFs, documents, archives, code. Everything is encrypted with the same zero-knowledge scheme.
  • Encrypted folders - Organize your files into folders. The folder structure is encrypted - only you can see it. Drag-and-drop to reorganize (desktop and mobile touch).
  • Folder download - Download an entire folder (including subfolders) as a ZIP file, decrypted client-side.
  • Upload progress tracking - Real-time progress bar on gallery tiles during upload. Encryption progress (0-50%) and network transfer progress (50-100%) via XHR upload events.
  • Image rotation - Rotate images at the pixel level. The original is securely deleted and replaced with a freshly encrypted copy using new keys.
  • Text editor - Plain-text files (.txt, .md, .log, .csv/.tsv, .json, .yaml/.yml, .xml, .ini/.conf/.cfg) open directly in the viewer. Click Edit to modify; Save writes a freshly-encrypted copy and deletes the old one in a single action. A "New Text Document" button inside the Upload modal creates blank documents from scratch. 5 MB editor cap; larger text files fall back to Download.
  • 6 color themes - Classic, cool, forest, neon, ocean, and warm. Stored in localStorage.
  • Recovery codes - 256-bit recovery code generated at account creation and replaced on every password change or recovery. If you lose your password, this is the only way back in. Lose both and your data is gone.
  • Key rotation on password change - changing your password (or recovering with your recovery code) generates a new master key, X25519 keypair and recovery code, re-seals every item's keys to the new public key, and re-encrypts your folder tree. See Password change and key rotation for what this does and does not protect.
  • Idle lock - after 30 minutes without interaction (a playing video counts as activity) the web app logs out and drops its keys.
  • Delegated uploads - Other apps (e.g., PPVDA) can upload to your account without holding your password. Authorize once via a copy-paste consent flow; connected apps get a refresh token that mints short-lived upload-only JWTs. Apps hold your X25519 public key only — they can seal uploads to you but cannot read, list, or delete any existing media, and their uploads show as APP (see above). Settings → Connected Apps lists each app with its authorize / last-used / expiry dates and shows your upload-key fingerprint (SHA-256 of your public key) to compare with the one the app displays. Revoke anytime there; a connection also expires after 60 days unused or a year after authorization, whichever comes first, and a password change or recovery revokes them all.
  • Single binary - One Go binary with an embedded web UI and SQLite. No external dependencies, no containers, no runtime requirements.
  • Self-hosted - Runs on your hardware. A $6/month VPS is enough. Your data never touches a third-party service.

Supported formats

  • Video: MP4, MOV, WEBM, MKV, M4V — with thumbnail generation, streaming playback (MP4/MOV), and in-browser preview
  • Image: JPG, PNG, GIF, WEBP — with thumbnail generation and in-browser preview
  • Text: TXT, MD, LOG, CSV/TSV, JSON, YAML/YML, XML, INI/CONF/CFG — opens in an in-browser editor with view, edit, and save. Also supports creating new text documents from within the UI.
  • Any file: PDFs, documents, archives, and any other file type can be uploaded and stored with full encryption. Non-media files are displayed with a file icon in the gallery and a download button in the viewer (no preview).

Note: Only MP4 and MOV videos support streaming playback when uploaded in the browser.

Cryptography

Key hierarchy

Password  (sent to the server over TLS; never stored)
 ├─ Argon2id(password, authSalt)             →  password hash  (server: login verification)
 ├─ Argon2id(password, kdfSalt)              →  KDF key        (server: unwraps the stored master key)
 └─ PBKDF2-SHA256(password, kdfSalt, 600k)   →  session key    (browser: unwraps the copy of the
                                                                master key returned at login)
Master key (random 256-bit, per user; replaced on password change / recovery)
 ├─ stored wrapped twice: under the KDF key and under the recovery code (AAD: userID)
 ├─ AES-256-GCM wraps the X25519 private key                         (AAD: userID)
 ├─ AES-256-GCM encrypts the folder tree                              (AAD: userID)
 └─ HKDF-SHA256(info="darkreel-owner-v1")  →  owner-tag HMAC key

X25519 keypair (per user; replaced on password change / recovery)
 ├─ public key       (stored plaintext, handed to browsers and delegated clients)
 └─ private key      (wrapped twice: once by master key, once by recovery code)

Per-file symmetric keys (one trio generated per upload)
 ├─ file key         → AES-256-GCM encrypts chunks     (AAD: mediaID || chunkIndex)
 ├─ thumb key        → AES-256-GCM encrypts thumbnail  (AAD: mediaID || 0)
 └─ metadata key     → AES-256-GCM encrypts metadata   (AAD: mediaID)
    All three keys are sealed to the user's public key → server stores
    the 92-byte sealed blobs alongside the encrypted content.

Once login completes, the server has cleared its copy and the master key and private key live only in the browser, as non-extractable CryptoKeys: the master key is unwrapped directly into one (its raw bytes are never held in JavaScript), and the private key is imported as one right after it is decrypted. Script running in the page — an XSS, a malicious extension — can use the keys while the page is open, but cannot copy them out to use later.

All uploads (browser, CLI, or delegated third-party) produce the same sealed-box wire format. Delegated clients receive only the public key and never hold the master key or private key, so they can seal uploads to the user but cannot open anything.

Algorithms

Component Algorithm Details
Password hashing Argon2id 3 iterations, 64 MB memory, 4 threads, 32-byte random salt
Master-key wrapping key Argon2id Same parameters, separate salt from the auth hash. The master key itself is random, not derived
File / thumb / metadata encryption AES-256-GCM Media ID + chunk index as AAD (prevents reordering and cross-file substitution)
Per-file key wrapping X25519 + HKDF-SHA256 + AES-256-GCM Sealed-box format: ephemeral X25519 ECDH, HKDF with info="darkreel-seal-v1", AES-256-GCM over the derived key. 92-byte output per 32-byte key. Produces the same wire format whether sealed by browser (Web Crypto), CLI (golang.org/x/crypto), or a delegated client.
User keypair X25519 Generated at registration and replaced on every password change / recovery, private key dual-wrapped (master key + recovery code), both with user ID as AAD
Session key PBKDF2-SHA256 600,000 iterations over the password and KDF salt; wraps the master key in the login / change-password response so the browser can unwrap it without Argon2id
Chunk padding Inside the AEAD Plaintext frame version | last-chunk flag | length | data | zeros sized so the ciphertext is exactly 1/2/4/8/16 MB (then whole MB); thumbnails exactly 256 KB
Metadata padding Space fill Bucketed to power-of-2 from 512 B before encryption so blob size doesn't leak filename length (folder tree too)
Owner tag HMAC-SHA256 Key = HKDF-SHA256(master key, "darkreel-owner-v1"); covers item ID + the three sealed keys; stored in the encrypted metadata
Delegation tokens HS256 JWT (scoped) 1-hour TTL, scope=upload, carries the delegation ID and is refused as soon as that delegation is revoked or expires; rejected on all non-upload endpoints
Refresh tokens 32-byte URL-safe random Stored server-side as sha256("darkreel:delegation-refresh-v1|"‖token) — DB leak cannot be replayed. Expire after 60 days unused or 1 year after authorization
Hash modification Nonce injection JPEG COM, PNG tEXt; MP4 free box appended at end (CLI, non-remuxed files only)
Secure deletion 1-pass shred Random overwrite, fsync, then unlink. Keys deleted first — ciphertext is unrecoverable regardless.

AAD binding

All block-level encryption uses Additional Authenticated Data (AAD) to cryptographically bind ciphertext to its context:

  • Master key wrapping (KDF key, session key, recovery code) uses the user ID as AAD
  • Private key wrapping (under master key and under recovery code) uses the user ID as AAD
  • File / thumb / metadata key sealing uses X25519-ECDH + HKDF; the derived AES-GCM key is per-upload by construction (fresh ephemeral keypair per seal), so there is no separate AAD on the sealed blob — substitution attacks are prevented by the ephemeral key being bound into the ciphertext itself
  • File chunk encryption uses UTF-8(mediaID) || BigEndian(uint64(chunkIndex)) as AAD
  • Thumbnail encryption uses UTF-8(mediaID) || BigEndian(uint64(0)) as AAD
  • Metadata encryption uses the media ID as AAD
  • Folder tree encryption uses the user ID as AAD

This prevents ciphertext substitution attacks - an attacker with database access cannot swap encrypted keys or metadata between users or media items. Decryption will fail if the AAD doesn't match.

On-disk format

// chunk plaintext (chunk_format 2), padded before encryption
[version=2: 1B] [flags: 1B, bit0 = last chunk] [data length: 4B big-endian] [data] [zeros → bucket]

// encrypted chunk — exactly 1/2/4/8/16 MB (then whole MB); thumbnails 256 KB
[nonce: 12 bytes] [ciphertext] [GCM tag: 16 bytes]
// media ID + chunk index bound as AAD - reorder and decryption fails

// chunk on disk (the length prefix only ever shows a bucket size)
[ciphertext length: 4B big-endian] [encrypted chunk] [random padding → server bucket]

Items uploaded before chunk format 2 (no chunk_format in their metadata) use unpadded chunk plaintext and are still readable.

Streaming

Videos are remuxed to fragmented MP4 on upload - no re-encoding. The CLI uses ffmpeg (supports all formats including WEBM/MKV, 1 s fragments). The browser uses mp4box.js (144 KB, no WASM, supports MP4/MOV, ~2 s segments).

upload:
  container → extract samples → fMP4 segments
    → merge into chunks that fit the 1 MB bucket
    → frame + pad to bucket size → AES-256-GCM encrypt → upload

playback:
  fetch chunk (prefetch-ahead) → Web Worker decrypt
    → MediaSource Extensions → <video>
    → playback starts after first chunk

download:
  fetch all chunks → decrypt → fMP4 → standard MP4

iOS Safari 17.1+ uses ManagedMediaSource. Non-remuxable formats uploaded via browser are stored as-is and played via blob URL.

Trade-offs

These are deliberate:

  • Chunk padding wastes disk space and bandwidth. Every chunk is padded up to its bucket, so a file costs up to one extra megabyte on disk and over the wire (more when a video segment lands in a larger bucket), and every item carries a 256 KB thumbnail regardless of actual size — a 100-byte text file occupies about 1.25 MB. This is the cost of preventing size fingerprinting — if an observer can correlate chunk sizes to known files, encryption is weakened.

  • Timestamps are coarsened. Upload dates are stored as year only. Precise timestamps reveal usage patterns. That precision is deliberately discarded.

    Delegation records (created_at, last_used_at in the Connected Apps panel) are the one exception: they keep date granularity rather than year. last_used_at is rewritten on every token refresh, so at second precision it would have been a per-second log of when a connected client last uploaded — recoverable by anyone who seizes the database. A date defeats correlation with an observed network event while still letting you spot an app that is active when it shouldn't be, which is the entire point of the panel.

  • No server-side thumbnails. The server can't see your files, so it can't generate thumbnails. The browser encrypts them before upload with a separate per-file key.

  • No recovery without codes. Lose your password and your recovery code? Your data is cryptographically gone. No backdoor, no admin recovery, no "forgot password" email. This is correct behavior for a zero-knowledge system.

  • SSD deletion is best-effort. The overwrite pass works on HDDs. On SSDs, wear leveling may retain old data. S

Description taken from the repository README.

Ratings

–
0 ratings
5 0
4 0
3 0
2 0
1 0

Rate this app

Sign in to rate

Comments 0

Sign in to comment

No comments yet.

Related apps

#encryption · #media · #streaming