Skip to content

Add the built-in OAuth 2.0 API (1.1.0) - #594

Open
James-Chapman wants to merge 43 commits into
mainfrom
feature/oauth-20-v110
Open

James-Chapman wants to merge 43 commits into
mainfrom
feature/oauth-20-v110

Conversation

@James-Chapman

Copy link
Copy Markdown
Collaborator

Summary

Adds the Matrix OAuth 2.0 API (spec v1.19) to the homeserver itself, so a client that only signs in through it, such as Element X, can register and log in. It is off by default (server.oauth.enabled). Version 1.1.0; main at 1.0.3 is merged in.

What changed

  • Discovery and client registration: GET /_matrix/client/v1/auth_metadata, and RFC 7591 dynamic registration at /_merovingian/oauth2/register. A client ID is a keyed hash of the accepted metadata; oauth_clients and oauth_sessions are migration 002.
  • Authorization code grant: /_merovingian/oauth2/authorize serves the login, registration and consent pages from the binary, with no JavaScript. PKCE S256 only, codes last 60 seconds and are single use, and a replayed code ends the session it produced.
  • Token endpoint: code, refresh and device-code grants at /_merovingian/oauth2/token, with one transaction per grant, and RFC 7009 revocation at /_merovingian/oauth2/revoke.
  • Account pages at /_merovingian/account: devices, sign-out, password change, deactivation, and approval of a cross-signing reset (the m.oauth UIA stage).
  • Legacy API: stays on by default; server.oauth.legacy_api_enabled turns it off. With both on, the SSO redirects hand a legacy client off to the OAuth sign-in. UIA endpoints answer an OAuth session 403.
  • Device authorization grant (RFC 8628), off by default (server.oauth.device_grant_enabled).
  • Config: server.oauth.* replaces server.oidc.*; the old keys are refused at start.
  • Legacy path changes: POST /keys/device_signing/upload follows the spec's UIA exemptions for every session (ADR-0794), and POST /refresh lists a device under its stored display name after a restart.
  • FreeBSD: the rc.d script sets merovingian_limits to -l 128m; the OAuth client ID key is derived per registration instead of holding a locked page for the life of the process; an unreadable registration token now logs registration.token_file_unusable.
  • Docs: ADR-0766 to ADR-0817, the threat model, the security review checklist, the user manual, and the plan in docs/todos/oauth-2-0-api.md with what is still open.

Why it changed

Element X creates accounts only through the OAuth 2.0 API, and the server answered auth_metadata with 404, so account creation failed with "Your account provider needs to be upgraded to support Matrix Authentication Service". Building the API in avoids running a separate authentication service.

Not done, and listed in the plan:

  • Nobody has yet signed in with Element X or a real browser against a server built from this branch. The suite drives the handlers directly, so cookie handling, SameSite, the CSP on redirects and deep links are unproven outside it.
  • No PostgreSQL scenario has run on this branch (the build VMs have no PostgreSQL), and the 1.0.x upgrade fixture is not on this branch.
  • The MSC4108 rendezvous is not part of 1.1.0, so Element X's QR-code login stays unavailable.
  • mkdocs build --strict has not been run for this branch.

Local verification at a8a4b42b: Linux VM 88 OK, 0 failed; FreeBSD VM 87 OK, 0 failed, 1 skipped.

CI tests

Modified:

  • tests/conformance/: test_account_lifecycle_conformance.cpp, test_client_server_conformance.cpp, test_route_query_conformance.cpp
  • tests/integration/: test_client_server_endpoints_flow.cpp, test_database_upgrade_flow.cpp, test_http_server_listener_flow.cpp, test_persistent_homeserver_flow.cpp, test_postgresql_store_behaviour_flow.cpp, test_retention_sweep_flow.cpp
  • tests/unit/: test_config_sso.cpp, test_crypto_token_key_cache.cpp, test_database_persistence.cpp, test_http_rate_limit_tiers.cpp, test_observability.cpp, test_worker_table_load_profile.cpp
  • tests/tooling/test_example_config.py

New:

  • tests/conformance/test_oauth_*_conformance.cpp (8 files): metadata, client registration, authorization, token, account management, legacy API, OAuth-aware clients, device grant
  • tests/integration/test_oauth_*_flow.cpp (11 files): metadata, client registration, password login, account creation, authorization, token, account pages, legacy API, login hand-off, device grant, log query; and test_request_exception_flow.cpp
  • tests/unit/: test_oauth_*.cpp (20 files), test_core_form_fields.cpp, test_core_host_cookie.cpp, test_core_request_cookies.cpp, test_http_response_head.cpp, test_config_oauth.cpp, test_crypto_oauth_client_id.cpp, test_database_oauth_store.cpp, test_legacy_auth_policy.cpp
  • tests/fuzz/: fuzz_form_fields.cpp, fuzz_request_cookies.cpp, fuzz_oauth_scope.cpp, fuzz_oauth_redirect_uri.cpp, fuzz_oauth_client_metadata.cpp, with corpora
  • tests/tooling/: test_page_text_member_initialisers.py, test_rcd_locked_memory.py

🤖 Generated with Claude Code

James-Chapman and others added 30 commits November 15, 2026 20:40
Element X creates accounts only through the Matrix OAuth 2.0 API, and
Merovingian answers its discovery request with 404, so account creation
from Element X fails.

- Bump every version location to 1.1.0, the first build of the 1.1 series.
- Add docs/todos/oauth-2-0-api.md: the design, twelve phases, and the
  proposals that still need the owner's confirmation before their phase.
- Record the owner's decisions: the API is built into the homeserver
  (ADR-0760), the legacy API stays on by default with a key to turn it
  off (ADR-0761), the registration page applies security.registration.*
  (ADR-0762), the pages are compiled in without JavaScript (ADR-0763),
  and server.oauth.* replaces server.oidc.* (ADR-0764).
- Link the plan from the docs navigation and the capability-gaps row.

No server behaviour changes in this commit.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…to core (ADR-0765, ADR-0766)

core::FormFields::parse reads application/x-www-form-urlencoded bodies for
the OAuth 2.0 endpoints and pages, refusing the whole body on a malformed
escape, an empty or '='-less field, a raw byte outside printable ASCII, a
decoded NUL or invalid UTF-8, a repeated name, or any cap exceeded.

core::RequestCookies::parse reads a Cookie header; a malformed or repeated
cookie makes only its own name unusable, so a tossed cookie can neither
supply a value nor break the pages. core::host_cookie and
host_cookie_deletion are the only Set-Cookie writers.

The UTF-8 validator moves from canonicaljson to core (canonicaljson now
links core, which src/meson.build builds first), and the RFC 9110 token
check behind http::header_name_is_valid moves to core::http_token_is_valid.
Unit tests and fuzz targets for both readers.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…r names case-insensitively (ADR-0767)

The response formatter moves from HttpServer.cpp to http/ResponseHead.hpp.
A handler's Content-Type in any letter case now replaces the default
instead of adding a second one. A header with CR, LF or another control
character, an invalid name, a handler's Content-Length, Transfer-Encoding,
Connection or Keep-Alive, a second Content-Type or X-Content-Type-Options,
or a status outside 200-599 turns the response into a fixed 500 with
Connection: close, logged as response.head_refused, where it used to be
dropped silently or written twice. 302, 303, 202, 409, 415, 451, 504 and
507 gain their reason phrases; any other status gets an empty phrase, not
OK. append_header_if_missing compares names case-insensitively.

Unit tests pin the exact bytes of an HTML page with a policy and cookies
and of 302 and 303 redirects; an integration test reads the SSO redirect
off a plain and a TLS listener. Docs: http-transport.md, the security
coding rules, CHANGELOG.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…:sha256 (ADR-0768, ADR-0769)

The oauth module holds the pure parts of the built-in OAuth 2.0 API: no
state, no I/O, no logging. A refusal is OAuthRefusal, the wire `error`
code beside a core::Error whose message is fixed text.

PKCE accepts only S256: a canonical 43-character challenge and a verifier
of 43 to 128 unreserved characters, compared in constant time, tested
with the RFC 7636 appendix B vector. parse_scope requires
urn:matrix:client:api:* and exactly one urn:matrix:client:device:<id>
whose ID is 10 to 255 unreserved characters, drops unknown tokens and
caps the scope at 2048 bytes and 32 tokens.

crypto::sha256 wraps crypto_hash_sha256 for protocols that name SHA-256.
Unit tests and a fuzz target for the scope parser.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…idation to oauth (ADR-0770, ADR-0771)

ParsedUri::read is the one reader for every address a client supplies: at
most 2048 bytes of printable ASCII, no fragment (a bare '#' included), no
userinfo, LDH host labels or a bracketed IPv6 literal with no '%' and no
trailing dot, a port of 1 to 65535 without a leading zero, and RFC 3986
pchar paths and queries. Nothing is decoded or normalised.

validate_redirect_uri applies the spec's web and native rules against a
validated ClientUri (https on a DNS name of two or more labels);
match_redirect_uri matches byte for byte, except that a native loopback
URI registered without a port matches any port. ClientMetadata::validate
applies the RFC 7591 rules the owner chose, and canonical_bytes gives the
same bytes for the same accepted metadata whatever the key order,
duplicate values or ignored members. The spec's redirect URI examples are
unit test cases; fuzz targets cover the reader, the redirect rules and the
metadata validator.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…dance (ADR-0772)

oauth::Page is the one renderer of every HTML page: a title and heading,
paragraphs, notice and error boxes, a detail list, https links that pass
ParsedUri::read, and a POST form to a compile-time PagePath with hidden
fields, labelled text and password inputs and one or two distinct submit
buttons. Every part takes HtmlText, made only by HtmlText::escape (which
refuses empty, over-4096-byte, non-UTF-8, control and bidirectional
formatting text) or from a consteval HtmlLiteral, so unescaped text does
not compile.

page_headers() gives Content-Type, a Content-Security-Policy whose only
style source is the SHA-256 of the fixed style block, X-Frame-Options,
Referrer-Policy and Cache-Control; page_headers(target) adds the matched
redirect URI's origin to form-action, built from its scheme, host and
port only. Unit tests put hostile strings in every slot and prove the
style hash.

The module gets its AGENTS.md and CLAUDE.md, rows in the root AGENTS.md,
architecture.md, auth-identity.md, the security coding rules and the
review skill's module invariants.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
auth's objects reach observability::SingleLog, so fuzz-oauth-scope failed
to link with -Dbuild_fuzz=true. With the two libraries added, all three
OAuth fuzz targets build and each ran 60 seconds on the Linux VM without
a finding.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… server.oidc.* (ADR-0773 to ADR-0775)

Phase 2 of the OAuth 2.0 API plan: configuration and metadata.

- server.oauth.enabled, legacy_api_enabled, device_grant_enabled and
  hand_off_redirect_allowlist are parsed, validated and restart-required.
- server.oidc.* is refused at start-up with a message naming
  server.oauth.enabled; OidcConfig and auth/OidcDiscovery are removed.
- With OAuth on, public_baseurl must be an https URL the strict reader
  accepts, and server.sso.authorization_url is refused.
- oauth::OAuthBaseUrl builds every OAuth address; oauth::server_metadata
  builds the auth_metadata document, served on the v1 and MSC2965 paths.
- auth_metadata stays in the generic rate-limit tier (ADR-0775).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The five targets added in phase 1 were registered in tests/fuzz/meson.build
but missing from scripts/run-fuzz-targets.sh, so the fuzz job never ran them
and tests/tooling/test_fuzz_targets.py failed.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…776 to ADR-0778)

Phase 3 of the OAuth 2.0 API: oauth_clients and oauth_sessions on SQLite and
PostgreSQL, hydrated at start-up, with the schema registry split by version so
a fresh and a migrated 1.0.x database reach the same schema by the same path.
delete_device removes a device's session row in its own transaction, the
retention sweep deletes sessionless clients unused for 30 days, and
merovingian-db-migrate --migrations plans only the files between its versions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…(ADR-0779 to ADR-0781)

POST /_merovingian/oauth2/register validates RFC 7591 client metadata and
answers 201 with a client ID that is a keyed BLAKE2b hash of the canonical
metadata, under a master-key-derived key with its own label, so a repeat
registration is the same row and costs no commit within a day. At most
10000 clients are held: at the cap up to 8 idle clients without a session
or pending authorisation are evicted, least recently used first, else 503
temporarily_unavailable. Every OAuth answer comes from one helper with
application/json and no-store. /_merovingian/oauth2/* and
/_merovingian/account* take the auth_sensitive tier, and 201 has its reason
phrase.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- PendingAuthorisationStore and AuthorizationCodeStore: in memory on
  HomeserverRuntime, 32-byte secrets kept as hashes, a digest index with
  constant-time confirmation, bounded (8192, 16 per address; 8192 codes),
  never evicting a live entry. oauth_client_has_pending_authorisation is
  answered from them in O(1); the test seam is gone. The idle-client walk
  examines at most max_idle_client_rows_examined rows.
- verify_login_credentials is the password check of POST /login, moved
  unchanged; verify_password_login adds the shared account-state gate.
  create_local_account makes /register's username checks and every
  registration gate with the caller's client key; /register passes
  127.0.0.1 as before.
- sanitized_http_target drops the whole query under /_merovingian/oauth2
  and /_merovingian/account.
- LocalHttpResponse::page: the boundary adds no CORS header to a page and
  wrap() leaves it alone.
- Referrer-Policy same-origin on pages, and form_post_origin_is_accepted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rize (ADR-0787 to ADR-0790)

GET validates the client and its redirect URI (a 400 page otherwise), then
redirects every later refusal with error, a fixed description and state, in
the query or the fragment. A valid request becomes a pending authorisation
bound to a __Host- cookie, answered with the login or registration page.
POST checks the form's origin, the cookie and the pending identifier, signs
in with verify_password_login or creates the account with
create_local_account, shows the consent page, and on approval redirects with
an authorization code. No device, token or OAuth session is created.

The pages and the redirect builder are pure functions in oauth; the handler
is OAuthAuthorization.cpp. request_header moves to RequestHeaders.cpp with a
values variant, the account gate of verify_password_login is exposed as
account_sign_in_gate, and the OAuth wall clock is one function.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…795)

POST /_merovingian/oauth2/token serves the authorization code grant
(PKCE S256, the redirect URI byte for byte, one transaction with the
audit row, a replayed code ending only the session it produced) and the
refresh token grant, for public clients only; an OAuth access token
always expires. POST /_merovingian/oauth2/revoke ends the session of an
access or refresh token as /logout does. POST /refresh and the refresh
grant refuse each other's sessions before rotating. Every UIA endpoint
answers an OAuth session 403 naming the account page, and
device_signing/upload now asks for UIA only to change held keys, as the
spec says.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… to ADR-0798)

/_merovingian/account signs a user in with their password into a fixed
15-minute in-memory session (hashed secret, __Host- cookie with
SameSite=Strict, a form token per session, Origin checked first), and
serves the overview, devices, device sign-out, password change,
deactivation and cross-signing reset approval. Each action calls the
client API's own function. An OAuth session's replacing cross-signing
upload is offered the m.oauth stage, completed by a one-use approval
given on the account page. The server metadata names the account
management URI and its actions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The user manual, auth, HTTP, audit and client-server API guides, the
module guidance, the security coding rules and the review skill now
describe the account pages and the m.oauth stage. The changelog lists
them under 1.1.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…isers (ADR-0799, ADR-0800)

The m.oauth stage of a replacing cross-signing upload now completes, with a
live approval, for a retry with no auth or no session, as polling clients
send it; the challenge reuses the user's live UIA session, so polling costs
one session, and offers org.matrix.cross_signing_reset as a second flow.

Clang 18 compiles a consteval HtmlLiteral call in a default member
initialiser as a run-time call. A tooling test now refuses such an
initialiser for the four page text types, and the one in AccountPage.cpp
is gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nabled=false (ADR-0801)

legacy_auth_refusal is the one decision every legacy route asks: GET /login,
a user's login, the SSO redirects and get_token answer 404 M_UNRECOGNIZED;
m.login.application_service and an appservice registration without
inhibit_login answer 400 M_APPSERVICE_LOGIN_UNSUPPORTED; a user's
registration 403 M_FORBIDDEN. Sessions already issued carry on, and with the
key true no answer changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… and a login token (ADR-0802)

With server.oauth.enabled and the legacy API both on, GET /login adds m.login.sso with
oauth_aware_preferred: true (and m.login.token when get_token did not), and both SSO
redirects start the /authorize sign-in or registration pages through a new
login_token_hand_off kind of pending authorisation. redirectUrl must be https, loopback
http or a private-use scheme, and match the allowlist when one is set; a refused one is a
400 page with no redirect. After the password a confirmation page names the account and
the destination; continue mints a 30-second single-use token into LoginTokenStore and
answers 303 with every older loginToken removed; cancel redirects nowhere.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…NKNOWN (ADR-0803)

handle_client_server_request caught only std::overflow_error; any other exception left the
dispatcher and the transport closed the connection with no answer. A catch-all after the
overflow catch now answers 500 M_UNKNOWN with a fixed text and the CORS headers, and logs one
error line (request.exception) with the method, the normalised route and the exception's type,
never its message, which can quote request data. The lock is released by the unwinding and
taken afresh only to build the answer.

current_exception_type_name moves to core (CurrentException.hpp) from its two copies in
ThreadPool.cpp and HttpServer.cpp. HomeserverRuntime::test_client_request_hook lets a test make
one request throw.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With server.oauth.device_grant_enabled, POST /_merovingian/oauth2/device
(the device authorization endpoint) issues a device code and an eight-letter
user code; the link page takes the code, signs the user in with the existing
login pages, and a consent page that warns first records the answer for the
device to collect at the token endpoint with the device_code grant
(RFC 8628). Authorisations live in a capped in-memory store; wrong user codes
are throttled per address and the throttle fails closed at its cap. A device
sign-in creates no account and runs in one browser at a time under a
two-minute lease.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A sign-in past the password step now records the user's credential stamp,
a hash of the stored password hash. It travels with the authorisation code
and the device approval, and approve, the code grant and the device-code
grant compare it in constant time after account_sign_in_gate. A password
change, reset or deactivation since makes it differ, and the sign-in is
refused and spent instead of granted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…DR-0808)

Every path that revokes all of a device's or a user's tokens (a password
change with logout_devices, a reset, an account-page change, deactivation,
logout/all, device deletion and refresh-token reuse) now deletes the
matching oauth_sessions rows in the same transaction, and memory follows
only the commit. The retention sweep deletes the row of a device that holds
no live access or refresh token, judging it again in the hold that deletes
it, before it judges the clients, so a client whose sessions all ended can
be evicted or aged out. Amends ADR-0776, ADR-0777 and ADR-0780.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…DR-0809)

The m.oauth challenge URL now carries the requesting device's device_id,
which the spec lets a Matrix-specific account management action take. When
it names one of the signed-in user's own OAuth devices, the reset page
names the device and its client, and the approval it gives is bound: only
that device's upload takes it, and a restored approval stays bound. Any
other device_id is ignored and never shown, and the approval is unbound as
before. A posted device that is no longer one of the user's OAuth devices
is refused with nothing approved. Amends ADR-0797 and ADR-0799.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mit, keep the display name on refresh

A refused token or device authorization request now logs client_id only
after find_registered_oauth_client found it; before then it is text the
caller chose. The code grant records the session a replayed code would end
at the redemption's instant, before the grant commits, so nothing that can
fail follows the commit (the old call ran after it, on a fresh clock, and
could find the code expired). The refresh grant lists a device the runtime
lost with the display name stored on its row, not its device ID. The token
flow test now includes <tuple> for the std::ignore of the previous commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ror page (ADR-0810)

The dispatch boundary's final catch now asks request_serves_page whether the
request was routed to the authorisation, device link or account page, or to
an SSO redirect that hands off to them, judged on the same path, method and
configuration the routes match on. Such a request gets a fixed 500 HTML
error page under the pages' own headers and no CORS header; every other
request keeps the 500 M_UNKNOWN JSON answer. Amends ADR-0803.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The URI reader takes an IPv6 host only in the RFC 3986 IPv6address
  grammar, and csp_source() gives a bracketed IPv6 host its scheme alone,
  since the CSP host-source grammar cannot name one (ADR-0811, amending
  ADR-0772).
- The hand-off accepts a private-use scheme only with no authority.
- A client URI host whose last label ends in a number by the WHATWG rule is
  refused.
- client_name refuses the soft hyphen, the Mongolian vowel separator, the
  zero-width characters, the word joiner and invisible operators, the BOM,
  the interlinear annotation characters and the tag characters.
- The hand-off confirmation page shows the destination's port.
- The redirect URI fuzz target aborts when csp_source() holds a space,
  ';', ',' or a quote, when a match differs from the request, or when a
  validated URI does not match itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FormFields::parse_query reads the query strings of /authorize, /link,
/account and the legacy SSO redirect's hand-off as parse reads a body,
except that a bare name with no '=' and an empty field count as not sent,
as RFC 6749 section 3.1 asks. A bare name is still decoded and checked, so
a malformed escape, NUL or invalid UTF-8 in it refuses the query; 'name='
keeps its empty value. Form bodies are still read with parse.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
store_device, store_access_token, store_refresh_token and
rotate_device_credentials now build their rows through
insert_device_statement, insert_access_token_statement and
insert_refresh_token_statement, which the grant writer already used. The
SQL text, parameters and behaviour are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
James-Chapman and others added 9 commits November 16, 2026 12:23
The early-phase Features bullets no longer say that nothing is served yet.
ADR-0794 records that ADR-0797 amends it, and ADR-0033 notes that
server.sso.authorization_url cannot be combined with server.oauth.enabled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
POST /refresh re-added a device the runtime's device list had lost (after a
restart) with its device ID as the display name. It now reads the device
row's stored name through stored_device_display_name, moved out of the OAuth
token endpoint into StoredDeviceDisplayName.{hpp,cpp} so both refresh paths
share it, and adds the device through remember_signed_in_device.

New integration scenario [legacy-refresh-device-name] in
test_oauth_token_flow.cpp.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The threat model gains a section on the OAuth 2.0 surface: the server's own
pages, cross-site form posts, open redirect and code theft, client
impersonation, the device grant as a phishing tool, the legacy SSO hand-off,
resource exhaustion, the credential and session lifecycle, logging and the
exception backstop, each with its mitigation and the risk its ADR accepts,
and an open item: nothing has been tried in a real browser or client yet.
The security review checklist gains the checks for a new page, form action,
endpoint, store, session path and password path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The plan names the commits of phases 1 to 10 and of the review fixes, and
lists what is still open: Milestone A with every browser-only check, the
PostgreSQL scenarios and the 1.0.x upgrade fixture (the build VM has no
PostgreSQL server binaries), QR-code login (MSC4108 is not in 1.1.0), the
strict documentation build and Element X's response_mode. The upgrade
fixture README and the root AGENTS.md say the fixture is not generated yet
and why. The capability-gaps rows no longer call auth_metadata OIDC
discovery and note QR-code login; the SSO milestone row notes the hand-off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FreeBSD's cxxabi.h declares std::type_info without defining it, so
current_exception_type_name (ADR-0803) did not compile there: the first
FreeBSD VM build of this branch stopped on it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every core::SecretBuffer locks a page, and FreeBSD's default RLIMIT_MEMLOCK
of 64 KiB allows 16. cached_token_hmac_keys also derived and held the OAuth
2.0 client ID key for the life of the process, OAuth on or off. In the
three-appservice delivery scenario that page was the one over the limit:
the registration token file could no longer be read into locked memory, and
POST /register answered "registration token rejected" with no log line.

TokenHmacKeys holds the two access-token keys again, as on main.
crypto::derive_oauth_client_id_key_from_file derives the client ID key from
one open of the master key file for each registration and drops it on
return; a failure logs oauth.client.id_key_unavailable and keeps the 500.
load_hashed_registration_token now logs registration.token_file_unusable,
once per outage, when a configured token file yields no hash. ADR-0779
records the amendment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every secret the server holds sits in a locked page, and a secret file is
not read without one. FreeBSD's default login class allows 64 KiB of
locked memory, which is 16 secrets. rc.subr starts a service in the
daemon class (128 MiB), so the packaged service was not at that limit,
but only because of login.conf. The script now defaults
merovingian_limits to "-l 128m" itself, after load_rc_config so rc.conf
can override it.

docs/hardening.md says what a server started outside rc.d needs.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The branch was cut from 1.0.2 and numbered its decisions from 0760. The
1.0.3 release has since taken 0760 and 0761 on main, and
feature/sync-state-after-1-1, which goes into the same 1.1.0 release,
uses 0762 to 0765. A number is never reused (ADR-0543), so the six move
above the branch's highest number; 0766 to 0811 stay where they are.

Files, index lines, links and every citation in code, tests and docs
are renamed together. No decision's text changes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The conflicts were the version strings only: this branch stays 1.1.0.
The package changelogs keep both entries, 1.1.0 above 1.0.3, and main's
ADR-0760 and ADR-0761 sit in number order in the ADR index.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Too many files!

This PR contains 417 files, which is 317 over the limit of 100.

To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch.

Upgrade to a paid plan to raise the limit.

Usage-priced reviews support at most 300 files.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9385db39-ea8f-47ad-a3b6-f96b014b2499
Commits

Reviewing files that changed from the base of the PR and between 5f458d5 and 89f7cd9.

Files selected for processing: 417

  • .agent/skills/merovingian-review/references/module-invariants.md
  • AGENTS.md
  • CHANGELOG.md
  • config/merovingian.conf.bsd.example
  • config/merovingian.conf.example
  • docs/adr/0033-leave-sso-protocol-integration-to-an-operator-gateway.md
  • docs/adr/0766-a-malformed-or-repeated-cookie-makes-only-its-own-name-unusable.md
  • docs/adr/0767-a-response-head-the-formatter-cannot-write-safely-is-refused-with-a-500.md
  • docs/adr/0768-the-oauth-module-is-pure-and-carries-the-wire-error-beside-core-error.md
  • docs/adr/0769-an-oauth-scope-needs-the-api-token-and-exactly-one-device-token-of-ten-or-more-unreserved-characters.md
  • docs/adr/0770-oauth-addresses-are-read-by-a-strict-reader-of-our-own-and-matched-byte-for-byte.md
  • docs/adr/0771-oauth-client-metadata-rules-and-its-canonical-form.md
  • docs/adr/0772-page-text-is-escaped-by-type-and-the-page-policy-names-only-a-validated-redirect-origin.md
  • docs/adr/0773-the-oauth-issuer-is-public-baseurl-and-the-routes-live-under-merovingian.md
  • docs/adr/0774-a-hand-off-allowlist-entry-is-an-https-origin-or-a-bare-private-use-scheme-never-a-prefix.md
  • docs/adr/0775-auth-metadata-stays-in-the-generic-rate-limit-tier.md
  • docs/adr/0776-an-oauth-session-is-a-row-keyed-by-user-and-device-and-the-token-tables-do-not-change.md
  • docs/adr/0777-an-oauth-client-s-last-use-is-written-at-most-once-a-day.md
  • docs/adr/0778-the-schema-is-built-from-per-version-tables-and-each-migration-step-from-what-its-version-adds.md
  • docs/adr/0779-an-oauth-client-id-is-a-keyed-hash-of-the-accepted-metadata.md
  • docs/adr/0780-oauth-registrations-are-capped-and-idle-clients-are-evicted-least-recently-used-first.md
  • docs/adr/0781-oauth-endpoints-answer-oauth-errors-with-no-store-from-one-helper.md
  • docs/adr/0782-pending-authorisations-and-authorization-codes-are-in-memory-hashed-bounded-and-never-evicted.md
  • docs/adr/0783-login-verification-and-account-creation-are-one-function-each-shared-by-the-matrix-routes-and-the-oauth-pages.md
  • docs/adr/0784-oauth-pages-use-a-same-origin-referrer-policy-and-a-form-post-must-name-this-server-s-origin.md
  • docs/adr/0785-an-oauth-page-response-is-marked-in-its-type-and-gets-no-cors-headers.md
  • docs/adr/0786-the-query-of-an-oauth-request-is-never-logged.md
  • docs/adr/0787-every-oauth-authorisation-asks-for-the-password-and-no-browser-session-is-kept.md
  • docs/adr/0788-the-oauth-browser-binding-is-one-host-cookie-and-the-pending-identifier-is-the-form-token.md
  • docs/adr/0789-response-mode-query-is-accepted-for-an-https-redirect-uri.md
  • docs/adr/0790-an-oauth-approval-is-judged-again-and-audited-and-its-redirect-sends-no-referrer.md
  • docs/adr/0791-the-oauth-token-endpoint-reuses-the-login-tokens-and-an-oauth-access-token-always-expires.md
  • docs/adr/0792-an-oauth-grant-is-one-transaction-and-a-replayed-code-ends-only-the-session-it-produced.md
  • docs/adr/0793-oauth-and-legacy-sessions-do-not-mix-at-the-refresh-endpoints.md
  • docs/adr/0794-a-uia-endpoint-refuses-an-oauth-session-and-cross-signing-upload-follows-the-spec-exemptions.md
  • docs/adr/0795-oauth-revocation-ends-the-session-as-logout-does-whoever-asks.md
  • docs/adr/0796-the-account-pages-keep-a-fixed-15-minute-session-in-memory-bound-to-a-strict-cookie-and-a-form-token.md
  • docs/adr/0797-an-oauth-session-replaces-its-cross-signing-keys-through-the-m-oauth-stage-and-a-one-use-approval.md
  • docs/adr/0798-account-page-actions-share-the-client-api-cores-and-every-password-change-ends-account-page-access.md
  • docs/adr/0799-the-m-oauth-stage-accepts-a-polling-retry-without-a-session-and-reuses-the-user-s-live-session.md
  • docs/adr/0800-no-default-member-initialiser-holds-oauth-page-text-because-clang-18-runs-it-at-run-time.md
  • docs/adr/0801-one-function-decides-the-legacy-api-switch-and-each-refused-use-answers-as-the-spec-says.md
  • docs/adr/0802-the-legacy-sso-redirect-hands-off-to-the-built-in-pages-confirms-and-mints-a-30-second-login-token.md
  • docs/adr/0803-the-client-server-dispatch-boundary-answers-an-escaped-exception-with-a-500-and-logs-only-its-type.md
  • docs/adr/0804-the-device-authorization-grant-answers-rfc-8628-and-a-redeemed-device-code-is-expired.md
  • docs/adr/0805-device-authorisations-and-user-codes-are-held-in-memory-capped-and-guessing-is-throttled-per-address.md
  • docs/adr/0806-a-device-sign-in-warns-first-creates-no-account-and-runs-in-one-browser-at-a-time.md
  • docs/adr/0807-an-oauth-sign-in-carries-the-credential-stamp-of-its-password-check-and-ends-when-it-changes.md
  • docs/adr/0808-an-oauth-session-row-ends-with-the-last-credential-of-its-device.md
  • docs/adr/0809-a-cross-signing-reset-approval-is-bound-to-the-oauth-device-that-asked-for-it.md
  • docs/adr/0810-an-exception-escaping-one-of-the-server-s-own-pages-is-answered-with-a-fixed-error-page.md
  • docs/adr/0811-a-bracketed-ipv6-redirect-target-adds-only-its-scheme-to-form-action.md
  • docs/adr/0812-the-oauth-2-0-api-is-built-into-the-homeserver.md
  • docs/adr/0813-the-legacy-authentication-api-stays-on-by-default-and-a-config-key-turns-it-off.md
  • docs/adr/0814-the-registration-page-applies-the-legacy-registration-settings.md
  • docs/adr/0815-the-authentication-pages-are-built-into-the-binary-without-javascript.md
  • docs/adr/0816-server-oauth-replaces-server-oidc-and-the-old-keys-are-refused.md
  • docs/adr/0817-a-form-body-is-read-strictly-and-refused-whole.md
  • docs/adr/index.md
  • docs/architecture.md
  • docs/auth-identity.md
  • docs/coding-rules.md
  • docs/crypto-boundary.md
  • docs/database-persistence.md
  • docs/debug-logging.md
  • docs/hardening.md
  • docs/http-transport.md
  • docs/log-filtering.md
  • docs/matrix-v1.19-client-server-api.md
  • docs/observability-audit.md
  • docs/platform-support.md
  • docs/release-process.md
  • docs/security-coding-rules.md
  • docs/security-review-checklist.md
  • docs/threat-model.md
  • docs/todos/capability-gaps.md
  • docs/todos/oauth-2-0-api.md
  • docs/todos/production-milestone.md
  • docs/user-manual.md
  • include/merovingian/auth/AuthMetadata.hpp
  • include/merovingian/auth/OidcDiscovery.hpp
  • include/merovingian/canonicaljson/Parser.hpp
  • include/merovingian/config/Config.hpp
  • include/merovingian/config/OAuthConfig.hpp
  • include/merovingian/config/OidcConfig.hpp
  • include/merovingian/config/PushConfig.hpp
  • include/merovingian/config/ServerConfig.hpp
  • include/merovingian/config/SsoConfig.hpp
  • include/merovingian/core/CookieOctets.hpp
  • include/merovingian/core/CookieSameSite.hpp
  • include/merovingian/core/CurrentException.hpp
  • include/merovingian/core/FormFields.hpp
  • include/merovingian/core/HostCookie.hpp
  • include/merovingian/core/HttpToken.hpp
  • include/merovingian/core/RequestCookies.hpp
  • include/merovingian/core/Utf8.hpp
  • include/merovingian/crypto/OAuthClientId.hpp
  • include/merovingian/crypto/Sha256.hpp
  • include/merovingian/crypto/TokenKey.hpp
  • include/merovingian/database/CredentialTable.hpp
  • include/merovingian/database/Migration.hpp
  • include/merovingian/database/OAuthClientStoreResult.hpp
  • include/merovingian/database/OAuthStore.hpp
  • include/merovingian/database/OAuthTables.hpp
  • include/merovingian/database/PersistentOAuthClient.hpp
  • include/merovingian/database/PersistentOAuthSession.hpp
  • include/merovingian/database/PersistentStore.hpp
  • include/merovingian/database/Schema.hpp
  • include/merovingian/homeserver/AccountCreationRequest.hpp
  • include/merovingian/homeserver/AccountPage.hpp
  • include/merovingian/homeserver/AccountSession.hpp
  • include/merovingian/homeserver/AccountSessionStore.hpp
  • include/merovingian/homeserver/AuthService.hpp
  • include/merovingian/homeserver/AuthorizationCodeRedemption.hpp
  • include/merovingian/homeserver/AuthorizationCodeStore.hpp
  • include/merovingian/homeserver/AuthorizationGrant.hpp
  • include/merovingian/homeserver/ClientApiLimits.hpp
  • include/merovingian/homeserver/ClientDeviceSessions.hpp
  • include/merovingian/homeserver/ClientServerRuntime.hpp
  • include/merovingian/homeserver/CrossSigningResetApprovals.hpp
  • include/merovingian/homeserver/DeviceAuthorisation.hpp
  • include/merovingian/homeserver/DeviceAuthorisationState.hpp
  • include/merovingian/homeserver/DeviceAuthorisationStore.hpp
  • include/merovingian/homeserver/HashedSecretTable.hpp
  • include/merovingian/homeserver/HomeserverRuntime.hpp
  • include/merovingian/homeserver/LegacyAuthPolicy.hpp
  • include/merovingian/homeserver/LegacyAuthRefusal.hpp
  • include/merovingian/homeserver/LegacyAuthUse.hpp
  • include/merovingian/homeserver/LocalHttpResponse.hpp
  • include/merovingian/homeserver/LoginTokenStore.hpp
  • include/merovingian/homeserver/OAuthAuthorization.hpp
  • include/merovingian/homeserver/OAuthClientCredentials.hpp
  • include/merovingian/homeserver/OAuthClientRegistration.hpp
  • include/merovingian/homeserver/OAuthClock.hpp
  • include/merovingian/homeserver/OAuthDeviceAuthorization.hpp
  • include/merovingian/homeserver/OAuthGrantRequest.hpp
  • include/merovingian/homeserver/OAuthJsonResponse.hpp
  • include/merovingian/homeserver/OAuthPageResponse.hpp
  • include/merovingian/homeserver/OAuthRevocation.hpp
  • include/merovingian/homeserver/OAuthSecret.hpp
  • include/merovingian/homeserver/OAuthTokenEndpoint.hpp
  • include/merovingian/homeserver/PasswordLoginRequest.hpp
  • include/merovingian/homeserver/PasswordLoginVerification.hpp
  • include/merovingian/homeserver/PendingAuthorisation.hpp
  • include/merovingian/homeserver/PendingAuthorisationKind.hpp
  • include/merovingian/homeserver/PendingAuthorisationStore.hpp
  • include/merovingian/homeserver/RequestHeaders.hpp
  • include/merovingian/homeserver/RetentionSweep.hpp
  • include/merovingian/homeserver/SignedInDevice.hpp
  • include/merovingian/homeserver/StoredDeviceDisplayName.hpp
  • include/merovingian/homeserver/UserCodeAttemptThrottle.hpp
  • include/merovingian/http/Request.hpp
  • include/merovingian/http/ResponseHead.hpp
  • include/merovingian/oauth/AccessTokenLifetime.hpp
  • include/merovingian/oauth/AccountDeviceRow.hpp
  • include/merovingian/oauth/AccountFormInput.hpp
  • include/merovingian/oauth/AccountPageFrame.hpp
  • include/merovingian/oauth/AccountPages.hpp
  • include/merovingian/oauth/AccountSignInInput.hpp
  • include/merovingian/oauth/ApplicationType.hpp
  • include/merovingian/oauth/AsciiCase.hpp
  • include/merovingian/oauth/AuthorizationPages.hpp
  • include/merovingian/oauth/AuthorizationRedirect.hpp
  • include/merovingian/oauth/ClientMetadata.hpp
  • include/merovingian/oauth/ClientUri.hpp
  • include/merovingian/oauth/ConsentPageInput.hpp
  • include/merovingian/oauth/DeviceConsentPageInput.hpp
  • include/merovingian/oauth/DisplayText.hpp
  • include/merovingian/oauth/FormContentType.hpp
  • include/merovingian/oauth/FormPostOrigin.hpp
  • include/merovingian/oauth/GrantedScope.hpp
  • include/merovingian/oauth/HandOffAllowlist.hpp
  • include/merovingian/oauth/HandOffRedirect.hpp
  • include/merovingian/oauth/HtmlLiteral.hpp
  • include/merovingian/oauth/HtmlName.hpp
  • include/merovingian/oauth/HtmlText.hpp
  • include/merovingian/oauth/OAuthBaseUrl.hpp
  • include/merovingian/oauth/OAuthErrorCodes.hpp
  • include/merovingian/oauth/OAuthPaths.hpp
  • include/merovingian/oauth/OAuthRefusal.hpp
  • include/merovingian/oauth/Page.hpp
  • include/merovingian/oauth/PageDetail.hpp
  • include/merovingian/oauth/PageForm.hpp
  • include/merovingian/oauth/PageHeaders.hpp
  • include/merovingian/oauth/PagePath.hpp
  • include/merovingian/oauth/ParsedUri.hpp
  • include/merovingian/oauth/Pkce.hpp
  • include/merovingian/oauth/RedirectUriRules.hpp
  • include/merovingian/oauth/ResponseMode.hpp
  • include/merovingian/oauth/ScopeParser.hpp
  • include/merovingian/oauth/ServerMetadata.hpp
  • include/merovingian/oauth/ServerMetadataOptions.hpp
  • include/merovingian/oauth/SubmitButton.hpp
  • include/merovingian/oauth/TextInput.hpp
  • include/merovingian/oauth/UserCode.hpp
  • meson.build
  • migrations/002_oauth_tables.sql
  • migrations/AGENTS.md
  • mkdocs.yml
  • packaging/AGENTS.md
  • packaging/freebsd/+MANIFEST
  • packaging/netbsd/Makefile
  • packaging/opensuse/merovingian.spec
  • packaging/rc.d/merovingian
  • packaging/rhel/merovingian.spec
  • packaging/rpm/merovingian.spec
  • scripts/build-deb.sh
  • scripts/build-freebsd-pkg.sh
  • scripts/build-netbsd-pkg.sh
  • scripts/build-openbsd-pkg.sh
  • scripts/build-opensuse-rpm.sh
  • scripts/build-rhel-rpm.sh
  • scripts/build-rpm.sh
  • scripts/build-static-linux.sh
  • scripts/run-fuzz-targets.sh
  • src/auth/AGENTS.md
  • src/auth/OidcDiscovery.cpp
  • src/auth/meson.build
  • src/canonicaljson/Parser.cpp
  • src/canonicaljson/meson.build
  • src/config/AGENTS.md
  • src/config/Config.cpp
  • src/config/ConfigParser.cpp
  • src/config/ReloadPlan.cpp
  • src/config/ReloadPolicy.cpp
  • src/config/meson.build
  • src/core/AGENTS.md
  • src/core/CookieOctets.cpp
  • src/core/CurrentException.cpp
  • src/core/FormFields.cpp
  • src/core/HostCookie.cpp
  • src/core/HttpToken.cpp
  • src/core/RequestCookies.cpp
  • src/core/Utf8.cpp
  • src/core/meson.build
  • src/crypto/AGENTS.md
  • src/crypto/OAuthClientId.cpp
  • src/crypto/Sha256.cpp
  • src/crypto/TokenKey.cpp
  • src/crypto/meson.build
  • src/database/AGENTS.md
  • src/database/Migration.cpp
  • src/database/MigrationFiles.cpp
  • src/database/OAuthStore.cpp
  • src/database/OAuthTables.cpp
  • src/database/PersistentStore.cpp
  • src/database/PostgresqlStore.cpp
  • src/database/Schema.cpp
  • src/database/SqliteStore.cpp
  • src/database/meson.build
  • src/db_migrate.cpp
  • src/federation_worker/meson.build
  • src/homeserver/AGENTS.md
  • src/homeserver/AccountPage.cpp
  • src/homeserver/AccountSessionStore.cpp
  • src/homeserver/AuthService.cpp
  • src/homeserver/AuthorizationCodeStore.cpp
  • src/homeserver/ClientServerRuntime.cpp
  • src/homeserver/CrossSigningResetApprovals.cpp
  • src/homeserver/DeviceAuthorisationStore.cpp
  • src/homeserver/HttpServer.cpp
  • src/homeserver/LegacyAuthPolicy.cpp
  • src/homeserver/LoginTokenStore.cpp
  • src/homeserver/OAuthAuthorization.cpp
  • src/homeserver/OAuthClientCredentials.cpp
  • src/homeserver/OAuthClientRegistration.cpp
  • src/homeserver/OAuthClock.cpp
  • src/homeserver/OAuthDeviceAuthorization.cpp
  • src/homeserver/OAuthJsonResponse.cpp
  • src/homeserver/OAuthPageResponse.cpp
  • src/homeserver/OAuthRevocation.cpp
  • src/homeserver/OAuthSecret.cpp
  • src/homeserver/OAuthTokenEndpoint.cpp
  • src/homeserver/PendingAuthorisationStore.cpp
  • src/homeserver/RequestHeaders.cpp
  • src/homeserver/RetentionSweep.cpp
  • src/homeserver/StoredDeviceDisplayName.cpp
  • src/homeserver/UserCodeAttemptThrottle.cpp
  • src/homeserver/meson.build
  • src/http/AGENTS.md
  • src/http/RateLimit.cpp
  • src/http/Request.cpp
  • src/http/ResponseHead.cpp
  • src/http/meson.build
  • src/main.cpp
  • src/meson.build
  • src/net/ThreadPool.cpp
  • src/net/meson.build
  • src/oauth/AGENTS.md
  • src/oauth/AccountPages.cpp
  • src/oauth/AsciiCase.cpp
  • src/oauth/AuthorizationPages.cpp
  • src/oauth/AuthorizationRedirect.cpp
  • src/oauth/CLAUDE.md
  • src/oauth/ClientMetadata.cpp
  • src/oauth/ClientUri.cpp
  • src/oauth/DisplayText.cpp
  • src/oauth/FormContentType.cpp
  • src/oauth/FormPostOrigin.cpp
  • src/oauth/HandOffAllowlist.cpp
  • src/oauth/HandOffRedirect.cpp
  • src/oauth/HtmlText.cpp
  • src/oauth/OAuthBaseUrl.cpp
  • src/oauth/Page.cpp
  • src/oauth/PageForm.cpp
  • src/oauth/PageHeaders.cpp
  • src/oauth/ParsedUri.cpp
  • src/oauth/Pkce.cpp
  • src/oauth/RedirectUriRules.cpp
  • src/oauth/ScopeParser.cpp
  • src/oauth/ServerMetadata.cpp
  • src/oauth/UserCode.cpp
  • src/oauth/meson.build
  • src/observability/Observability.cpp
  • tests/conformance/AGENTS.md
  • tests/conformance/test_account_lifecycle_conformance.cpp
  • tests/conformance/test_client_server_conformance.cpp
  • tests/conformance/test_oauth_account_management_conformance.cpp
  • tests/conformance/test_oauth_authorization_conformance.cpp
  • tests/conformance/test_oauth_aware_clients_conformance.cpp
  • tests/conformance/test_oauth_client_registration_conformance.cpp
  • tests/conformance/test_oauth_device_grant_conformance.cpp
  • tests/conformance/test_oauth_legacy_api_conformance.cpp
  • tests/conformance/test_oauth_metadata_conformance.cpp
  • tests/conformance/test_oauth_token_conformance.cpp
  • tests/conformance/test_route_query_conformance.cpp
  • tests/fixtures/upgrade/README.md
  • tests/fuzz/AGENTS.md
  • tests/fuzz/corpus/fuzz-form-fields/bad-escape.txt
  • tests/fuzz/corpus/fuzz-form-fields/plus-and-empty.txt
  • tests/fuzz/corpus/fuzz-form-fields/repeated-name.txt
  • tests/fuzz/corpus/fuzz-form-fields/token-request.txt
  • tests/fuzz/corpus/fuzz-oauth-client-metadata/device-rlo.json
  • tests/fuzz/corpus/fuzz-oauth-client-metadata/minimal.json
  • tests/fuzz/corpus/fuzz-oauth-client-metadata/native.json
  • tests/fuzz/corpus/fuzz-oauth-redirect-uri/hostile.txt
  • tests/fuzz/corpus/fuzz-oauth-redirect-uri/loopback-port.txt
  • tests/fuzz/corpus/fuzz-oauth-redirect-uri/private-use.txt
  • tests/fuzz/corpus/fuzz-oauth-redirect-uri/web.txt
  • tests/fuzz/corpus/fuzz-oauth-scope/bad-spacing.txt
  • tests/fuzz/corpus/fuzz-oauth-scope/two-devices.txt
  • tests/fuzz/corpus/fuzz-oauth-scope/valid.txt
  • tests/fuzz/corpus/fuzz-request-cookies/malformed-pairs.txt
  • tests/fuzz/corpus/fuzz-request-cookies/repeated-name.txt
  • tests/fuzz/corpus/fuzz-request-cookies/two-cookies.txt
  • tests/fuzz/fuzz_form_fields.cpp
  • tests/fuzz/fuzz_oauth_client_metadata.cpp
  • tests/fuzz/fuzz_oauth_redirect_uri.cpp
  • tests/fuzz/fuzz_oauth_scope.cpp
  • tests/fuzz/fuzz_request_cookies.cpp
  • tests/fuzz/meson.build
  • tests/integration/test_client_server_endpoints_flow.cpp
  • tests/integration/test_database_upgrade_flow.cpp
  • tests/integration/test_http_server_listener_flow.cpp
  • tests/integration/test_oauth_account_creation_flow.cpp
  • tests/integration/test_oauth_account_pages_flow.cpp
  • tests/integration/test_oauth_authorization_flow.cpp
  • tests/integration/test_oauth_client_registration_flow.cpp
  • tests/integration/test_oauth_device_grant_flow.cpp
  • tests/integration/test_oauth_legacy_api_flow.cpp
  • tests/integration/test_oauth_log_query_flow.cpp
  • tests/integration/test_oauth_login_hand_off_flow.cpp
  • tests/integration/test_oauth_metadata_flow.cpp
  • tests/integration/test_oauth_password_login_flow.cpp
  • tests/integration/test_oauth_token_flow.cpp
  • tests/integration/test_persistent_homeserver_flow.cpp
  • tests/integration/test_postgresql_persistence_flow.cpp
  • tests/integration/test_postgresql_store_behaviour_flow.cpp
  • tests/integration/test_request_exception_flow.cpp
  • tests/integration/test_retention_sweep_flow.cpp
  • tests/meson.build
  • tests/smoke/meson.build
  • tests/support/AGENTS.md
  • tests/support/ConsoleLogCapture.hpp
  • tests/support/OAuthAccountPageSupport.hpp
  • tests/support/OAuthAuthorizationSupport.hpp
  • tests/support/OAuthRegistrationSupport.hpp
  • tests/support/OAuthTokenSupport.hpp
  • tests/tooling/test_example_config.py
  • tests/tooling/test_page_text_member_initialisers.py
  • tests/tooling/test_rcd_locked_memory.py
  • tests/unit/test_auth_oidc_discovery.cpp
  • tests/unit/test_config_oauth.cpp
  • tests/unit/test_config_oidc_validation.cpp
  • tests/unit/test_config_sso.cpp
  • tests/unit/test_core_form_fields.cpp
  • tests/unit/test_core_host_cookie.cpp
  • tests/unit/test_core_request_cookies.cpp
  • tests/unit/test_crypto_oauth_client_id.cpp
  • tests/unit/test_crypto_token_key_cache.cpp
  • tests/unit/test_database_oauth_store.cpp
  • tests/unit/test_database_persistence.cpp
  • tests/unit/test_http_rate_limit_tiers.cpp
  • tests/unit/test_http_response_head.cpp
  • tests/unit/test_legacy_auth_policy.cpp
  • tests/unit/test_oauth_account_pages.cpp
  • tests/unit/test_oauth_account_session_store.cpp
  • tests/unit/test_oauth_authorization_code_store.cpp
  • tests/unit/test_oauth_authorization_pages.cpp
  • tests/unit/test_oauth_authorization_redirect.cpp
  • tests/unit/test_oauth_client_metadata.cpp
  • tests/unit/test_oauth_cross_signing_reset_approvals.cpp
  • tests/unit/test_oauth_device_authorisation_store.cpp
  • tests/unit/test_oauth_form_post_origin.cpp
  • tests/unit/test_oauth_hand_off_allowlist.cpp
  • tests/unit/test_oauth_hand_off_redirect.cpp
  • tests/unit/test_oauth_page.cpp
  • tests/unit/test_oauth_page_response.cpp
  • tests/unit/test_oauth_pending_authorisation_store.cpp
  • tests/unit/test_oauth_pkce.cpp
  • tests/unit/test_oauth_redirect_uri.cpp
  • tests/unit/test_oauth_scope.cpp
  • tests/unit/test_oauth_server_metadata.cpp
  • tests/unit/test_oauth_token_rules.cpp
  • tests/unit/test_oauth_user_code.cpp
  • tests/unit/test_observability.cpp
  • tests/unit/test_worker_table_load_profile.cpp

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

…absent

make_schema_absent dropped only what migration 001 created. Since
migration 002 the OAuth tables stayed behind, so the next open rebuilt
v1 and failed with: relation "oauth_clients" already exists. That
failed the postgres-integration, coverage and sonarcloud checks, the
only places the PostgreSQL scenarios run.

The helper now reads the newest version from the ledger and runs the
downgrade plan from it to nothing.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@James-Chapman

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T20:30:28.688404Z 592fe56 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

An unknown error occurred
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/oauth/RedirectUriRules.cpp Fixed
…ttp prefix

SonarCloud's quality gate failed on seven findings in the new code.

Six were cpp:S1035 in HtmlLiteral, HtmlName and PagePath: their consteval
checks threw a string literal. A check that clang 18 runs at run time
(ADR-0800) then threw a pointer no std::exception handler catches. They
throw std::logic_error by value now.

The seventh, cpp:S5332 in RedirectUriRules.cpp, is a false positive: the
line builds the http prefix of a native client's loopback redirect URI,
which the spec and RFC 8252 section 7.3 require, for a host already
checked to be a loopback literal. It carries NOSONAR with that reason.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@James-Chapman

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 592fe56f98

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@James-Chapman

Copy link
Copy Markdown
Collaborator Author

@codex security review

@github-advanced-security github-advanced-security AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

Product code:
- FormFields::decode_component and ParsedUri's component check are while
  loops in which each branch advances by the bytes it read, instead of a
  for loop whose body also moved the counter.
- ClientMetadata::validate and ParsedUri::read carry comments that say
  why each step is there.
- PendingAuthorisationStore::find and record_user take only the entry
  from bound_entry; they never used the hash.

Test code:
- Twelve long scenarios gain comments on what their GIVEN/WHEN/THEN text
  does not say.
- The support percent decoder follows the product decoders' loop form,
  the hand-off test's start() takes the Config by reference, and unused
  page values and an alias CodeQL could not see used are gone.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each rule in the comment above ClientMetadata::validate ended in a
semicolon, which CodeQL read as commented-out code. The rules end in
full stops now; no rule's wording changes. Comment only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@James-Chapman
James-Chapman added this pull request to stack #596 November 17, 2026 01:03
@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
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.

2 participants