Skip to content

Security follow-up: transfer v2, entry signing, Argon2id, limits and docs - #125

Merged
johnwmail merged 5 commits into
security/hardening-2026-12from
security/hardening-followup
Dec 3, 2026
Merged

johnwmail merged 5 commits into
security/hardening-2026-12from
security/hardening-followup

Conversation

@johnwmail

Copy link
Copy Markdown
Owner

Follow-up to #124 (stacked on security/hardening-2026-12; retarget to main after #124 merges). Implements items #1–#4 and #6–#13 of the security review; #5 (pin GitHub Actions to commit SHAs) is intentionally skipped.

Changes

# Change
1 Device transfer v2: random link secret in the URL fragment is mixed into PBKDF2; HKDF splits encryption and proof keys; envelope fetch is now POST and needs the one-time link token; approve/deny need an approval secret that only the creating device holds
2 Optional entry signing (sign-then-encrypt, per device). Invalid signature blocks the entry; unsigned entries warn when enabled; Settings has toggle + "Sign all entries"
3 Optional Argon2id key protection when changing the PGP passphrase (CSP gets 'wasm-unsafe-eval')
4 frontend/public/_headers – CSP/security headers for Cloudflare Pages
6 X-Forwarded-Proto honoured only from TRUSTED_PROXIES
7 docker-compose.yml publishes on 127.0.0.1 (BIND_ADDRESS/HOST_PORT to override)
8 Audit log retention + per-account cap + pruning; unknown-account logins share one bucket
9 Global failed registration-code budget (REGISTRATION_MAX_FAILURES)
10 Atomic TOTP replay claim, 16-byte minimum TOTP secret
11 Shallow git clones with size/file-count watchdog (GIT_MAX_REPO_MB)
12 Per-account push/pull budget (GIT_SYNC_RATE_LIMIT)
13 window.__webpass only in VITE_E2E builds; CI fails if it is in the production bundle

Compatibility (details in README "Upgrading from v0.10.x")

  • No DB migration; accounts, entries, passwords, 2FA, git config untouched.
  • Breaking only for: in-flight/old transfer links (v1 rejected – create a new link; server + all frontends must be upgraded together), proxies without TRUSTED_PROXIES that relied on X-Forwarded-Proto, direct LAN access to the compose port.
  • Entry signing / Argon2id are opt-in.

Tests

  • go vet, gofmt, golangci-lint clean; go test ./... (also TZ=Asia/Hong_Kong), OpenBSD cross-build.
  • Frontend tsc, Vitest (159), prod bundle contains no __webpass.
  • Full Playwright suite via playwright-e2e-test.sh: 88/88 passed (new: signing, Argon2id, transfer v2 link secret).
  • New Go tests: transfer v2 (token, approval secret, v1 rejection), shallow push/pull round trip against a bare repo (history grows), repo-limit watchdog, git rate limit, audit pruning, registration lock-out, TOTP replay, untrusted X-Forwarded-Proto.

rdu64 and others added 5 commits December 3, 2026 15:45
… approval secret

- Mix a random link secret (URL fragment, never sent to a server) into the
  PBKDF2 input so the pairing code cannot be brute-forced offline from the
  server-held ciphertext.
- Derive separate AES-GCM and HMAC keys with HKDF (no key reuse for the proof).
- Envelope fetch is now POST and requires the one-time link token.
- Approve/deny require a secret only the creating device holds (hash uploaded).
- v1 envelopes/links are rejected; create a new link after upgrading.

Co-authored-by: Cursor <cursoragent@cursor.com>
…c rate

- X-Forwarded-Proto is only honoured from TRUSTED_PROXIES.
- Audit log retention/pruning (AUDIT_RETENTION_DAYS, AUDIT_MAX_ROWS_PER_ACCOUNT)
  and unknown-account logins no longer create unbounded rows.
- Global registration-code failure counter (429 when locked).
- Atomic TOTP replay claim; minimum TOTP secret length.
- Shallow clones with size/file-count watchdog (GIT_MAX_REPO_MB).
- Per-account push/pull budget (GIT_SYNC_RATE_LIMIT).

Co-authored-by: Cursor <cursoragent@cursor.com>
- Sign-then-encrypt entries with the PGP key (opt-in per device); a present but
  invalid signature blocks the entry, unsigned entries are flagged when
  signing is on. Settings: toggle + 'Sign all entries'.
- Opt-in Argon2id S2K when changing the PGP passphrase (shows current mode).
- Unit + E2E tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
- frontend/public/_headers: CSP and security headers for Cloudflare Pages.
- CSP allows 'wasm-unsafe-eval' (Argon2id key unlock needs WebAssembly).
- docker-compose publishes on 127.0.0.1 by default (BIND_ADDRESS/HOST_PORT).
- window.__webpass only exists in VITE_E2E builds; CI checks the prod bundle.
- Server does not serve _headers/.gitkeep.

Co-authored-by: Cursor <cursoragent@cursor.com>
README, AGENTS.md, CONTRIBUTING.md, .env.example and the OpenBSD env example
describe the new behaviour, limits, E2E build flavour and compatibility.

Co-authored-by: Cursor <cursoragent@cursor.com>
@johnwmail
johnwmail merged commit 257a9a6 into security/hardening-2026-12 Dec 3, 2026
1 check passed
johnwmail added a commit that referenced this pull request Dec 3, 2026
* Harden backend: git SSRF checks, rate limits, CSRF, size limits

- Git: enforce the remote address policy at connect time (HTTP dial
  control and SSH host-key callback), stricter URL/scp host validation,
  re-validate the stored URL on push/pull, per-account repo lock,
  context-aware clone/push with timeouts, read .gpg-id as a regular file
  only, validate trusted host-key fingerprints.
- Remove the server-side git token cache and /git/session; push/pull
  require the token in the request body. Remove dead toggle-sync route.
- Rate limiting: validate the fingerprint before keying, check IP first,
  group IPv6 by /64, authenticate key-transfer before limiting, and add a
  shared budget for endpoints that re-verify the login password.
- CSRF exemptions match exact login paths only.
- Fail closed when session info cannot be loaded (deleted account).
- Reject oversized entries with 413 instead of truncating; cap the
  decompressed tar stream including skipped entries.
- WebAuthn: store challenge expiry in UTC, reject clone warnings.
- SQLite: apply pragmas to every pooled connection; single connection
  for in-memory databases.
- Reject JWT_SECRET placeholders, including the shipped examples.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Harden frontend: transfer link validation, logout, clipboard

- Validate transfer links (https server URL, fingerprint and token
  format) and require confirmation before sending the login password to
  a server on another origin.
- Require pairing codes of at least 8 characters.
- Log out on the server before clearing the local session in Settings.
- Encode entry path segments in API URLs.
- Keep the clipboard wipe timer alive after the component unmounts and
  wipe decrypted text copied from the Encrypt/Decrypt tool.
- Send git credentials only with push/pull; drop setGitSession.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Ops: dockerignore secrets, relayd forwarded headers, pin CI tools

- .dockerignore: exclude env files, databases and keys in any directory.
- OpenBSD: set X-Forwarded-For/Proto in relayd and TRUSTED_PROXIES so
  rate limits are per client, not per proxy.
- Release/deploy workflows: persist-credentials: false; pin wrangler.
- README: update git sync endpoints.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Security follow-up: transfer v2, entry signing, Argon2id, limits and docs (#125)

* Device transfer v2: link secret in URL fragment, HKDF key separation, approval secret

- Mix a random link secret (URL fragment, never sent to a server) into the
  PBKDF2 input so the pairing code cannot be brute-forced offline from the
  server-held ciphertext.
- Derive separate AES-GCM and HMAC keys with HKDF (no key reuse for the proof).
- Envelope fetch is now POST and requires the one-time link token.
- Approve/deny require a secret only the creating device holds (hash uploaded).
- v1 envelopes/links are rejected; create a new link after upgrading.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Harden proxy trust, audit log, registration, TOTP, git clones and sync rate

- X-Forwarded-Proto is only honoured from TRUSTED_PROXIES.
- Audit log retention/pruning (AUDIT_RETENTION_DAYS, AUDIT_MAX_ROWS_PER_ACCOUNT)
  and unknown-account logins no longer create unbounded rows.
- Global registration-code failure counter (429 when locked).
- Atomic TOTP replay claim; minimum TOTP secret length.
- Shallow clones with size/file-count watchdog (GIT_MAX_REPO_MB).
- Per-account push/pull budget (GIT_SYNC_RATE_LIMIT).

Co-authored-by: Cursor <cursoragent@cursor.com>

* Optional entry signing and Argon2id key protection

- Sign-then-encrypt entries with the PGP key (opt-in per device); a present but
  invalid signature blocks the entry, unsigned entries are flagged when
  signing is on. Settings: toggle + 'Sign all entries'.
- Opt-in Argon2id S2K when changing the PGP passphrase (shows current mode).
- Unit + E2E tests.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Pages _headers, loopback compose bind, test hooks only in E2E builds

- frontend/public/_headers: CSP and security headers for Cloudflare Pages.
- CSP allows 'wasm-unsafe-eval' (Argon2id key unlock needs WebAssembly).
- docker-compose publishes on 127.0.0.1 by default (BIND_ADDRESS/HOST_PORT).
- window.__webpass only exists in VITE_E2E builds; CI checks the prod bundle.
- Server does not serve _headers/.gitkeep.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Docs: transfer v2, entry signing, Argon2id, new env vars, upgrade notes

README, AGENTS.md, CONTRIBUTING.md, .env.example and the OpenBSD env example
describe the new behaviour, limits, E2E build flavour and compatibility.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: rdu64 <rdu64@arm64.dev>
Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: rdu64 <rdu64@arm64.dev>
Co-authored-by: Cursor <cursoragent@cursor.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