Repository navigation
Reject existing-user claims in FastAPI signup flow - #204
PrivateBasicsApp wants to merge 41 commits into
Conversation
Details: - base.txt: Django >=5.2,<6.0, pin fastapi==0.138.2, and raise the redis floor to >=5.0 (drops the 4.2.0rc1 pre-release marker that was keeping the runtime on the redis 5.1.0b6 beta) - development.txt: constrain dev deps to the runtime pins via -c requirements.txt - Regenerate both lockfiles with pip-compile --generate-hashes for reproducible, hash-verified installs Runtime now requires Python >=3.10 (Django 5.2).
+ pyproject.toml: set DJANGO_SETTINGS_MODULE for pytest-django + dev deps: add pytest-django (requirements.in/development.txt + regenerated requirements-dev.txt)
Chore/update dependencies (Django 5.2, FastAPI 0.138 + security)etesync#205
…signup Fix/tenant isolation and signup
Signed-off-by: PrivateBasicsApp <privatebasicsapp@proton.me>
Signed-off-by: PrivateBasicsApp <privatebasicsapp@proton.me>
Signed-off-by: PrivateBasicsApp <privatebasicsapp@proton.me>
- **Ticket TTL**: `ex` is in seconds, so tickets lived 10000 s instead of 10. They now expire after 60 s, which leaves room for slow networks, and they are still single-use. - **Pub/sub**: the connection is released when the session ends. - **Push**: updates are forwarded again, only to users who are still active members of the collection. Membership is checked when the session opens and before each message. Collection keys are not rotated when a member is removed, so without this check a removed member would keep receiving new items they can decrypt.
Signed-off-by: PrivateBasicsApp <privatebasicsapp@proton.me>
…-types The ticket is now created as a `str`, as `TicketOut` declares, and the value read back from Redis is cast to `bytes`, since the client is created without `decode_responses`. There is no behavior change, because the Redis key stays the same. This removes the two mypy errors in `websocket.py`.
Signed-off-by: PrivateBasicsApp <privatebasicsapp@proton.me>
Signed-off-by: PrivateBasicsApp <privatebasicsapp@proton.me>
Signed-off-by: PrivateBasicsApp <privatebasicsapp@proton.me>
…word-change The `change_password` now deletes other user's tokens in the same transaction as the key update.
**Malformed `Authorization` header**: a header without a token or with extra parts now gets 401 `authentication_failed` instead of an `IndexError` + handle lookups and conflicts that returned 500
Signed-off-by: PrivateBasicsApp <privatebasicsapp@proton.me>
Signed-off-by: PrivateBasicsApp <privatebasicsapp@proton.me>
Signed-off-by: PrivateBasicsApp <privatebasicsapp@proton.me>
An incoming invitation is now valid only while its sender is still an active admin of the collection. Before, an invitation could still be accepted after its sender had been demoted or deactivated, so a former admin could keep granting access. The check is in the incoming queryset, so list, get, accept and reject all treat such an invitation as missing: 404, with the same response as an unknown uid. - If the sender becomes an active admin again, the invitation is valid again, as if it had just been sent. - The invitee can no longer reject such an invitation. It stays in the database until the sender deletes it or leaves the collection. - The Android app does not catch errors from accept and reject (`InvitationsListFragment.kt`), so this 404 is likely to crash it. The same already happens on master when an invitation is deleted while the list is open.
A chunk upload writes the file before saving its row. When the row could not be saved, for example on a re-upload of an existing chunk (409 `chunk_exists`), the file stayed on disk with no row pointing to it, and repeated uploads could fill the disk. The file is now deleted when saving the row fails with any database error: a conflict, or a value the database rejects, such as a uid too long for its column on PostgreSQL. The row is now saved once instead of twice. Responses are unchanged.
fix(api): validate and cap the limit of list endpoints The `limit` parameter of the seven list endpoints (collections, `list_multi`, items, revisions, members, incoming and outgoing invitations) must now be at least 1 and is capped at 500. Before, `limit=0` or `-1` returned an empty page with `done=False`, so a client following `done` never finished; `-2` or lower caused a 500; and a page had no upper bound. Values below 1 now get 422. A larger limit is served in pages of 500, and clients get the rest by following `done`, as they already do. The default stays 50.
fix(websocket): advance the stoken during catch-up When a websocket session opens, the server sends the items changed since the client's `stoken`, in pages of 50. The loop never advanced the `stoken`, so with more than 50 changed items it sent the first page over and over, contents included, until the client disconnected. It now moves on to the next page each time and stops at `done`.
Signed-off-by: PrivateBasicsApp <privatebasicsapp@proton.me>
fix(api): limit the size of request bodies A middleware now counts the body as it arrives and rejects it with 413 `request_too_large` as soon as it exceeds the limit, so it never reads more than the limit. The default limit is 100 MiB, and `max_request_size` (in bytes) in the `[global]` section of the ini changes it.
build(deps): update anyio to 4.14.2 (handle security warning)
build(deps): update pip-tools to 7.6.2
build(deps): update django to 5.2.18
build(deps): update sqlparse to 0.6.1
|
This PR is a lot of commits that do much more than what the title/description say. |
|
You're right, sorry about that. I opened the PR from a branch on my fork, but I kept merging other fixes into my fork's master along the way, and those commits ended up in this PR too. That wasn't intended. I'll clean it up so it only contains the changes described in the title. Would you prefer I force-push this PR or close it and open a new one? |
|
Sorry again for the noise. Your modernization changed the base a lot (uv, the msgpack rewrite, the new test suite), so instead of force-pushing I'll close #204, #205, #207 and #208 and open small PRs from branches based on your current master: one fix each, with tests in your suite, passing your CI. #205 and #208 are superseded by your dependency updates. I'm dropping the change in #204's title: it would block the activation of users created in the admin. What's left is about a dozen fixes. Several are security-related: access control on chunks, websocket push after #198, invitations, auth tokens. @tasn Would you like the details of those privately first? If so, what's the best channel? The rest are robustness fixes (a few 500s, list limit validation, Redis pub/sub connections not being released) that I can open right away, one at a time. |
|
Closing this as announced. The first focused PR is #210: it fixes the |
Prevent unauthenticated account takeover where
/signup/could initializeUserInfofor a pre-provisioned user and immediately return a valid auth token.Details:
signup_save(etebase_server/fastapi/routers/authentication.py) check for an existing username viaget_user_queryset(...).get(...)and immediately raiseHttpError("user_exists", ...)(HTTP 409) if found.