domma-cms 1.47.4 → 1.47.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.47.5] - 2026-11-08
4
+
5
+ - **Security: the site's own records are never written through the public collections API.** `roles`, `user-profiles`, API tokens, projects and the other built-in collections refuse create, update and delete on `/api/v1/:slug` and `/api/collections/:slug/public` whatever their API settings say - with `roles` create set to public, an anonymous request could make a top-level role. Admins change them in the admin as before; the Tools' notes, tasks and contacts (each user's own rows) are unchanged.
6
+
3
7
  ## [1.47.4] - 2026-11-08
4
8
 
5
9
  - **Security: files visitors send with a form are private.** They were saved to content/media/, served to anyone at `/media/<name>` and listed in the Media library - CVs and right-to-work documents among them. New uploads go to `content/form-uploads/<form>/<upload id>/` (kept out of the site repo by its own `.gitignore`) and are served only by `GET /api/forms/:slug/uploads/:id/:name`, to a signed-in user with the submissions inbox's permission (`collections` read) who can see the form, while a submission links to the file. Only PNG, JPEG, GIF, WebP and PDF are shown inline; everything else is a download, always with nosniff, `private, no-store` and a CSP that runs nothing. The submission panel shows pictures and opens files with the admin's sign-in; the notification email links to them and says to sign in (files are not attached). On first start a one-off migration moves the files existing submissions reference into the private store and rewrites the references - only real submissions (`meta.source: form:<slug>`) and only regular files (a link or folder is skipped); a file a page or other content also links to is copied and left in Media. The file route's CSP also has `frame-ancestors 'none'`. Webhooks, Actions and plugins that fetched a submission's file URL without signing in can no longer do so.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "domma-cms",
3
- "version": "1.47.4",
3
+ "version": "1.47.5",
4
4
  "description": "File-based CMS powered by Domma and Fastify. Run npx domma-cms my-site to create a new project.",
5
5
  "type": "module",
6
6
  "main": "server/server.js",
@@ -59,7 +59,7 @@ import {getRoleLevel, invalidate as invalidateRoles, isBaseRole} from '../../ser
59
59
  import {getEffectiveLevel} from '../../services/userRoles.js';
60
60
  import {getConfig, saveConfig} from '../../config.js';
61
61
  import {riskyConnectionOptions, signedOnly} from '../../services/codePolicy.js';
62
- import {PRESET_COLLECTION_SLUGS} from '../../services/presetCollections.js';
62
+ import {PRESET_COLLECTION_SLUGS, USER_DATA_PRESET_SLUGS} from '../../services/presetCollections.js';
63
63
  import {ensureFormForCollection} from '../../services/forms.js';
64
64
  import {hooks} from '../../services/hooks.js';
65
65
  import {DRAFT_STATUS, authenticateApiToken, draftsOnlyDecision, scopeAllows} from '../../services/apiTokens.js';
@@ -78,6 +78,12 @@ import {
78
78
 
79
79
  const ALL_PRESET_SLUGS = new Set(['roles', 'user-profiles', ...PRESET_COLLECTION_SLUGS]);
80
80
 
81
+ /** Built-in collections the public surface never writes: every preset bar the user-data ones, and anything systemManaged. */
82
+ function isSystemCollection(schema) {
83
+ if (schema?.systemManaged) return true;
84
+ return ALL_PRESET_SLUGS.has(schema?.slug) && !USER_DATA_PRESET_SLUGS.includes(schema.slug);
85
+ }
86
+
81
87
  /**
82
88
  * The generic routes are open to anyone holding `collections`, which every
83
89
  * level-1 admin does. Two kinds of collection need more than that (see
@@ -279,6 +285,14 @@ async function publicAccessGate(schema, operation, request, reply) {
279
285
  return reply.status(404).send({ error: 'Not found' });
280
286
  }
281
287
 
288
+ // The site's own records are never written through the public surface, whatever their api block
289
+ // says: with roles.create set to public (or a role, or token mode) an anonymous POST made a level-0
290
+ // role. Admins change them in the admin. The Tools' user-data presets (notes, tasks, contacts) are
291
+ // the exception - each user writes their own rows here, row access deciding (ownRow/pinOwner).
292
+ if (operation !== 'read' && isSystemCollection(schema)) {
293
+ return reply.status(403).send({ error: 'This collection cannot be written through the public API' });
294
+ }
295
+
282
296
  const access = schema.api?.[operation];
283
297
  if (!access?.enabled) {
284
298
  return reply.status(403).send({ error: `Public ${operation} is disabled for this collection` });