docs(performance): add CollabTable performance report

This commit is contained in:
Gabriel20xx committed 2026-10-16 22:54:30 +00:00
1 parent 6aec03fb3d
commit 7dd0d34383
3 files changed
+352

No files matched your search

+96
View File
@@ -0,0 +1,96 @@
# Performance Report — CollabTable
- **Project:** CollabTable
- **Path:** /workspace/Personal/Web/Originals/CollabTable
- **Analyzed:** 2026-10-16
- **Commit:** 6aec03f on main
- **Working tree:** clean (no uncommitted changes, no untracked files)
- **Stack:** Go 1.26 (net/http, pgx v5) API server; PostgreSQL; SvelteKit 2 / Svelte 5 static SPA (Vite 8, TanStack Query) embedded in the Go binary; Android client (Kotlin, Room, Retrofit) with offline sync; Docker multi-stage image on `scratch`; GitHub Actions.
- **Scope:** Read all first-party backend code (`backend/*.go`, including tests), `docker/Dockerfile`, `.dockerignore`, `.github/workflows/*`, the frontend data layer, list components, routes and Vite config, the Android API client, preferences and sync repository, and the shared auth, postgres and authclient code that CollabTable calls. Excluded: `node_modules`, `frontend/.svelte-kit`, the Gradle wrapper, lock files (read for versions only), build output, and the rest of `shared/` (node, python and java packages, which CollabTable does not use). Tracked SQLite files were inspected read-only from a copy (schema and row counts only). No tests, builds or linters were run; the analysis is static.
## Summary
| Severity | Count |
|---|---:|
| Critical | 0 |
| High | 2 |
| Medium | 5 |
| Low | 3 |
| Info | 1 |
Two structural costs dominate: the dashboard re-downloads the full database every 5 seconds, and sync writes row by row with several round trips per value inside one long transaction. Missing indexes and pagination will make both worse as data grows.
## Issues
### P-001 · Dashboard re-downloads the entire dataset every 5 seconds · **High**
- **Location:** `backend/web.go:9-29` (four unpaginated queries), `backend/data.go:68-204` (no LIMIT in any query builder), `backend/web.go:74-76` (`no-store`), `frontend/src/lib/features/lists/listsData.svelte.js:4,10`, `frontend/src/lib/api.js:27-29`
- **Description:** `createOverviewData()` polls `/web/data` with `refetchInterval: 5000`. Each response contains every non-deleted list, every field, every item and every item value, with no pagination, no `since` filter and no HTTP caching (`Cache-Control: no-store`). The server already computes per-list effective update times (`web.go:31-72`), but the client has no way to use them to skip unchanged data. TanStack Query's default is to poll only while the tab is visible, so each open dashboard pays this cost.
- **Impact:** Transfer, JSON encoding and client re-rendering all scale with total data size rather than with the amount of change. With a few thousand items and several viewers this is continuous multi-megabyte traffic and repeated full re-renders.
- **Recommendation:** Serve changes incrementally with a `since` cursor (as sync already does), or add an ETag derived from the maximum `updatedat` and answer `304` when nothing changed, dropping `no-store` for that path. Compress the response (see P-006). Consider a longer interval or server push for the dashboard.
### P-002 · Sync issues several statements per row inside one long transaction · **High**
- **Location:** `backend/sync.go:61-209` (the transaction closure). For item values, `sync.go:172-207`: `listid` lookup (`:175`), `EXISTS` on items (`:185`), optional stub insert (`:193`), upsert (`:198`) and a notification insert (`:206`). Per-row upserts at `sync.go:64-79`, `:104-126`, `:149-164`. Request size is capped at 50 MB by `backend/server.go:253-259`.
- **Description:** Every list, field, item and value in a request is processed one at a time with separate statements. Each item value needs four to five round trips, plus a notification row per change, and the whole batch holds row locks until commit. There is no cap on the number of rows per request.
- **Impact:** An initial sync or a large offline push (potentially thousands of rows) becomes thousands of sequential round trips. The transaction stays open for the whole batch, and the 60-second `WriteTimeout` (`server.go:123`) can cut the request off. The device then retries and repeats the same work, and concurrent devices contend on the same rows.
- **Recommendation:** Batch the writes, using `pgx.Batch` or multi-row `INSERT ... SELECT FROM unnest(...)` upserts per table. Load the field-to-list map once per request instead of once per value. Insert notifications as one multi-row statement per request. Cap rows per request, return `413` above the cap, and have clients chunk their pushes.
### P-003 · No index on `updatedat`, so every delta query scans the table · **Medium**
- **Location:** `backend/db.go:40-189` (indexes exist only on `fields.listid`, `items.listid`, `item_values.itemid`, `item_values.fieldid`, and notifications `createdat` and `listid`, at `:83-86` and `:97-98`). Queries filtering on `updatedat`: `backend/data.go:75`, `:108`, `:145`, `:178`; sync calls at `backend/sync.go:220-235`.
- **Description:** Sync and `/web/data` filter with `updatedat >= $1`, but `lists`, `fields`, `items` and `item_values` have no index on `updatedat`. Rows are soft-deleted and never physically removed, so the tables only grow.
- **Impact:** Every sync from every device performs four full table scans, and the cost grows with history rather than with recent change volume.
- **Recommendation:** Add `CREATE INDEX IF NOT EXISTS` on `updatedat` for `lists`, `items`, `fields` and `item_values` in `initSchema`. Consider `(isdeleted, updatedat)` if soft-delete filtering is common in the same queries.
### P-004 · No pagination on list endpoints or the sync response; the first sync returns everything · **Medium**
- **Location:** `backend/data.go:68-204` (`queryLists`, `queryFields`, `queryItems`, `queryValues`, none with LIMIT), `backend/data.go:228-235` (`GET /api/lists`), `backend/sync.go:216-248` (`since` is nil when `lastSync == 0`, so the full table is returned).
- **Description:** Collection endpoints return unbounded arrays. The first sync from any device (`lastSync == 0`) returns every list, field, item and value in the database in one response.
- **Impact:** Response size and server memory grow linearly with total data. Large first syncs risk the 60-second write timeout and slow mobile clients.
- **Recommendation:** Add keyset pagination (a `(updatedat, id)` cursor and a `limit` parameter) to the collection endpoints. For sync, return a `hasMore` flag and a cursor, and let the client loop until it is caught up.
### P-005 · Frontend scans full arrays for every row, card and cell on each poll · **Medium**
- **Location:** `frontend/src/routes/lists/[id]/+page.svelte:94` (`itemValuesFor(overview.values, item.id)` runs once per visible row and scans every value in the database) and `:98` (`valueFor` per cell); `frontend/src/lib/components/lists/ListCard.svelte:7-8` (each card filters all fields and all items); `frontend/src/lib/features/lists/listHelpers.js:1-15` (linear `filter` and `find` with no index).
- **Description:** The helpers are linear scans over the complete data set, and they run for every visible row and card. Because each 5-second poll replaces the arrays, every derived value is recomputed on every poll.
- **Impact:** Cost per render is roughly visible rows times total values. With a large data set this appears as delayed input and scroll jank.
- **Recommendation:** Build lookup maps once per data change in a `$derived` (a `Map` keyed by `listId`, by `itemId`, and by `itemId + fieldId`). Pass pre-grouped slices into the card and row components. Rely on TanStack's structural sharing so unchanged data keeps its references.
### P-006 · No HTTP compression and no cache headers on JSON or static assets · **Medium**
- **Location:** `backend/server.go:118-125` (plain `http.Server`, no compression middleware), `backend/server.go:292-316` (`spaFileServer` sets no `Cache-Control`), `backend/web.go:74-76` (`no-store` on `/web/data`).
- **Description:** JSON responses (`/web/data`, `/api/sync`, `/api/lists`) are sent uncompressed. Static build output, including content-hashed Vite assets, is served with no cache-control, and the embedded filesystem provides no modification times for conditional requests.
- **Impact:** Large JSON bodies transfer several times more bytes than necessary, and browsers refetch the whole app bundle on each visit.
- **Recommendation:** Add gzip or brotli middleware, or enable it at the reverse proxy. Set `Cache-Control: public, max-age=31536000, immutable` for `_app/immutable/*` and `no-cache` for `index.html`. Add ETags for `/web/data` (see P-001).
### P-007 · Request bodies up to 50 MB are decoded into memory with no per-route limit · **Medium**
- **Location:** `backend/server.go:253-259` (`decodeJSON` uses `io.LimitReader(r.Body, 50*1024*1024)`), used by `backend/sync.go:46` and by the write handlers in `backend/data.go`.
- **Description:** Every write endpoint accepts up to 50 MB of JSON and decodes it fully into Go structs. `io.LimitReader` truncates silently, so an oversized body fails with a confusing decode error instead of `413`. These handlers have no concurrency cap, so each concurrent request can allocate its full decode buffer.
- **Impact:** A few concurrent large requests can exhaust memory. It is also an easy denial-of-service vector (see the rate-limiting note in the Security report).
- **Recommendation:** Use `http.MaxBytesReader` with per-route limits (for example 1 to 5 MB for single-entity writes, and a higher bound for sync), returning `413` when exceeded. Bound concurrent sync transactions with a semaphore sized below `DATABASE_MAX_CONNS`.
### P-008 · One notification row per changed row, on every write path · **Low**
- **Location:** `backend/sync.go:79`, `:126`, `:164`, `:206`; `backend/data.go:256`, `:302`, `:364`, `:418`, `:507`, `:561`, `:605`, `:621`; retention in `backend/db.go:212-230`; polling in `backend/web.go:92-141` (`LIMIT 500` at `:109`).
- **Description:** Each changed row inserts its own notification. A 1,000-value sync writes 1,000 extra rows, and each one is later read by the Android poller.
- **Impact:** Write amplification on the hot path and extra cleanup load. Clients polling 500 notifications at a time may need several polls to catch up after a bulk change.
- **Recommendation:** Coalesce notifications per list per request, so a sync produces one row per affected list. Alternatively, drop per-row notifications and rely on the `updatedat` delta.
### P-009 · Docker build context and cache layering can be tighter · **Low**
- **Location:** `docker/Dockerfile:34-35` (`COPY shared/backend/` happens before `go mod download`); `.dockerignore` excludes `.git`, `node_modules`, `data/` and `collabtable.db`, but not `CollabTableAndroid/`, `.github/` or `**/node_modules` under `shared/`.
- **Description:** Any edit under `shared/backend` invalidates the module-download layer, because the source is copied before `go mod download`. The build context also includes the whole Android project and CI files, which slows context transfer.
- **Impact:** Slower builds and avoidable cache misses in CI.
- **Recommendation:** Copy only `shared/backend/go.mod` and `go.sum` before `go mod download`, and copy the rest of `shared/backend` afterwards. Add `CollabTableAndroid/`, `.github/` and `**/node_modules` to `.dockerignore`.
### P-010 · No statement timeout or per-query budget on the database pool · **Low**
- **Location:** `shared/backend/postgres/postgres.go:114-121` (pool defaults: `MaxConns: 20`, no `statement_timeout`); `backend/sync.go:61` (the transaction runs under the request context).
- **Description:** Queries are bounded only by the request context. Nothing caps statement run time at the database, and a long sync transaction holds a pool connection for its full duration.
- **Impact:** A slow query or a large sync can hold one of 20 connections for longer than intended and starve other requests.
- **Recommendation:** Set `statement_timeout` (and optionally `lock_timeout`) as pool runtime parameters, and set `DATABASE_MAX_CONNS` explicitly for each environment. Combine this with the batching in P-002.
### P-011 · Checked, no issue found · **Info**
- **Location:** `shared/backend/authclient/client.go:116` (5-second HTTP client timeout on outbound identity calls); `docker/Dockerfile:41-47` (final stage is `FROM scratch`, runs as `65534`, and contains only the binary and CA bundle); `backend/db.go:83-98` (indexes on the foreign-key and list-scoped lookup columns, and on notification `createdat` for cleanup and polling).
- **Description:** Outbound identity calls have a timeout, the runtime image is minimal and contains no build tools, and the main lookup paths are indexed.
- **Impact:** None. Recorded so these areas are not re-checked.
- **Recommendation:** None.
## Notes
- Static analysis only. No tests, builds, Docker builds, lint runs or load tests were executed. Estimates come from code reading and should be confirmed with a benchmark on realistic data (for example a few thousand items across several devices).
- AuthGuard's own performance is outside this repository and was not analyzed.
- `shared/` was reviewed selectively: the parts CollabTable imports (`backend/auth`, `authclient`, `authproxy`, `coreconfig`, `postgres`, and the `carriernodeclient` construction). The shared web-ui was searched with grep only. The node, python and java packages were not reviewed.
- The frontend bundle was not measured. The web-ui is imported through its barrel (`import { Pagination } from '@gabriel20xx/web-ui'`), and whether that tree-shakes needs verification with a production build.
- No TODO, FIXME or HACK markers were found in `backend/` or `frontend/src/`.
+113
View File
@@ -0,0 +1,113 @@
# Code Quality Report — CollabTable
- **Project:** CollabTable
- **Path:** /workspace/Personal/Web/Originals/CollabTable
- **Analyzed:** 2026-10-16
- **Commit:** 6aec03f on main
- **Working tree:** clean (no uncommitted changes, no untracked files)
- **Stack:** Go 1.26 (net/http, pgx v5) API server; PostgreSQL; SvelteKit 2 / Svelte 5 static SPA (Vite 8, Tailwind 4, TanStack Query) embedded in the Go binary; Android client (Kotlin, Jetpack Compose, Room, Retrofit/OkHttp); Docker; GitHub Actions.
- **Scope:** Read all first-party backend code (`backend/*.go`, including the five test files), the frontend data layer, routes, list components and Vite config, the Android API client, preferences, sync repository and app Gradle file, `README.md`, `.github/workflows/*`, `docker/Dockerfile`, and the shared auth, postgres and authclient code that CollabTable calls. Excluded: `node_modules`, `frontend/.svelte-kit`, the Gradle wrapper jar, generated build output, lock files (read for versions only), and the rest of `shared/`. The tracked SQLite files were inspected read-only from a copy. No tests, linters or builds were run.
## Summary
| Severity | Count |
|---|---:|
| Critical | 0 |
| High | 0 |
| Medium | 6 |
| Low | 8 |
| Info | 0 |
The backend is small and readable, but its transactional and delete logic is duplicated across the REST and sync paths and has drifted apart. A few error-handling assumptions are wrong, and the data layer has essentially no test coverage.
## Issues
### Q-001 · Notification errors inside transactions abort the sync they were meant to tolerate · **Medium**
- **Location:** `backend/notifications.go:51-57` (`ignoreNotificationError`); called inside transactions at `backend/sync.go:79`, `:126`, `:164`, `:206` and `backend/data.go:453`.
- **Description:** `ignoreNotificationError` says a failed notification "must never roll back the data mutation". When the notification insert runs inside the transaction, PostgreSQL marks the transaction as aborted after any failing statement, so the next statement fails and the commit cannot succeed. The error is only logged, which makes the function look like it tolerates the failure, but the whole sync then returns `500 Sync failed` after rolling back. The comment is wrong for these paths.
- **Impact:** A transient failure of a notification insert turns a successful write into a failed sync, and the client retries the same payload. Maintainers reading the comment will assume the opposite of what happens.
- **Recommendation:** Isolate the notification insert in a savepoint (a nested `tx.Begin` in pgx, or `SAVEPOINT` and `ROLLBACK TO SAVEPOINT`), or write notifications after commit. Update the comment to match the actual behavior.
### Q-002 · Delete semantics differ between REST endpoints and sync · **Medium**
- **Location:** `backend/data.go:309-321` (REST list delete sets only `lists.isdeleted`); `backend/sync.go:81-91` (sync list delete also cascades to fields, items and values); `backend/data.go:420-455` (field delete cascades only when no active fields remain); `backend/data.go:609-621` (item delete updates the item, then deletes its values in a separate statement whose error is discarded at `:620`, and skips the notification at `:618-619` if the re-read fails).
- **Description:** The same logical operations (delete a list, delete an item) leave different state depending on the entry point. A list deleted through REST keeps its fields, items and values active, while the same delete through sync removes the children. `/web/data` filters out deleted lists but still returns the active items and values that belong to them (`backend/web.go:31-72`). Item deletion is not atomic and can leave orphaned values if the second statement fails.
- **Impact:** The dashboard, the Android client and sync can disagree about what exists, and orphaned values are silently accepted.
- **Recommendation:** Implement `deleteList`, `deleteField` and `deleteItem` once, each inside a transaction, and call them from both REST and sync. Check every error.
### Q-003 · `handleSync` is a 200-line function, and cascade logic is duplicated · **Medium**
- **Location:** `backend/sync.go:45-249` (one function; the transaction closure spans `:61-209`). Duplicated cascade logic: `sync.go:128-143` and `backend/data.go:440-452`. Event-type selection repeated at `sync.go:72-78`, `:119-125` and `:157-163`. Default-value handling repeated at `sync.go:96-103` and `backend/data.go:349-354` and `:393-398`.
- **Description:** Upserts, notifications, cascades and response assembly all live in one closure. The business rules for deletion, defaults and event types are implemented twice, once in the sync handler and once in the REST handlers. Q-002 is a direct result of this duplication.
- **Impact:** Hard to test or change safely, and the two code paths have already diverged.
- **Recommendation:** Extract a small repository layer (`upsertList`, `upsertField`, `upsertItem`, `upsertValue`, `deleteList`, `deleteField`, `deleteItem`) shared by the REST handlers and sync, and keep the handlers as thin request and response adapters. Move event-type selection into one helper.
### Q-004 · Core data layer has no tests, and CI never starts a database · **Medium**
- **Location:** `backend/routes_test.go:8-11` (registers routes with a nil database and asserts nothing); `backend/auth_test.go`, `env_test.go`, `models_test.go` and `sync_test.go` (cover env parsing, JSON timestamp parsing, timestamp normalization and the auth stub only); `.github/workflows/tests.yml` (Go job runs `go test ./...` with no Postgres service); the frontend has no unit tests (CI runs `npm run check` only); `CollabTableAndroid/app/src` has no test sources.
- **Description:** No test exercises `handleSync`, the list, field, item and value handlers, `/web/data`, the CORS wrapper, the SPA fallback, or the frontend helpers in `listHelpers.js`. The one route test runs without assertions.
- **Impact:** The most complex logic (sync merge, cascades, notification side effects, timestamp handling) is covered only by manual testing, so regressions like Q-001 and Q-002 are invisible.
- **Recommendation:** Add `httptest` integration tests against a real Postgres (as a CI service container), starting with sync round trips and delete cascades. Give `routes_test.go` real assertions on methods and status codes. Add Vitest tests for `listHelpers.js`, and JVM unit tests for the Android sync merge logic.
### Q-005 · Setup documentation contradicts the configuration · **Medium**
- **Location:** `README.md:52` (`SECRET` marked as optional, default "unset (push endpoint refuses every caller)"); `README.md:70-79` (Quick Start `docker run` sets no `SECRET`); `README.md:55` (`COOKIE_SECURE` described as marking cookies `Secure`); `shared/backend/auth/proxy.go:359-361` and `:838-841`; `backend/auth.go:113-120`; `frontend/vite.config.js:38-41` (dev proxy forwards only `/web` and `/health`).
- **Description:** The auth service is built with `RequireSecret()` (`auth.go:118`). When `SECRET` is unset, `/api/auth/status` and every auth-gated route return `500 SECRET environment variable is not set.`, so the documented Quick Start produces a dashboard that cannot load. The README table also calls `SECRET` optional. The live session cookie's `Secure` and `SameSite` attributes come from AuthGuard (see Security S-013), so `COOKIE_SECURE` does not do what the README says. `npm run dev` proxies only `/web` and `/health`, but the dashboard calls `/api/auth/*` and `/api/tech-stack` (`frontend/src/lib/api.js`), so the dev server cannot reach the API.
- **Impact:** Operators who follow the docs get a deployment that fails or looks secure when it is not, and developers hit a confusing dev setup.
- **Recommendation:** Mark `SECRET` as required when auth is enabled, add it to the Quick Start, correct the `COOKIE_SECURE` description, and add `/api` to the Vite proxy.
### Q-006 · Client-supplied timestamps drive the change cursor and overwrite unconditionally · **Medium**
- **Location:** `backend/sync.go:20-43` (client timestamps accepted as sent, clamped only if in the future); upserts that overwrite regardless of the stored `updatedat`: `sync.go:64-69`, `:104-116`, `:149-156`, `:198-203`; the delta cursor filters on the stored value at `backend/data.go:75`, `:108`, `:145`, `:178`. Android: local edits stamped with device time (`CollabTableAndroid/app/src/main/java/com/collabtable/app/ui/screens/ListDetailViewModel.kt:148`), and the cursor is the server's `serverTimestamp` (`CollabTableAndroid/app/src/main/java/com/collabtable/app/data/repository/SyncRepository.kt:49-60`, `:283`).
- **Description:** Two related problems. (1) A device that edits offline stamps the change with an old local time. If another device has already advanced its cursor past that time, the `updatedat >= since` filter never returns the change to it. (2) Upserts overwrite the stored row whatever its `updatedat`, so an older change that arrives later replaces a newer one. The Android client mitigates (1) by forcing a full down-sync at app start (`SyncRepository.kt:122`), so the devices affected are those that stay open for a long time.
- **Impact:** Silent divergence between devices, and lost updates when two devices edit the same row offline. Dashboard users see stale data until a device restarts.
- **Recommendation:** Assign server-side change tokens (a monotonically increasing sequence, or the server receive time) to every write and use that as the cursor, keeping client `updatedat` for display only. Alternatively, make each upsert conditional on `EXCLUDED.updatedat` being newer than the stored value, and document the last-writer-wins rule.
### Q-007 · Validation and error mapping return misleading status codes and contract drift · **Low**
- **Location:** `backend/data.go:248-255` (duplicate list id returns `500 Failed to create list` rather than `409`); `backend/data.go:549-558` (an item value for a missing item or field fails on a foreign key and returns `500`); `backend/data.go:589-607` (`PUT /api/items/{id}` accepts a body but only bumps `updatedat`, ignoring the body); `backend/server.go:292-316` (unknown `/api/...` paths return `index.html` with `200`).
- **Description:** Client errors are reported as server errors, one endpoint documents a body it does not use, and unknown API paths get HTML with a success status.
- **Impact:** Clients cannot distinguish retryable from permanent failures, and an API mistake returns a web page instead of an error.
- **Recommendation:** Map unique and foreign-key violations (`pgconn.PgError` codes `23505` and `23503`) to `409` and `422`. Make `PUT /api/items/{id}` either apply the documented fields or be removed. Return JSON `404` for unmatched `/api/` paths before the SPA fallback.
### Q-008 · Dead code and unused wiring · **Low**
- **Location:** `backend/notifications.go:59-61` (`isNoRows` has no callers); `backend/server.go:38` and `:96-106` (the `carrierNode` client is built, stored and never used, and it holds the internal secret); `backend/db.go:111-140` and `:165-169` (retired auth tables are still created on every start); `backend/db.go:197-210` (session-pruning goroutine for those retired tables).
- **Description:** Dead helpers and an unused client remain in place. The retired tables are still managed by startup code even though nothing reads them.
- **Impact:** Noise for maintainers, and a secret held in memory for no purpose.
- **Recommendation:** Remove `isNoRows`. Construct the CarrierNode client only when a feature uses it. Drop the session-pruning goroutine, or document why it stays.
### Q-009 · Several failures are discarded without a comment on the risk · **Low**
- **Location:** `backend/data.go:424` and `:587` (`_ = decodeJSON(...)` on DELETE and PUT with an optional body); `backend/data.go:620` (`_, _ =` on the item value delete); `backend/data.go:618-619` (a failed item re-read silently skips the notification); `backend/sync.go:211` (raw database error text is logged, which can include values).
- **Description:** Errors are ignored in several places. The `decodeJSON` ignores are reasonable for optional bodies, but `data.go:620` guards data integrity, and the others hide failures from operators.
- **Impact:** Silent inconsistency (see Q-002) and harder debugging.
- **Recommendation:** Check and return the error from the value delete. Document the intentional `decodeJSON` ignores, or return `400` on a malformed body. Log errors with a request identifier rather than raw values.
### Q-010 · CI does not cover shared code, lint is partial, and Node versions disagree · **Low**
- **Location:** `.github/workflows/tests.yml` and `.github/workflows/lint.yml` `paths:` filters include `backend/**` and `frontend/**` but not `shared/**`, although `backend/go.mod` replaces the shared module with `../shared/backend` (`docker.yml` does include `shared/**`); `.github/workflows/lint.yml:41` (`node-version: '20'`) against `tests.yml:64` (`'22'`), `docker/Dockerfile:4` (`node:22-alpine`) and `README.md:85` (`Node.js 22+`); no Go lint job (`gofmt`, `go vet`, `golangci-lint`); the `format:check` script in `frontend/package.json` is not run; Android has no CI (acknowledged in the README).
- **Description:** A breaking change in `shared/backend` does not trigger the Go test job on push or pull request, and lint runs on Node 20 while everything else uses 22.
- **Impact:** Breakage in the shared library can reach `main` untested by push-triggered checks. The Docker build compiles it, but does not run its tests.
- **Recommendation:** Add `shared/backend/**` and `shared/packages/web-ui/**` to the Go and frontend workflow paths. Standardize on Node 22. Add `gofmt -l` and `go vet` to the Go job, and `npm run format:check` to lint.
### Q-011 · Unpinned and inconsistent dependency declarations · **Low**
- **Location:** `frontend/package.json` `devDependencies` and `dependencies` blocks (21 entries use `"latest"`, including `svelte`, `@sveltejs/kit`, `vite` and `@tanstack/svelte-query`); `.github/workflows/tests.yml:70` (web-ui installed with `--no-package-lock`); `CollabTableAndroid/app/build.gradle` (`compose-bom:2024.06.00` for the app but `2023.10.01` for `androidTestImplementation`, and `retrofit` declared as both `implementation` and `kapt`).
- **Description:** `"latest"` specifiers make the declared range meaningless and rely entirely on the lock file being respected. CI installs web-ui without a lock file. The Android app and test dependency sets use different Compose BOMs.
- **Impact:** Upgrades happen implicitly whenever the lock is regenerated, and app and test builds can resolve different Compose versions.
- **Recommendation:** Pin ranges (for example a caret range around the locked Svelte 5.56.8), commit the lock, and use `npm ci` for web-ui in CI. Align the Compose BOM and remove the redundant `kapt` Retrofit line.
### Q-012 · Release build has minification disabled · **Low**
- **Location:** `CollabTableAndroid/app/build.gradle:30` (`minifyEnabled false` in the `release` build type).
- **Description:** The release build ships unshrunk, unobfuscated code, and `proguard-rules.pro` has no effect because minification is off.
- **Impact:** Larger APK, and easier reverse engineering of the sync protocol.
- **Recommendation:** Enable `minifyEnabled true` and `shrinkResources true` for release, then verify with a release build and the Gson and Retrofit keep rules.
### Q-013 · Mutable singleton in the Android API client is not synchronized · **Low**
- **Location:** `CollabTableAndroid/app/src/main/java/com/collabtable/app/data/api/ApiClient.kt:15-18` (mutable `baseUrl`, `retrofit` and `context`); `:119-137` (`initialize` and `setBaseUrl` rebuild Retrofit); `:139-145` (the `api` getter builds Retrofit lazily).
- **Description:** The singleton's fields are written from settings and read from background sync work without synchronization or `@Volatile`, and the lazy getter can build Retrofit twice.
- **Impact:** Possibly a stale base URL or a duplicate client during a settings change. This needs verification by changing the URL while a sync is running.
- **Recommendation:** Guard the state with a lock or `@Volatile`, or make the base URL an immutable value that is rebuilt through a single factory driven by a `StateFlow`.
### Q-014 · Stale and junk artifacts are tracked in the repository · **Low**
- **Location:** `backend/data/collabtable.db` (69,632-byte SQLite file; all five tables have zero rows and a pre-migration camelCase schema); `backend/collabtable.db` (0 bytes); `CollabTableAndroid/build-errors.txt` (contains only an interrupt marker); `CollabTableAndroid/build-output.txt` (4.8 KB build log); root `.gitignore` (no `*.db` or build-log rule).
- **Description:** Database files and build logs are committed. The SQLite file is a leftover from the Node-era schema, and the Go server uses PostgreSQL only. No credentials or user data were found in them.
- **Impact:** Confusing for contributors, and a risk if real data is ever saved there.
- **Recommendation:** Remove the tracked files, add ignore rules for `*.db` and `build-*.txt`, and keep only the placeholder `backend/web/.gitkeep`.
## Notes
- Static review only. No tests, linters, Go or Node builds, or Gradle runs were executed. Test coverage was assessed by reading the `_test.go` files and the CI workflows.
- Checked and clean: no `{@html}`, `innerHTML` or `eval` in the dashboard; error wrapping in `backend/db.go` and the auth helpers is consistent; `shared/backend/postgres/postgres.go:216-235` (`WithTx`) rolls back through a deferred call on every path; no TODO, FIXME or HACK markers in `backend/` or `frontend/src/`.
- `map[string]any` is used for several ad hoc response bodies (`backend/web.go:77-89`, `backend/data.go:464` and `:623`). That is acceptable for these responses, and no weakly typed data flows through the core domain types.
- `shared/` was reviewed selectively. Two items in it are outside CollabTable's runtime and are noted for the shared package owners rather than counted here: `shared/backend/syncsocket/syncsocket.go:269` sets `InsecureSkipVerify` (which disables WebSocket origin checks) when the allowed origin is `*`, and the package is not imported by CollabTable.
+143
View File
@@ -0,0 +1,143 @@
# Security Report — CollabTable
- **Project:** CollabTable
- **Path:** /workspace/Personal/Web/Originals/CollabTable
- **Analyzed:** 2026-10-16
- **Commit:** 6aec03f on main
- **Working tree:** clean (no uncommitted changes, no untracked files)
- **Stack:** Go 1.26 (net/http, pgx v5) API server with PostgreSQL; identity delegated to a separate AuthGuard service via `shared/backend/auth`; SvelteKit 2 / Svelte 5 static dashboard embedded in the Go binary; Android client (Kotlin, Retrofit/OkHttp, Room, SharedPreferences); Docker multi-stage image on `scratch`; GitHub Actions.
- **Scope:** Read all first-party backend code (`backend/*.go`), the Docker and CI configuration, the frontend API client, routes and query layer, the Vite config, the Android API client, preferences, manifest, network security config and app Gradle file, and the shared auth, authclient, authproxy, coreconfig and postgres code that CollabTable calls. Git history was searched for credential-shaped strings and `.env` files. Excluded: `node_modules`, `frontend/.svelte-kit`, the Gradle wrapper, generated build output, lock files (read for versions only), and the rest of `shared/`. Tracked SQLite files were inspected read-only from a copy, schema and row counts only. No tests, audits, builds or network calls were made; the analysis is static.
## Summary
| Severity | Count |
|---|---:|
| Critical | 0 |
| High | 0 |
| Medium | 10 |
| Low | 7 |
| Info | 2 |
No critical or high-severity issues were confirmed. Authentication is delegated to AuthGuard and fails closed when it is not configured, and sync tokens are generated with 256 bits of randomness and stored hashed. The main concerns are a reflective CORS policy with credentials, a login-disabled mode that hands out sync tokens to anyone, the absence of object-level authorization on data (possibly intended, but unscoped), missing rate limiting and security headers, and several Android client exposures (the token written to logcat, cleartext traffic permitted, and the token stored in plain preferences).
## Issues
### S-001 · Reflective CORS with credentials on every route · **Medium**
- **Location:** `backend/server.go:274-290` (`withCORS`), in particular `:276-281`.
- **Description:** The middleware echoes any request `Origin` into `Access-Control-Allow-Origin` and sets `Access-Control-Allow-Credentials: true` on all responses, including session-protected routes (`/web/data`, `/api/auth/users`, `/api/auth/token/regenerate`). If the browser sends the user's cookies, any origin can read those responses. The preflight `Allow-Methods` list also omits `PATCH`, which `server.go:181` accepts.
- **Impact:** Exploitability depends on the AuthGuard cookie attributes, which are not in this repository. With `SameSite=Lax`, a cross-site page will not receive the cookie, but a same-site origin will (another subdomain of the same site, or a sibling app on a shared cookie domain, which the authclient docs describe as a cross-project SSO option). Such an origin could read `/web/data` or call `POST /api/auth/token/regenerate` and read the new sync token. Rated Medium here; it would be High if the cookie is scoped to a parent domain. Needs verification against the deployed AuthGuard cookie.
- **Recommendation:** Replace the reflection with an explicit allow-list from configuration (for example `ALLOWED_ORIGINS`) and set credentials headers only for those origins. The dashboard is same-origin and needs no CORS headers at all, so the default should be none. Keep `Vary: Origin` and add `PATCH` to the allowed methods if it is needed.
### S-002 · Login-disabled mode lets anyone obtain a write-capable sync token · **Medium**
- **Location:** `backend/server.go:186-188` (`POST /api/auth/token/regenerate` behind `RequireIfLoginRequired`); `shared/backend/auth/proxy.go:504-519` (`CurrentUser` returns the superadmin placeholder whenever login is not required); `backend/auth.go:194-210` (`handleTokenRegenerate` mints a token for the placeholder identity).
- **Description:** When login is not required (`AUTH_DISABLED=true`, or the login-required override pushed by ProjectConfigurator set to false), `RequireIfLoginRequired` lets any caller reach token regeneration without credentials. The endpoint mints a write-capable sync token for identity 0, and the bearer-token check on the sync API then passes for that caller.
- **Impact:** The sync API's token requirement protects nothing in that mode, and any network client can obtain full read, write and delete access. The README describes `AUTH_DISABLED` as "nothing gated", so this matches the documented intent. The override path can be set centrally in a shared deployment, however, and nobody may notice that the token API has become open.
- **Recommendation:** Keep token minting behind a real credential even when login is off (for example, always require a session for token regeneration), or document the consequence prominently and log a warning when the override is set to false.
### S-003 · No object-level ownership or roles on list, field, item or value data · **Medium**
- **Location:** `backend/auth.go:129-149` (`requireAPIToken` only checks that a token exists); `backend/server.go:195-219` (all data routes); `backend/data.go` (all handlers); `backend/sync.go:61-209`; `backend/db.go:40-189` (no owner or tenant columns); `backend/sync.go:198-203` and `backend/data.go:549-558` (item values upserted by `id` alone).
- **Description:** Any valid sync token (one per account) and any logged-in account can read, overwrite, soft-delete and move every list, field, item and value. The item-value conflict clause updates only `value` and `updatedat`, so a write that names a different `itemId` or `fieldId` than the stored row is silently applied to the stored row. The schema has no owner column, and `api_tokens.user_id` is used only for token regeneration. Item values are hard-deleted when their item or list is deleted (`sync.go:88`, `:129`, `:140`, `:166`), so those deletions cannot be undone by a later sync, even though lists and items are soft-deleted.
- **Impact:** For a collaborative tool this may be intended, in which case every account is effectively an administrator of the data. If it is not intended, it is an authorization gap. Either way, one compromised device token can wipe or rewrite the database, and some of that loss is permanent.
- **Recommendation:** Confirm the intended model and document it. If the data is shared, make item-value upserts reject writes whose `itemid` or `fieldid` do not match the stored row. If per-list access is needed, add a membership table and check it in every handler.
### S-004 · Managed-user routes require a login only, leaving the role check to AuthGuard · **Medium**
- **Location:** `backend/server.go:178-182` (list, create, update and delete users, behind `RequireIfLoginRequired`); `shared/backend/auth/proxy.go:897-1013` (handlers forward the caller's session to AuthGuard without a local role check); `shared/backend/auth/proxy.go:618` (`RequireUserManager` exists but CollabTable does not use it).
- **Description:** The handlers document that AuthGuard enforces authorization, which holds only if AuthGuard rejects non-admin sessions. CollabTable does not check the role before proxying. If AuthGuard does not reject it, `GET /api/auth/users` returns every account's username, email and role to any logged-in account.
- **Impact:** No defense in depth. A bug or policy change in AuthGuard would expose administrative functions here. Needs verification against the deployed AuthGuard version.
- **Recommendation:** Gate these routes with `RequireUserManager` (or `RequireAdminIfLoginRequired`), which the shared package already provides, so the policy is visible in this repository.
### S-005 · Password change does not require the current password, and existing sessions stay valid · **Medium**
- **Location:** `shared/backend/auth/proxy.go:664-705` (`UpdateMe` accepts only `email`, `username` and `password`); `backend/auth.go:39-43` (documented behavior: a credentials change "simply returns the updated account and leaves the current session valid").
- **Description:** Anyone holding a session cookie can change the account password without knowing the current one. Sessions on other devices also remain valid, and there is no re-authentication step.
- **Impact:** A stolen or unattended session can lock the owner out. The usual defenses (re-authentication, and revoking other sessions on password change) are absent.
- **Recommendation:** Require `currentPassword` (and the TOTP code when enabled) on `POST /api/auth/credentials` whenever the password changes, and have AuthGuard revoke other sessions on a password change.
### S-006 · No rate limiting or request budgets on login, token use, writes or body size · **Medium**
- **Location:** `shared/backend/auth/proxy.go:1093-1142` (`Login` forwards every attempt to AuthGuard with no local throttling); `backend/auth.go:129-149` (sync-token check, no throttling); `backend/server.go:188` (token regeneration); `backend/server.go:253-259` (up to 50 MB per request, see P-007).
- **Description:** A search of CollabTable and the shared auth packages finds no rate limiter, lockout or request throttle. Brute-force protection for passwords and TOTP codes depends entirely on AuthGuard. Sync tokens carry 256 bits of entropy, so guessing them is not a practical concern; the issue is request volume and availability.
- **Impact:** Credential stuffing against the login proxy, load from unthrottled token checks, and memory exhaustion from large bodies.
- **Recommendation:** Add per-IP and per-account limits on `/api/auth/login`, `/api/auth/totp/*` and `/api/auth/setup`, either in-process or at the proxy. Confirm AuthGuard's own limits. Enforce body size per route (see P-007).
### S-007 · No security headers on the dashboard or API · **Medium**
- **Location:** `backend/server.go:118-125` (no header middleware); `backend/server.go:292-316` (`spaFileServer` writes `index.html` with only `Content-Type`); `backend/web.go:74-76` (cache headers only).
- **Description:** Responses carry no `Content-Security-Policy`, no `X-Frame-Options` or `frame-ancestors`, no `X-Content-Type-Options` and no `Referrer-Policy`. The app can be framed, which allows clickjacking of user-management and token-regeneration actions. Without a CSP, an injected script would have no restrictions. No unsafe HTML rendering was found in first-party code, which limits the immediate risk.
- **Impact:** Clickjacking of logged-in actions and a weaker defense against future XSS. HSTS belongs at the TLS terminator and is not set here.
- **Recommendation:** Add middleware that sets `X-Frame-Options: DENY` (or `frame-ancestors 'none'`), `X-Content-Type-Options: nosniff`, `Referrer-Policy: strict-origin-when-cross-origin`, and a CSP such as `default-src 'self'` with hashes or nonces for SvelteKit's inline bootstrap script. Set HSTS at the proxy.
### S-008 · Android app logs full HTTP traffic, including the bearer token, in every build · **Medium**
- **Location:** `CollabTableAndroid/app/src/main/java/com/collabtable/app/data/api/ApiClient.kt:20-23` (`HttpLoggingInterceptor` at `Level.BODY`), and `:55-64` (the interceptor is added to the client unconditionally; `authInterceptor` at `:58` sets the `Authorization` header first).
- **Description:** The logging interceptor is not gated on the debug build type, and it does not redact headers. Its output includes the `Authorization: Bearer <token>` header and the full request and response bodies, which carry all list and item data, in release builds.
- **Impact:** The long-lived sync token and user data end up in logcat and in any log capture or bug report. Exploiting this requires access to device logs (ADB, a debugging tool, or a bug report), not a remote attack.
- **Recommendation:** Use `Level.NONE` for release builds (for example `if (BuildConfig.DEBUG)`), call `redactHeader("Authorization")`, and do not log bodies in production.
### S-009 · Cleartext HTTP is allowed for all domains and is the default server URL · **Medium**
- **Location:** `CollabTableAndroid/app/src/main/res/xml/network_security_config.xml:3-4` (`cleartextTrafficPermitted="true"` in `base-config`); `CollabTableAndroid/app/src/main/java/com/collabtable/app/data/preferences/PreferencesManager.kt:298` (default `http://10.0.2.2:8080/api/`); `CollabTableAndroid/app/src/main/java/com/collabtable/app/data/api/ApiClient.kt:25-44` (the bearer token is attached to every request).
- **Description:** The release app accepts `http://` server URLs for any host, and the bearer token is sent with every request. Traffic is unencrypted and can be read or altered on the network path.
- **Impact:** Token and data exposure on untrusted networks whenever an operator configures an HTTP URL. Cleartext is needed only for the emulator default.
- **Recommendation:** Keep cleartext only for debug builds (a debug resource overlay) or for `10.0.2.2` and `localhost`. Require HTTPS for remote hosts and reject `http://` in the settings UI otherwise.
### S-010 · Long-lived sync token stored in plain SharedPreferences, with app backup enabled · **Medium**
- **Location:** `CollabTableAndroid/app/src/main/java/com/collabtable/app/data/preferences/PreferencesManager.kt:73-80` and `:283` (token written to `collab_table_prefs` with `MODE_PRIVATE`, unencrypted); `CollabTableAndroid/app/src/main/AndroidManifest.xml:11` (`android:allowBackup="true"`).
- **Description:** The API token is written to ordinary SharedPreferences. With `allowBackup="true"` the file is included in device backups, and on a rooted device or with ADB backup access it can be read directly.
- **Impact:** The token grants full sync access (see S-003) and can be recovered from a backup or a compromised device.
- **Recommendation:** Store the token with `EncryptedSharedPreferences` or the Android Keystore, exclude it from backups with `dataExtractionRules` and `fullBackupContent`, or set `allowBackup="false"`.
### S-011 · Sync token has no expiry, scope or per-device identity · **Low**
- **Location:** `backend/db.go:181-188` (`api_tokens` has no expiry column); `backend/auth.go:159-170` (32 random bytes, stored as an unsalted SHA-256 hash); `backend/auth.go:194-210` (regeneration replaces the account's single token).
- **Description:** The token is well built: 256 bits from `crypto/rand`, stored only as a hash, and checked through an indexed lookup. It never expires, carries no scope, and cannot be revoked per device. Regenerating invalidates every device at once.
- **Impact:** A lost or retired device keeps write access until the operator regenerates the token, and regenerating also breaks every other device.
- **Recommendation:** Issue per-device tokens with `last_used` and `expires_at` columns and a revoke action, or at least document a rotation procedure.
### S-012 · Shared-secret comparisons are not constant-time · **Low**
- **Location:** `shared/backend/coreconfig/coreconfig.go:182` (`r.Header.Get("X-Internal-Auth") != secret`); `shared/backend/auth/proxy.go:819` (same pattern in `SetLoginRequiredInternal`).
- **Description:** A `!=` comparison on strings can exit early. Other helpers in the workspace use `subtle.ConstantTimeCompare` (`shared/backend/auth/reset.go:73`, `shared/backend/auth/totp.go:82`), so these two are inconsistent.
- **Impact:** A theoretical timing side channel on the internal `SECRET`. Network jitter makes practical exploitation unlikely.
- **Recommendation:** Compare with `subtle.ConstantTimeCompare` on byte slices, after confirming that the expected secret is non-empty.
### S-013 · `COOKIE_SECURE` does not govern the session cookie; its attributes come from AuthGuard · **Low**
- **Location:** `shared/backend/authclient/client.go:411-417` (`ForwardCookies` replays AuthGuard's `Set-Cookie` unchanged); `shared/backend/auth/proxy.go:1140` (login forwards those cookies); `shared/backend/authproxy/authproxy.go:72-83` (only the logout-clearing cookies use the `secure` flag); `README.md:55`.
- **Description:** The README says `COOKIE_SECURE=true` marks cookies `Secure`. In practice that flag affects only the cookies CollabTable clears on logout. The live session cookie's `Secure`, `SameSite` and `Domain` attributes come from AuthGuard. Needs verification against the AuthGuard configuration.
- **Impact:** An operator may believe the session cookie is `Secure` when it is not, and the cookie's scope (see S-001) is not visible from this repository.
- **Recommendation:** Document that AuthGuard controls these attributes, and verify them in a deployed environment (`Secure`, `HttpOnly`, `SameSite`, `Domain`).
### S-014 · No length or format limits on input, and item-value upserts do not check row ownership · **Low**
- **Location:** `backend/models.go:50-94` (all IDs and free-text fields are unconstrained strings); `backend/data.go:223-263` (list creation checks only for an empty ID and name); `backend/sync.go:96-98` (`fieldType` accepts any string); `backend/sync.go:198-203` and `backend/data.go:549-558` (the upsert conflict clause ignores `itemid` and `fieldid`); `backend/data.go:206-214` (the `X-Device-Id` header is stored verbatim in notifications).
- **Description:** Client-chosen primary keys and free-text fields have no length or character limits, and `fieldType` is not checked against the types the UI understands. The item-value conflict clause (see S-003) silently ignores a mismatched `itemId` or `fieldId`. The device identifier is stored without limits.
- **Impact:** Oversized rows and storage growth, inconsistent typing, and a data-integrity problem that is as much a correctness issue as a security one.
- **Recommendation:** Bound string lengths (IDs to a sensible maximum such as 64 characters, names to a few hundred, values to a configured limit). Validate `fieldType` against the known set. Reject item-value writes whose `itemId` or `fieldId` do not match the stored row, or add that check to the conflict clause.
### S-015 · Public first-run setup can be claimed by whoever reaches the server first · **Low**
- **Location:** `backend/server.go:173` (`POST /api/auth/setup` is public); `shared/backend/auth/proxy.go:1014-1091` (`Signup` registers the first AuthGuard account while setup is unclaimed).
- **Description:** Until an operator completes setup, anyone who can reach the URL can create the first account, which in AuthGuard is the superadmin. The claim flag prevents a second setup, but not a first-visitor takeover.
- **Impact:** Matters only for a deployment reachable from untrusted networks before setup is completed. It is a common pattern for setup flows, but it should be stated.
- **Recommendation:** Complete setup before exposing the service, or protect `/api/auth/setup` with a one-time setup token printed at startup or supplied through the environment.
### S-016 · CI and supply-chain hygiene · **Low**
- **Location:** `.github/workflows/docker.yml:52` (`echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login ...`, with the secret interpolated into the shell script); `.github/workflows/docker.yml:34-65`, `.github/workflows/lint.yml:35-39` and `.github/workflows/tests.yml:35-62` (third-party actions pinned to major tags, not commit SHAs); `.github/workflows/tests.yml:70` (web-ui installed with `--no-package-lock`).
- **Description:** The Docker Hub token is interpolated into a shell command rather than passed through an environment variable. Actions are referenced by mutable tags.
- **Impact:** Lower risk on GitHub-hosted runners, but a compromised action tag would run with access to the secret on pushes to `main`.
- **Recommendation:** Pass the secret through an `env:` entry and pipe it to `docker login --password-stdin` from that variable. Pin actions to full commit SHAs, which Dependabot can maintain. Use a lock file for web-ui.
### S-017 · Dependency versions need an audit, which was not possible offline · **Low**
- **Location:** `backend/go.mod` (`github.com/jackc/pgx/v5 v5.10.0`, `golang.org/x/crypto v0.54.0`, `github.com/joho/godotenv v1.5.1`); `frontend/package-lock.json` (`svelte 5.56.8`, `@sveltejs/kit 2.70.2`, `vite 8.2.0`, `@tanstack/svelte-query 6.1.38`, `tailwindcss 4.3.3`); `frontend/package.json` (21 `"latest"` specifiers, see Q-011 in the Quality report); `CollabTableAndroid/app/build.gradle` (`okhttp3:logging-interceptor 4.12.0`, `retrofit2 2.9.0`, `kotlinx-coroutines-android 1.7.3`).
- **Description:** Versions were read from manifests and locks only. No vulnerability database was queried, because that requires network access. Several Android libraries are older releases, for example Retrofit 2.9.0 and kotlinx-coroutines 1.7.3.
- **Impact:** Known-vulnerable dependencies may be present. This review can neither confirm nor rule them out.
- **Recommendation:** Run `govulncheck ./...` in `backend`, `npm audit` (including build tooling) in `frontend`, and a Gradle dependency vulnerability scan (for example OWASP Dependency-Check) for the Android app. Upgrade whatever is flagged.
### S-018 · Committed-secret scan found no live credentials · **Info**
- **Location:** Tracked files (`git ls-files`); full history of `backend/.env.example` (commits `07e25a3` and `9a6ec94` for the `SECRET` and `DATABASE_URL` lines); `git log -G` over all refs for credential-shaped strings; `docker/Dockerfile`; `README.md`.
- **Description:** No `.env`, key or certificate files are tracked. The only env file is `backend/.env.example`, which holds placeholders. The historical `SECRET` value at `07e25a3` was the placeholder text, and the historical `DATABASE_URL` at `9a6ec94` was empty. The history search matched only test fixtures in `shared/` and documentation placeholders, and those hits were reviewed and redacted. The tracked SQLite file `backend/data/collabtable.db` has empty tables and no credentials (see Q-014 in the Quality report).
- **Impact:** None found.
- **Recommendation:** Keep `.env` ignored (it is, in `backend/.gitignore`), and consider a pre-commit secret scanner.
### S-019 · Controls verified as sound · **Info**
- **Location:** `backend/data.go:107-113`, `:145-149`, `:178-182` (dynamic SQL only adds numbered placeholders); `backend/db.go` and `backend/data.go` (all values bound as parameters); `backend/server.go:292-316` (static files served only from the embedded build, so no path traversal); `frontend/src` (no `{@html}`, `innerHTML` or `eval`; Svelte escapes text); `backend/auth.go:159-170` and `:194-210` (token generation and hashing); `shared/backend/coreconfig/coreconfig.go:182` and `shared/backend/auth/proxy.go:817-820` (internal endpoints refuse requests when `SECRET` is empty); `shared/backend/auth/proxy.go:359-361` and `:838-841` (auth fails closed when `SECRET` or the AuthGuard URL is missing); `shared/backend/authclient/client.go:116` (5-second timeout on outbound calls); `docker/Dockerfile:41-47` (non-root user, `scratch` base, no build tools in the final image); no `InsecureSkipVerify` or similar TLS bypass in CollabTable's own code or in the packages it imports.
- **Impact:** Positive findings.
- **Recommendation:** None.
## Notes
- Static analysis only. Nothing was executed: no tests, builds, dependency audits or network calls. Fail-closed behavior was confirmed by reading the code, not by running the server.
- AuthGuard, the identity service, is outside this repository. S-001 (exploitability), S-004, S-005, S-006 and S-013 depend on how it behaves and should be verified against a running instance.
- Android findings come from source, manifest and Gradle review. The app was not built or run.
- `shared/` was reviewed selectively. `shared/backend/syncsocket/syncsocket.go:269` sets `InsecureSkipVerify = true` (which disables WebSocket origin checks in the library) when the allowed origin is `*`. CollabTable does not import this package, so it is not counted here, but its owners should review it.
- `shared/.githooks/post-commit` runs `shared/scripts/sync-consumers.ps1 -Commit` on commit once the hook path is configured (see `install-sync-hook.ps1`). `-Push` is opt-in (`sync-consumers.ps1:11-12` and `:370`). This is a developer-workflow concern rather than a runtime one.