Skip to content

fix(server): expiry before password, required key material, safe names, no leaked uploads (#38, #39, #40, #43, #52) - #68

Merged
Hiczownik merged 1 commit into
mainfrom
fix/server-hardening-p2
Oct 21, 2026
Merged

Hiczownik merged 1 commit into
mainfrom
fix/server-hardening-p2

Conversation

@Hiczownik

Copy link
Copy Markdown
Owner

PR A of the P2 plan: five small server fixes, each with a test.

Issue Fix
#43 OpenSessionAsync checks expiry and the download limit before the password, like UnlockGroupAsync. A dead bundle answers 410 without running bcrypt or adding to FailedPasswordAttempts.
#52 For encrypted confirms, KeySalt, KeyEnvelope and EncryptedManifest are required and must be unpadded base64url (new MustBeKeyMaterial rule in BundleRules). No exact lengths, to leave room for the planned CLI (#66).
#39 SanitizeFileName caps the extension at 64 characters. The body is already capped at 190, so the result is at most 254.
#40 Names made only of dots (., .., ...) fall back to unnamed_file. fileNameSafety.ts already did this, and now has the same extension cap.
#38 Presign records each multipart upload it starts. If a later initiate or the DB save fails, it aborts them (best effort) and rethrows the original error.

Tests

  • Unit: sanitizer cases for dots-only and long extensions, plus a set of awkward names that must always end up non-empty, not only dots, and at most 255 characters.
  • Integration:
    • Encrypted confirms with missing, empty or non-base64url key material get 400.
    • A used-up bundle answers 410 to eight wrong guesses, with 0 failed attempts and no lock recorded.
    • A presign whose third file fails to initiate aborts the first two, and leaves no session rows.
    • Long-extension and dots-only names confirm and are stored with safe names.
  • The test S3 mock fails InitiateMultipartUpload for keys containing initiate_fail, like the existing non_existent / delete_fail hooks.
  • The 13 new integration tests all fail against the old server code.
  • Results: 73 unit and 150 integration backend tests pass, and 211 on the frontend. tsc and eslint are clean.

The existing "encryption mode differs from presign" check now sends key material, so it still tests the service's mismatch check and not the new validator rule.

🤖 Generated with Claude Code

…ed names, no leaked multipart uploads

- Opening a download session checks expiry and the download limit before the password, as unlocking
  does: guesses at a dead bundle get 410 without running bcrypt or counting towards a lockout. (#43)
- Encrypted confirms must carry a salt, key envelope and manifest, as unpadded base64url; a bundle
  without them got a share link nobody could ever open. (#52)
- SanitizeFileName caps the extension at 64 characters, so even "unnamed_file" plus the extension
  fits the varchar(255) column, and names made only of dots fall back to "unnamed_file". The
  browser's copy follows the same rules. (#39, #40)
- If presign fails partway (a later initiate or the save), the multipart uploads it already started
  are aborted; no session row records them, so the purge never could. (#38)

Fixes #38
Fixes #39
Fixes #40
Fixes #43
Fixes #52

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant