Skip to content

Fix the high and medium findings of the security review - #28

Merged
ssenerg merged 1 commit into
mainfrom
security-fixes
Oct 25, 2026
Merged

ssenerg merged 1 commit into
mainfrom
security-fixes

Conversation

@ssenerg

@ssenerg ssenerg commented Oct 25, 2026

Copy link
Copy Markdown
Owner

Fixes the high and medium findings of the security review, and a few cheap low ones in the same code.

High

  • Two-factor codes could be guessed without limit. Wrong codes only counted against the client's budget, so someone with the password and many IPv6 addresses could keep guessing. Wrong codes now also count against the account, from any address and either sign-in path. After 5 in a row, the next code waits a minute, then twice as long after each wrong one, up to a day. A right code resets the count. Refused codes aren't checked, get 429 with Retry-After, and are logged as login codes refused. Input too short or long to be a code doesn't count.

Medium

  • A stolen session could make an app password. Making one now asks for the password, like making a passkey. The form has a password field, and scripts send password.
  • Upload links' use and size limits could be beaten. A HEAD sent just as an upload was stored gave the link's use and bytes back. Now the use is only given back if the upload's row was really deleted, and a stored upload's row is deleted before its temp file is removed.
  • Folders and empty files skipped quotas and the free-space floor. Each folder now counts 4 KiB against a home's quota. Making a folder, copying a folder, or making any file (empty ones too) first checks upload.min_free and the last 1% of the disk's inodes.
  • Share links came back at a recreated path. Links now follow a rename or move, and end on delete, also when the parent folder is deleted. A file uploaded again keeps its links. Through WebDAV, a file replaced by a MOVE keeps them, since apps save that way; a replaced folder loses them, as its folder shares already did.
  • Container logs weren't rotated. Compose now keeps the last 50 MB of each container's log.

Low, in the same code

  • Two-factor setup asks for the password, so a stolen session can't turn it on with its own secret and lock the owner out.
  • Reset race: an app password or passkey being made while the password changes is now refused, as sessions already were.
  • Deleting re-checks the entry after taking its lock.
  • Access log: requests with unknown HTTP methods no longer log share or upload tokens.
  • Passkeys: the host name is copied out of Fiber's reused request buffer.

Not in this PR

  • Zip downloads still have no entry limit.
  • Low findings left as they are:
    • anonymous visitors can fill the passkey ceremony table;
    • CI publishes :latest before tests and govulncheck pass;
    • grantees can see the owner's older trash entries;
    • WebDAV shows grantees the owner's quota;
    • a running zip download or upload outlives a revoke;
    • temp folders left by a crash stay;
    • concurrent uploads can run slightly past upload.min_free;
    • WebDAV locks can be filled;
    • the Postgres image is unpinned;
    • findings that depend on settings.

Rollout

  • Log rotation needs one manual step. The server's /opt/goftp/docker-compose.yml is root-owned, so the deploy won't update it. Install it again as the README describes. The next compose up then recreates both containers, which restarts Postgres for a moment.
  • Usage goes up a little. Homes with folders show 4 KiB more per folder after the next count.
  • Scripts need the password now. Scripts that create app passwords (/.sync/ action=create) or start two-factor setup (action=start) must send password.

Tests

  • New tests:
    • TestWrongCodes, and TestTwoFactorCodeLimit over HTTP;
    • password checks in the app password, sync page and two-factor tests;
    • TestResumableLinkUseKept (it fails against the old store behavior);
    • free-space checks for empty files, folders and copies in TestMinFree;
    • TestHomeQuotaFolders;
    • TestLinkFollowsItsEntry.
  • go test ./... passes on Linux (golang:1.27.3-alpine) against Postgres 18. -race passes on macOS, apart from the known macOS-only TestLongNonASCIIPath.
  • Checked in a browser: wrong and right passwords on the Sync form, and the new password field on the two-factor page.

🤖 Generated with Claude Code

- Count wrong two-factor codes per account, wherever they come from:
  after 5 in a row, each next code waits a minute, then twice as long
  after each wrong one, up to a day. The client's budget alone let
  someone with the password guess codes from many addresses.
- Ask for the password to make an app password, or to set up
  two-factor sign-in, so that a stolen session cannot become a lasting
  WebDAV login or lock its user out. App passwords and passkeys made
  while the password changes are refused, as sessions already were.
- Give an upload link's use back only for an upload really forgotten,
  and forget a stored upload before removing its temp file: a HEAD at
  that moment gave the use and its bytes back.
- Count folders against home quotas (4 KiB each), and check the free
  space, and the last 1% of the disk's inodes, before folders and empty
  files are made, which no write checked before.
- Have links follow what they lead to when it is renamed or moved, and
  end when it is deleted, so that none leads to what is made in its
  place.
- Keep the last 50 MB of each container's log.
- Also: re-check an entry after locking it for deletion, keep tokens out
  of the log line of unknown methods, and copy the passkey host name out
  of the request buffer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ssenerg
ssenerg merged commit ec8d156 into main Oct 25, 2026
4 checks passed
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