Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

docs: refresh the v1 API audit against HEAD, retire T10 (#21261)

Danny Xubd4570e7e140
diff --git a/docs/design/reauthenticate-credential-changes.md b/docs/design/reauthenticate-credential-changes.md
index b2ee98d2d5..03602f3126 100644
--- a/docs/design/reauthenticate-credential-changes.md
+++ b/docs/design/reauthenticate-credential-changes.md
@@ -1,6 +1,6 @@
# Require re-authentication to change your own credentials
-Status: proposal · 2026-08-24
+Status: implemented with deltas · proposed 2026-08-24, shipped 2026-08-27
`UpdateUser` lets an authenticated caller rewrite their own password, TOTP secret, and recovery
codes without proving they still control the credential being replaced. Closes T10 in
diff --git a/docs/design/v1-api-audit-2026-08.md b/docs/design/v1-api-audit-2026-08.md
index 7085e43563..a9d858d7c2 100644
--- a/docs/design/v1-api-audit-2026-08.md
+++ b/docs/design/v1-api-audit-2026-08.md
@@ -2,15 +2,14 @@
What's wrong with the v1 API, in plain terms.
-Audited against `93671b00b0` (2026-08-04); every finding below re-verified against `fd4ef828e6`
-(2026-08-18), with HEAD line numbers. Findings are code-traced, not runtime-proven, except where
-noted. Nothing here is patched yet. Fixed findings are removed and listed at the end.
+Audited against `93671b00b0` (2026-08-04); every finding below re-verified against `9e117d42e2`
+(2026-08-27), with HEAD line numbers. Findings are code-traced, not runtime-proven, except where
+noted. Fixed findings are removed and listed at the end.
## The short version
| | Problem | Severity |
|---|---|---|
-| T10 | A stolen session can change your password and switch off your 2FA | HIGH |
| T2 | Schema diff reads a second database without checking permission on it | HIGH |
| T15 | Rotating a leaked cloud credential can silently do nothing | HIGH |
| T13 | "Waiting for my approval" can show an empty page with a live Load More | HIGH |
@@ -25,22 +24,6 @@ noted. Nothing here is patched yet. Fixed findings are removed and listed at the
---
-## Getting in, and staying in
-
-### T10 · A borrowed session becomes permanent account takeover — HIGH
-
-Changing your own password doesn't require the current password, and switching off your own 2FA
-doesn't require a code. So anyone who gets a session — stolen laptop, shared browser, leaked token —
-converts that temporary access into permanent ownership of the account. Refresh tokens are revoked
-on password change, but the attacker's own access token keeps working.
-
-The frontend work in [#21193](https://github.com/bytebase/bytebase/pull/21193) split these screens
-apart, but the backend is unchanged: there is still no current-password or recent-auth field on the
-API. **Fix:** require the current password (or a fresh OTP) on both paths.
-`user_service.go:371-378` (password), `:395-411` (MFA)
-
----
-
## Doing more than you're allowed
### T2 · The permission check only looks at one resource per request — HIGH
@@ -54,15 +37,15 @@ no access to. Every other known case is closed inside the handler; this is the l
parked patch `04` fixes it.
The real fix is the general one — teach the interceptor to collect *every* annotated resource field,
-so the next second-resource field doesn't reopen the hole. `acl.go:708-726`,
-`database_service.go:1047-1105`
+so the next second-resource field doesn't reopen the hole. `acl.go:735-753`,
+`database_service.go:1051-1082`
### T18a · Test-environment rights can cancel a production migration — MED
`BatchCancelTaskRuns` checks your permission against the stage *you claim in the URL*, then cancels
task runs by ID without ever confirming those IDs belong to that stage. So permission to cancel in
test is enough to kill an in-flight production migration in the same project. Sibling handlers get
-this right by reading the environment off the actual rows. `rollout_service.go:1034-1143`
+this right by reading the environment off the actual rows. `rollout_service.go:1040-1154`
### T11 · A create check is skipped on `allow_missing` updates — MED
@@ -72,7 +55,7 @@ member can create groups anyway — but the code comment right above it claims t
which is how this survives review.
Same root cause, wider: 15 of the 45 CUSTOM RPCs declare a `permission` annotation that is never
-enforced. It's decorative, and it reads as protection. `acl.go:252-254`, `group_service.go:172-177`
+enforced. It's decorative, and it reads as protection. `acl.go:251-253`, `group_service.go:167-177`
---
@@ -83,18 +66,19 @@ enforced. It's decorative, and it reads as protection. `acl.go:252-254`, `group_
The worst one: **rotating a leaked cloud credential can silently no-op.** `UpdateDataSource` decides
what to write based on the `authentication_type` in the request rather than the mask or the stored
value, so a request carrying only a new GCP credential falls through an empty branch and writes
-nothing. You get HTTP 200 and the compromised key stays live. `instance_service.go:1346-1388`
+nothing. You get HTTP 200 and the compromised key stays live. `instance_service.go:1405-1447`
The other three lose data rather than fail to save it:
- **`UpdateSetting` replaces whole settings.** Updating your Slack config wipes stored Feishu, WeCom,
Lark, DingTalk and Teams secrets — and it *validates* the mask path first, then ignores it. For
- environments the replace cascades into every instance and database. `setting_service.go:508-512`
+ environments the replace cascades into every instance and database. `setting_service.go:329-391`,
+ `:505-525`
- **`UpdateDatabaseCatalog` never reads a mask at all** and replaces the whole config column, wiping
other schemas' classification and masking. Its proto comment refers to an `update_mask` field that
doesn't exist. `database_catalog_service.go:96-139`
- **`UpdateIssue` implements four fields** and silently drops the rest, so `update_mask=["status"]`
- returns 200 and does nothing. `issue_service.go:883-910`
+ returns 200 and does nothing. `issue_service.go:922-948`
Underneath: some Update RPCs reject unknown mask paths, others ignore them, in four different error
wordings. There's no shared validator.
@@ -107,13 +91,13 @@ read-modify-write round-trips the policy etag and has it silently discarded, so
permissions at once means one edit vanishes. If the lost edit was a revoke, access stays granted.
The saved-query path already implements this correctly, so the pattern is in-tree.
-`project_service.go:586`, `workspace_service.go:437`
+`project_service.go:601`, `workspace_service.go:437`
### T18c-i · Deleting several projects can half-finish — MED
`BatchDeleteProjects` purges in a loop with no transaction. A failure partway leaves some projects
irreversibly purged, and the error names only the one that failed — not the ones already gone.
-`project_service.go:485-489`
+`project_service.go:495-504`
---
@@ -126,7 +110,7 @@ token is minted, and *then* non-matching issues are dropped in Go. So filtering
approval" in a busy workspace shows an empty list with a live "Load more" button underneath.
This is the default My Issues view, and there's no empty-page workaround on the frontend.
-`issue_service_converter.go:29-41`, `issue_service.go:139-148`
+`issue_service_converter.go:29-41`, `issue_service.go:134-148`
(Same shape as the `SearchProjects` bug that parked patch `03` fixes — also still unmerged.)
@@ -153,9 +137,9 @@ None of this is documented, and the responses are bare repeated lists — so any
- **The query-history `instance ==` filter always returns nothing.** It compares an instance name
against a longer stored value using `LIKE` with no wildcard. The proto documents the broken form.
- `store/query_history.go:255-256`
+ `store/query_history.go:257`
- **`ListTaskRuns` has no pagination and no limit** — and its documented wildcard parent pulls an
- entire rollout in one call, on the table that grows fastest. `store/task_run.go:65-131`
+ entire rollout in one call, on the table that grows fastest. `store/task_run.go:64-130`
### T17 · Typing a quote breaks search — MED
@@ -164,7 +148,7 @@ that exists precisely for this, used at 6 sites; 11 others still interpolate raw
those search boxes and search fails with `InvalidArgument`. It also allows filter-semantics
injection — not a privilege boundary, since the filter only narrows an already-authorized list.
-Worst site: `accessGrant.ts:35` interpolates SQL statement text raw, while lines 38-40 right next to
+Worst site: `accessGrant.ts:35` interpolates SQL statement text raw, while lines 37-40 right next to
it do it safely.
---
@@ -177,19 +161,19 @@ it do it safely.
- **Email enumeration.** `Signup` answers "already registered" *before* it checks whether signup is
even allowed, so anyone can test whether an email has an account — on a workspace with signup
- disabled. `auth_service.go:328-334`
+ disabled. `auth_service.go:298-304` (existence), `:327-329` (restriction)
- **Open mail relay.** `SendEmailLoginCode` will send to any address over the customer's SMTP.
[#21177](https://github.com/bytebase/bytebase/pull/21177) added a domain check, but it only
applies if the domain-restriction license feature is on, enforcement is enabled, *and* a domain
list is set — no default deployment qualifies. The 60s cooldown is per recipient, so volume scales
- with the address list. `user_service.go:753-785`
+ with the address list. `auth_service_email_code.go:137-179`, `user_service.go:1443-1473`
- **LDAP config disclosure.** `ListIdentityProviders` hands any caller the SSO config for any
workspace ID they guess: LDAP host, port, bind DN, base DN, user filter, plus OAuth/OIDC endpoints
- and client IDs. Passwords and secrets are redacted. `idp_service.go:55-85`, `:526-535`
+ and client IDs. Passwords and secrets are redacted. `idp_service.go:55-85`, `:461-541`
- **Workspace-existence oracle.** `GetAuthenticationRestriction` (which replaced the actuator leak,
now fixed) is anonymous by design and doesn't need membership. Naming a real workspace returns
200, a fake one returns `InvalidArgument`. The pre-login page genuinely needs most of these
- fields; the oracle is the part worth closing. `auth_service.go:140-179`
+ fields; the oracle is the part worth closing. `auth_service.go:107-152`
### T18c-iii · `CheckRelease` error codes leak existence — MED · ✅ read myself
@@ -199,7 +183,7 @@ map which databases exist workspace-wide. [#21102](https://github.com/bytebase/b
added a third distinguishable error that also leaks instance ownership.
**Fix:** return `NotFound` for both, matching the convention `BatchCreateRevisions` already adopted,
-with a regression test. `release_service_check.go:92-111`
+with a regression test. `release_service_check.go:77-110`
---
@@ -220,13 +204,11 @@ constraints.
## What I'd do, in order
-1. **Require re-authentication for password change and 2FA disable (T10).** The one finding that
- turns a temporary compromise into a permanent one, and it affects both deployments.
-2. **Fix the ACL class, not the instance (T2).** Teach the interceptor to collect every annotated
+1. **Fix the ACL class, not the instance (T2).** Teach the interceptor to collect every annotated
resource field, then annotate `DiffSchema`. Otherwise the next second-resource field reopens it.
-3. **Make credential rotation fail loudly (T15).** A security operation that returns 200 and does
+2. **Make credential rotation fail loudly (T15).** A security operation that returns 200 and does
nothing is worse than one that errors.
-4. **Fail closed on auth annotations, and put api-linter in CI.** Reject
+3. **Fail closed on auth annotations, and put api-linter in CI.** Reject
`AUTH_METHOD_UNSPECIFIED` at startup; make a `permission` on a CUSTOM RPC either enforced or a
build error, since 15 are decorative. None of Tier 5 was visible to `buf lint`'s BASIC profile,
which is why it accumulated.
@@ -246,6 +228,7 @@ constraints.
| T13 `SearchWorksheets` | [#21160](https://github.com/bytebase/bytebase/pull/21160) + [#21178](https://github.com/bytebase/bytebase/pull/21178) — visibility predicate pushed into SQL before `LIMIT` |
| T18 worksheet write/delete | [#21169](https://github.com/bytebase/bytebase/pull/21169) + [#21181](https://github.com/bytebase/bytebase/pull/21181) — per-verb permissions; SQL Editor Read User can no longer rewrite or delete |
| T9 | [#21189](https://github.com/bytebase/bytebase/pull/21189) (self-hosted audit rows) + [#21234](https://github.com/bytebase/bytebase/pull/21234) — one `login_attempt` table bounds password, email-code, and MFA guessing per identity on both deployments, replacing the audit-log counter and the per-code attempt column (which bypassed the resend cooldown). Accepted with it: no per-tenant failed-login record on Cloud, and lockout-as-denial-of-service — see [`login-attempt-lockout.md`](login-attempt-lockout.md) |
+| T10 | [#21252](https://github.com/bytebase/bytebase/pull/21252) + [#21258](https://github.com/bytebase/bytebase/pull/21258) — password change and MFA lifecycle move off `UpdateUser` onto their own methods, each requiring a `CredentialProof`: current password, live OTP, recovery code, or a Cloud-only emailed re-auth code. Every proof claims a T9 login-attempt slot, so no proof channel is an unbounded guessing oracle, and a factor-touching method refuses the password while a live factor exists. Accepted with it: **the stolen access token still answers until it expires (≤1h)** — credential generation and the fenced transaction were cut or deferred, password change revokes only the account's web refresh tokens (best-effort, OAuth grants untouched), and an MFA change revokes nothing. What this closes is the credential being *spent* on its own replacement, not the session. Design, and the shipped-vs-designed delta: [`reauthenticate-credential-changes.md`](reauthenticate-credential-changes.md) |
**`AIService.Chat` — accepted, not fixed** (2026-08-18). `Chat` requires an authenticated workspace
principal and touches no database or sheet, so the only exposure is LLM spend. On Cloud the feature