GitHub - Ymsniper/vault-share: Self-hosted, invite-only encrypted file sharing in Flask. Each file gets its own AES-256-GCM key, sealed with HPKE for every reader. Signed uploads, duress passwords that open separate cover vaults, and a master key that can require a USB flash drive.
Pangram verdict · v3.3
We believe this text is mainly AI, with some human-written content.
AI likelihood · overall
AIArticle text · 1,352 words · 6 segments analyzed
Secure file sharing: a Flask web app for sharing confidential files between users. Each file is encrypted at rest with its own AES-256-GCM key, kept only as copies encrypted to the public key of each person allowed to open it, checked with SHA-256 and an HMAC, and signed with an ECDSA key certified by a local CA. Features Every file has its own AES-256-GCM key, stored only as copies encrypted with HPKE (X25519) for its owner and each person it is shared with: the server's own keys cannot open a stored file. Files are signed with ECDSA P-256 keys certified by a local OpenSSL CA, with revocation and a signature proof that can be checked offline. Uploads are checked by their content, not their name. Archives are accepted but marked Not checked for everyone they are shared with. The database is encrypted with SQLCipher, and every file record is protected by an HMAC. Argon2id passwords, server-side sessions, CSRF protection, rate limits, security headers and optional two-factor login. Registering needs an invite code, and every username gets a random tag. Bans and a cleanup by inviter and time window undo what a stolen admin login let in. A duress password that opens a cover vault of its own, kept apart by keys, and can wipe the rest. The master key can also require a USB stick and a passphrase; pulling the stick locks the service. A terminal console to run and manage the server. A black-and-white interface in typewriter type, with an ASCII-art wordmark. Run python -m venv .venv .venv/bin/pip install -r requirements-dev.txt bin/vault-share install # the `vault-share` command, from any terminal read -s -x CA_PASSPHRASE # fish; in bash: read -rs CA_PASSPHRASE && export CA_PASSPHRASE pki/create_ca.sh vault-share init-db vault-share # the console; `vault-share serve` runs the server alone read -s asks for the CA passphrase without showing it and without saving it in the shell history, which export CA_PASSPHRASE='...'
would do.
The console asks for it itself at startup when it is not set, and keeps it in memory only. vault-share passes anything else to flask --app app, so vault-share keys status or vault-share admin grant 'bob#516850' work from any folder; vault-share install links the command into ~/.local/bin. Then open http://127.0.0.1:5000 (the port can change, see "Server settings" below). pki/create_ca.sh creates the local CA in instance/ca/ once; the app needs the same CA_PASSPHRASE every time it starts, to issue a certificate to each new user. Registering needs an invite code: make the first one with vault-share invite new (see below). Using it The page at /security, linked from every page's footer, tells users what this server stores and cannot read, what it records and for how long, which cookies it sets, and what its operator can do. Anyone can read it, logged in or not, and it stays up while the service is paused, since it needs neither the database nor the master key. Uploading asks for your password again: it unlocks your private key to sign the file. Each file's record carries an HMAC over all of its fields, from the owner and the hash to the name, the description and the signature, so a record edited in the database fails its check on the file page. Each file page also offers a signature proof, a zip with the signature, the signer's certificate, the CA certificate and the OpenSSL commands that check the file without the app. They check the certificate as it was at the upload time, and name your copy FILE rather than using the file's name, which could hold shell syntax. Every upload is checked before it is stored: its extension must be on the list, its content must really be that type (filetype reads the first bytes, so a program renamed .pdf is refused; text must be UTF-8, and JSON and TOML must be valid), and it must fit under the upload limit. Documents: PDF, DOCX, XLSX, PPTX, ODT, ODS, ODP Images: PNG, JPG, GIF, WEBP, BMP, TIFF, HEIC Audio: MP3, WAV, OGG, FLAC, M4A Video: MP4, MOV, WEBM, MKV, AVI Text: TXT, MD, CSV, JSON, TOML, YAML, INI, CFG, LOG Archives (ZIP, 7Z, RAR, TAR, GZ, TGZ, BZ2, XZ) are accepted too: their signature is checked, so a program renamed .zip is refused, but not what they hold. They are marked Not checked, and the HMAC of the file's record covers that mark, so it cannot be dropped in the database. Everyone they are shared with sees a warning, and must tick "I understand" before downloading. DOC, XLS, PPT and RTF (macros, embedded objects), and HTML, SVG, XML, scripts and programs (they run code when opened) are left out; share them inside an archive. A check tells what kind of file it is, not that it is harmless. The upload page explains all of this under "What happens". Every visit to a file's page checks its record and signature, and every download checks the file itself. A record changed behind the app's back shows up at once: At login, five wrong passwords for one username from one address block that pair for 15 minutes, and twenty from one address block the address; an IPv6 address counts as its whole /48 network, since one subscriber can switch among many. A browser that logged in as someone keeps a signed cookie for a year that says so, holding a keyed digest rather than the name; browsers without it share fifty wrong tries an hour per username, wherever they come from, so many addresses together get about 1,200 guesses a day at one account instead of no limit at all. Wrong tries from somewhere else never lock the owner out of a browser they have logged in from before; during such an attack, a browser they never used has to wait for the hour to pass. Once logged in, the password asked at upload, download, sharing, revoking, deleting and in the settings has a limit of its own, five wrong ones per account, which only that account's sessions can use up. Sharing with a username that does not exist counts too, ten an hour, since each one is a guess at someone's tag. The counters live in memory (Flask-Limiter), so restarting the app clears them. A password check counts from the moment it starts, so requests sent at the same time cannot all slip under a limit: one that finds the limit filled by checks still running waits up to 10 seconds for them, and is refused only if they failed. Right passwords count too, sixty checks in 15 minutes per account, and at most four checks run at once: each one takes 64 MiB of memory. Two-factor login is optional, per user, from the "Two-factor" page: scan the QR code with an authenticator app such as Aegis or FreeOTP and confirm with a first code. Wrong codes count toward the same limit as wrong passwords, and each code works only once, even when two requests carry it at the same moment. Turning it on also gives ten recovery codes, shown once in that page: each one logs in once instead of a code from the phone, and "New codes" replaces them. Someone who lost both the phone and the codes asks the operator, who can turn their two-factor login off with vault-share admin clear-totp '<username>' or "Clear two-factor" in the console's Users tab. Until it is confirmed, the new secret stays on the server with the session that asked for it: it never goes into the browser's cookie, and another session of the account cannot see it. An admin's new invite code is shown the same way, in the page that made it.
The video below walks through the duress password on a test server: setting one, moving files to the cover files, and logging in with each password.
vault-share-duress-demo.mp4 A duress password, set from the "Duress" page, is the one to give if someone forces you to log in.
It opens your cover files: a second vault that is real, where uploads, downloads, sharing and the settings all work, rather than an empty account that refuses things.