oliver-zehentleitner / maity

clean-up: G7 sign-in routes: the anonymous entry points check Sec-Fetch-Site and credentials differently; registration takes same-site (may concern security)

Sign in to report

tsk-hkgnd1dp0c9c Done An agent

From the clean-up audit tsk-hgnbapyw7hnh (uncovered files, G7 sign-in, joining, landing and notification routes), read at 9dfd4b65. Every line number is at 9dfd4b65. Paths are under hub/src/maity_hub/ unless they start with docs/ or hub/tests/.

This card may concern the security team. Items 1 and 2 are a CSRF rule on anonymous sign-in and sign-up calls. The impact found by reading is low (see each item). No card found that covers it: searched the card text for Sec-Fetch-Site, same-site and cross-site registration.

1. Bug (contract divergence): POST /auth/register accepts Sec-Fetch-Site: same-site

  • Kind: likely bug, security weight low.
  • Files: routes/registration.py:135 refuses only cross-site. docs/api.md:2239-2240 (§2.7.1) says registration keeps "the rules of §2.6.5 for transport, Sec-Fetch-Site and next", and §2.6.5 (docs/api.md:1889-1893) refuses cross-site and same-site. The other anonymous calls follow §2.6.5: routes/device_codes.py:88 (device login), routes/email_sign_in.py:60 (mail link and code), routes/password_reset.py:30 and :72 (reset, through the same guard).
  • Tests: hub/tests/test_device_codes.py:283, hub/tests/test_email_sign_in.py:270 and hub/tests/test_register_page.py:145 refuse same-site; nothing tests POST /auth/register with it.
  • Impact: a page on a sibling host under the same registrable domain can start a registration in a visitor's browser. It sets no session (the answer is 202, the link goes to the address in the body), so the visible effect is a mail and a pending row counted against the address's limits. Not verified on a running hub.
  • Proposal: refuse same-site as §2.6.5 does, through the shared guard of item 3, and add the test.
  • Effort: S. Risk: low; the dashboard's form posts same-origin.

2. Docs drift: §2.6.5 says the device and mail calls refuse same-site "like a login", but the login does not

  • Kind: docs drift, security weight low.
  • Files: docs/api.md:1889-1891 (§2.6.5: POST /auth/device-login, …/complete, /auth/email-link and /auth/email-code "refuse a Sec-Fetch-Site of cross-site or same-site (forbidden), like a login (§2.1)"). §2.1 (docs/api.md:463) and routes/auth.py:109 refuse only cross-site.
  • What is wrong: one of the two texts is wrong. If §2.1 is right, a same-site page can post a password login in a visitor's browser (login CSRF needs the attacker's own password, so it signs the visitor into the attacker's account).
  • Proposal: decide (open question); then either the login refuses same-site too (code, §2.1 and a test), or §2.6.5 drops "like a login".
  • Effort: S. Risk: low.

3. Duplication: four entry points, three ways to refuse a credential

  • Kind: duplication, design.
  • Files:
  • routes/auth.py:105-110 (login): an Authorization header is forbidden with no details.reason; TLS; cross-site only.
  • routes/registration.py:131-136 (register): an inline ApiError with humans_only; TLS; cross-site only.
  • routes/device_codes.py:82-89 (_anonymous, device login, used by the mail and reset flows too): humans_only; TLS; cross-site and same-site.
  • routes/email_sign_in.py:301-303 (the link page GET): humans_only and TLS, written again.
  • What is wrong: docs/api.md:194 and §2.10 (docs/api.md:3360-3362) answer an agent or runner credential with humans_only; the login does not. Each entry point has its own copy, which is how item 1 came about.
  • Proposal: one guard, for example anonymous_entry(request) (credential humans_only, TLS, Sec-Fetch-Site per §2.6.5), in the shared sign-in module proposed on the companion card, used by login, register, device login, the mail flows and the reset.
  • Effort: S. Risk: low; the login's error gains details.reason.

Order

  • Decide item 2 first; item 3's guard then carries one rule for all.
  • Items 1 and 3 fit one PR with the move of _anonymous on the companion card ("clean-up: G7 sign-in routes: one sign-in completion …", item 5).

Open question

  • Should the password login refuse Sec-Fetch-Site: same-site like the other anonymous sign-in calls (§2.6.5), or does §2.1's "cross-site only" stand?

Covered elsewhere

  • The registration limit copy and the device-code breaker: tsk-5sfts81hr516.

Effort sum: 3 S.