simpl-liste/scripts
le king fu 97f5a6bad6 fix(security): whitelist sync data columns and check ownership of references
POST /api/sync copied the client's `data` into `.set()` for list, task
and tag updates, so an authenticated client could rewrite `userId`
(moving its rows into another account), `id`, `createdAt` or
`deletedAt`. Task-tag links, task `listId`/`parentId` and list creation
did not check that the referenced rows belong to the caller.

- web/src/lib/syncData.ts: one zod schema per entity and action. Unknown
  keys are stripped rather than rejected, because the app marks its
  outbox as synced on HTTP 200 and a skipped operation would be lost.
  Strings are truncated to the mobile limits (notes 10000). Null maps
  to undefined for NOT NULL columns.
- processOperation writes only the parsed output; taskTag create and
  delete verify the task and the tag; task create/update verify
  listId; parentId and list create ids are refused when taken by
  another account (a missing parent passes, since initialMerge can push
  a subtask before its parent).
- vitest 4.1 (vitest 5 requires @types/node >= 22, web is on 20) with
  tests built from the payloads the app sends today.
- REVIEW.md: rules and pitfall updated, npm test added, syncData.ts in
  the Haut table (review-levels.py --check passes).

Refs #142

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 22:11:49 -04:00
..
review-levels.py fix(security): whitelist sync data columns and check ownership of references 2026-10-19 22:11:49 -04:00