docs(quick-batch-261105-oc4): security hardening batch, 5 items, 12 todos closed

This commit is contained in:
Jakub Zych
2026-11-05 18:46:35 +01:00
parent 27c98bf22a
commit 895248eef2
23 changed files with 2470 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
---
title: activate-by-code mints a session without the second factor when require_activation is off (finding F-1)
date: 2026-10-26
priority: low
area: sm-user-plugin
g15office: yfadd1mb
---
sm-user-plugin's `POST /_user/api/v1/activate-by-code` signs the account in (`mintFor`) without asking the login gates. Phase 19.6 plan 01 accepted that path because "a new or not-yet-activated account cannot have 2FA yet". That reason holds only with the default `golem15.user.activation.require_activation: true`. With `require_activation: false` and `activate_mode: user`, a not-activated account signs in with its password, can enable TOTP (sm-mfa-plugin), and a later activate-by-code with the mailed activation code answers `{"message":"Account activated","token":…}` with no challenge. The mailbox alone then stands in for the second factor, which a password reset does not allow (a reset mints no token).
Found and reproduced by 19.6-04 (security review finding F-1, 19.6-SECURITY-REVIEW.md "Open findings"): register in mode user, password login, TOTP setup and confirm, the next password login is challenged, `IssueActivationCode`, activate-by-code answers 200 with a token.
The user deferred it at 19.6-04 Task 5 (2026-10-26). Impact is low: it needs the non-default configuration, a user who enabled a second factor before activating, and the user's unexpired activation code.
To fix later:
- In `ActivateByCode`, after `VerifyActivationCode` succeeds, call `CheckLoginGates` for the user (a source the mfa gate challenges, for example `LoginSourcePassword`, or a new `LoginSourceActivation` together with an sm-mfa-plugin gate change) and answer the gate's body instead of the token; the account stays activated.
- Add a test in sm-user-plugin (a gate that challenges, then activate-by-code answers the challenge) and an end-to-end case in sm-mfa-plugin's `TestEveryLoginPathIsGated`, and update its `tokenMints` reason.
- Release sm-user-plugin as a patch and bump sm-demo-app, sm-bm-app and fonoteka.go in separate commits (D-17 order).
- Until then, `TestEveryLoginPathIsGated/mint_sites` lists `ActivateByCode` with a pointer to F-1, so any change to the mint sites fails until the list is updated.
## Closed 2026-11-05
Fixed in quick 261105-oc5: sm-user-plugin b179e6b (activate-by-code asks the login gates). Untagged; release sm-user-plugin v0.1.20 and bump the apps.

View File

@@ -0,0 +1,20 @@
---
title: Require re-authentication to change two-factor factors (review finding WR-05)
date: 2026-10-26
priority: normal
area: sm-mfa-plugin
g15office: krt3vrts
---
Phase 19.6 code review WR-05 (19.6-REVIEW.md, 19.6-REVIEW-FIX.md): changing second factors needs only a session JWT. PHP and the frontends send no password on `DELETE /2fa/totp`, `DELETE /2fa/email`, `DELETE /2fa/webauthn/{id}`, `POST /2fa/totp/confirm` (when TOTP is already on) and `POST /2fa/webauthn/register`, so a stolen session can change factors while it lasts.
Partial mitigation shipped in sm-mfa-plugin v0.1.2 (463c750): a password change demotes passkeys to second-factor keys, so a passkey registered from a stolen session does not outlive the victim's password change.
Full fix (a contract change, user deferred it on 2026-10-26):
- Require a `password` field (or a current factor) on those routes, refused with the existing 403 `{"error":"Password confirmation required."}` and counted in the login throttle like the recovery-code routes (WR-06, 0a08070).
- Update the frontends that call them (sm-demo-app's vue-demo-app `pages/account/security.vue` and any app frontend) to ask for the password.
- Release sm-mfa-plugin as a minor/patch together with the frontend change, and bump the apps in separate commits.
## Closed 2026-11-05
Fixed in quick 261105-oc5: sm-mfa-plugin 3aa52c6 (golem15.mfa.factor_changes_require_password, default true), vue-demo-app 848ee1e, sm-demo-app 7b75d2c. Untagged; release sm-mfa-plugin v0.2.0.

View File

@@ -0,0 +1,25 @@
---
title: attach.StaticHandler does not send the stored Content-Disposition
date: 2026-10-28
created: 2026-10-28T20:50:55.000Z
area: lagoon/attach
severity: minor
priority: normal
g15office: knuu7fil
files:
- modules/lagoon/attach
---
## Problem
Follow-up from quick 261028-rqe (ba8432c, 4957e5c). `attach.Store` saves `Content-Disposition: attachment` for non-inline types and the surf uploads route sends it, but `attach.StaticHandler` and `attach.StaticHandlerPublic` serve blobs without the stored disposition, so an app that mounts them directly serves an HTML body inline.
## Solution
- Make both handlers send the stored disposition (and `X-Content-Type-Options: nosniff`), additive.
- Blob writers that bypass `attach.Store` can adopt `attach.IsInlineContentType`: fonoteka.go `storeUpload`/`StorePublicFile` (see `2026-10-28-fonoteka-uploads-use-disk-extension.md`), the sm-user-plugin avatar writer, the sm-feedback-plugin screenshot writer.
- Adding the disposition to objects already in a bucket stays an operator task (documented in `docs/services/storage.md#deploy-note`).
## Closed 2026-11-05
Fixed in quick 261105-oc8: summercms.go 27c98bf. Writers that bypass attach.Store (fonoteka.go, sm-user avatar, sm-feedback screenshot) remain follow-ups.

View File

@@ -0,0 +1,25 @@
---
title: Make pinning in public channels a manage action, and check the pinned message belongs to the channel
date: 2026-11-03
priority: high
area: sm-chatchannels-plugin (classes/channel_service.go, api/pins.go), sm-demo-app plugins/demo/classes/chat_context.go
files:
- ../sm-chatchannels-plugin/classes/channel_service.go
- ../sm-chatchannels-plugin/api/pins.go
- ../sm-demo-app/plugins/demo/classes/chat_context.go
g15office:
---
## Problem
chatchannels gates PinMessage and UnpinMessage only with channel access, which the demo grants every member. So any visitor can unpin the seeded welcome pins or flood the pins panel. PinMessage also never checks that the message belongs to the channel's conversation.
## Solution
Additively in chatchannels: PinMessage and UnpinMessage require CanManageContext, or an optional contracts.PinPolicy the host implements; the demo answers it from its moderator group. Verify message.conversation_id equals the channel's conversation before creating the pin. Meanwhile the demo layer can hide pin actions for non-moderators, but the server must enforce the rule.
Source: phase 20 code review (20-REVIEW.md WR-02).
## Closed 2026-11-05
Fixed in quick 261105-oc6: sm-chatchannels-plugin a042536, sm-demo-app ce800f2/7e4b9d3/11d3afc. Untagged; sm-bm-app needs CanPin before it bumps.

View File

@@ -0,0 +1,24 @@
---
title: A server-side DM-only rule for calls, not the seeded participant count
date: 2026-11-03
priority: medium
area: sm-chatvideo-plugin classes/video_service.go, sm-demo-app config/golem15.chatvideo.yaml
files:
- ../sm-chatvideo-plugin/classes/video_service.go
- ../sm-demo-app/config/golem15.chatvideo.yaml
g15office:
---
## Problem
The server has no DM-only rule; channel calls are refused today only because the seeded personas plus a visitor exceed max_participants: 4. Raising the cap, or a channel with fewer participants, would let any member ring everyone who opened that channel.
## Solution
Add an optional host hook in chatvideo (for example CanStartCall(conversationType)), or check conversation.type == dm in the demo, so the rule does not depend on seed data.
Source: phase 20 code review (20-REVIEW.md IN-01).
## Closed 2026-11-05
Fixed in quick 261105-oc7: sm-chatvideo-plugin 11a9607 (contracts.CallPolicy, DMOnly), sm-demo-app fbfdcf6.

View File

@@ -0,0 +1,23 @@
---
title: The incoming-call runtime closes stale session handles
date: 2026-11-03
priority: medium
area: vue-chatvideo-layer app/composables/useIncomingCalls.ts
files:
- ../vue-chatvideo-layer/app/composables/useIncomingCalls.ts
g15office:
---
## Problem
Two video:call:incoming events for the same session, both pending in subscribe, both pass the pending-session check; the second overwrites rt.channel and the first handle is never closed. The logout half of this finding was fixed in phase 20 plan 08 (the demo's sign-out dismisses the ring); the handle leak remains.
## Solution
Keep a sequence number per watchSession and close the handle unless it is the latest.
Source: phase 20 code review (20-REVIEW.md IN-07).
## Closed 2026-11-05
Fixed in quick 261105-oc7: vue-chatvideo-layer 6d5784d. Untagged.

View File

@@ -0,0 +1,24 @@
---
title: chatvideo honours live membership, so a ban ends call access at once
date: 2026-11-03
priority: medium
area: sm-chatvideo-plugin classes/video_service.go, classes/authorizer.go
files:
- ../sm-chatvideo-plugin/classes/video_service.go
- ../sm-chatvideo-plugin/classes/authorizer.go
g15office:
---
## Problem
chatvideo checks participant rows only. A ban revokes the user's JWTs, but an already minted LiveKit join token (900 s) and an open video:session subscription survive it, because chatvideo never consults contracts.LiveMembership as chat does.
## Solution
Have chatvideo honour LiveMembership (through chat's Service.IsParticipant) in requireParticipant and the authorizer, and remove the participant from the LiveKit room on a ban.
Source: phase 20 code review (20-REVIEW.md IN-02).
## Closed 2026-11-05
Fixed in quick 261105-oc7: sm-chatvideo-plugin f996156. Untagged.

View File

@@ -0,0 +1,23 @@
---
title: check-local passes member JWTs to curl through a config on stdin, not argv
date: 2026-11-03
priority: low
area: sm-demo-app scripts/check-local.sh
files:
- ../sm-demo-app/scripts/check-local.sh
g15office:
---
## Problem
check-local still puts member JWTs into -H "Authorization: Bearer ..." arguments, readable by other local users in /proc/*/cmdline. The LiveKit join token and the new check-moderation.sh already use a curl config on stdin. Local and throwaway users only, but inconsistent with the stated pattern.
## Solution
Give request() an optional JWT that it writes as header = "Authorization: Bearer ..." into a curl config on stdin (curl -K -), as check-moderation.sh does, and drop every -H Authorization argument.
Source: phase 20 code review (20-REVIEW.md IN-03).
## Closed 2026-11-05
Fixed in quick 261105-oc9: sm-demo-app 55620dc.

View File

@@ -0,0 +1,23 @@
---
title: GET /_demo/api/v1/chat/members is read-only and needs no id list
date: 2026-11-03
priority: medium
area: sm-demo-app plugins/demo/chat_api.go
files:
- ../sm-demo-app/plugins/demo/chat_api.go
g15office:
---
## Problem
The GET assigns handles to members that lack one (two concurrent first loads race on the same rows) and expands every member id into id IN ?, which fails with 500 past Postgres' 65535 bind-parameter limit. The production reset schedule is off, so users accumulate.
## Solution
Select with the memberWhere subquery (WHERE id <> ? AND <memberWhere>) instead of an id list, and assign missing handles at registration or in demo:seed, not in a GET.
Source: phase 20 code review (20-REVIEW.md IN-09).
## Closed 2026-11-05
Fixed in quick 261105-oc9: sm-demo-app 9595606.

View File

@@ -0,0 +1,24 @@
---
title: nginx proxies only LiveKit's /rtc paths, not its whole HTTP surface
date: 2026-11-03
priority: low
area: sm-demo-app deploy/nginx/demo.summercms.io.conf, scripts/check-deploy.sh
files:
- ../sm-demo-app/deploy/nginx/demo.summercms.io.conf
- ../sm-demo-app/scripts/check-deploy.sh
g15office:
---
## Problem
Browsers need only /rtc and /rtc/validate, but the /livekit/ location also exposes LiveKit's Twirp RoomService on the public origin. It is protected by admin JWTs signed with the API secret, so exposing it is unnecessary.
## Solution
Use location ^~ /livekit/rtc { proxy_pass http://127.0.0.1:7890/rtc; ... } and answer 404 for the rest of /livekit/; adjust check-deploy and check-live. A vhost change on rome needs its own go-ahead.
Source: phase 20 code review (20-REVIEW.md IN-06).
## Closed 2026-11-05
Fixed in quick 261105-oc9: sm-demo-app 6c52514. Committed only; installing the vhost on rome needs its own go-ahead.

View File

@@ -0,0 +1,23 @@
---
title: demo:seed fills the default moderation lists only on the first run
date: 2026-11-03
priority: low
area: sm-demo-app plugins/demo/console/seed_friends.go
files:
- ../sm-demo-app/plugins/demo/console/seed_friends.go
g15office:
---
## Problem
seedModerationLists refills both lists whenever both are empty, and every release runs demo:seed. An admin who deliberately empties both lists gets the defaults back at the next deploy.
## Solution
Seed only once: insert the lists when the settings row is created, or record a seeded flag.
Source: phase 20 code review (20-REVIEW.md IN-05).
## Closed 2026-11-05
Fixed in quick 261105-oc9: sm-demo-app 5630d92 (golem15.demo migration).

View File

@@ -0,0 +1,23 @@
---
title: The VAPID runbook step runs with pipefail and appends the keys only when both exist
date: 2026-11-03
priority: low
area: sm-demo-app DEPLOY.md (Chat family, VAPID keys)
files:
- ../sm-demo-app/DEPLOY.md
g15office:
---
## Problem
The remote script uses set -e without pipefail. If herald:vapid-generate fails, nothing is appended but the SUBJECT line, and the re-run guard then refuses ("already in .env") although no key pair exists; recovery needs a hand edit. The keys are already on rome; this matters for a rebuild.
## Solution
Use set -eo pipefail, generate into a variable first, check both keys are non-empty, then append all three lines in one tee.
Source: phase 20 code review (20-REVIEW.md IN-08).
## Closed 2026-11-05
Fixed in quick 261105-oc9: sm-demo-app 054cda5.