[GH-ISSUE #4867] [Issue]: Undated local UI settings can overwrite server preferences #2694

Closed
opened 2026-10-21 05:53:14 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Xelvanis on GitHub (Aug 10, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4867

Originally assigned to: @SpicyMarinara on GitHub.

Summary

A browser-local UI settings blob with no trustworthy marinara-engine-ui-updated-at timestamp can be stamped as current during startup and replace the server's complete synced UI settings profile. This can silently revert unrelated cross-device preferences to stale local values.

Expected behavior

When a local UI settings cache has no valid timestamp and a server UI settings blob exists, server-present keys should remain authoritative. Local values should be used only for keys missing from the server, after which the merged complete profile can be rewritten with a current timestamp.

Existing behavior should remain unchanged when the local timestamp is valid or when no server settings blob exists yet.

Actual behavior

useSettingsSync determines that an undated local profile is customized, assigns it Date.now() before reading the server, and then treats it as newer than a dated server profile. The local-wins branch calls pushNow(), which serializes and PUTs the entire local pickSyncedSettings projection. The server stores the UI settings as one opaque replacement value, so unrelated server-present preferences are overwritten rather than merged.

This is a pre-existing compatibility/recovery issue and is not caused by adding enterToSendGame to the synced projection.

Steps to reproduce

  1. Use a server with a nonempty app_settings.ui profile containing a finite __updatedAt and at least one customized shared preference.
  2. In another browser, restore or retain a customized/legacy marinara-engine-ui local-storage blob whose companion marinara-engine-ui-updated-at key is absent or invalid.
  3. Start that browser against the same Marinara server.
  4. Observe startup settings arbitration.
  5. Inspect the resulting server app_settings.ui value.
  6. The browser synthesizes a current local timestamp and replaces the full server profile, reverting server-present preferences to the stale browser's values.

A long-unopened pre-timestamp browser can reach this path after current UI-store migration. Other plausible triggers are restoring the UI local-storage blob without its companion timestamp or selective storage corruption/cleanup.

Environment

  • Marinara Engine version: staging commit 5732c27c9acccaa22498ecea58afd715a97886dc
  • Install type: source/static investigation; applies to browser-local settings sync
  • OS + version: not exercised
  • Browser or app shell: not exercised

Logs, screenshots, or video

No runtime logs or screenshots. The issue was established through bounded source/history tracing and prior real-store hydration/projection probes.

Relevant code paths:

  • packages/client/src/hooks/use-settings-sync.ts
    • readLocalUpdatedAt() returns null for missing/invalid values.
    • Startup assigns Date.now() when local state is customized but undated, before fetching server settings.
    • localIsNewer then selects pushNow().
    • pushNow() PUTs the complete pickSyncedSettings projection.
  • packages/server/src/routes/app-settings.routes.ts
    • PUT /app-settings/:key accepts and stores the complete opaque value.
  • packages/server/src/services/storage/app-settings.storage.ts
    • set() replaces the stored value for the key.

Additional context

The realistic blast radius is one user's cross-browser UI preferences, including appearance and synchronized input/chat/image/player preferences. Chats, messages, characters, personas, lorebooks, and other content are not overwritten.

The original pre-timestamp cohort is shrinking because a successful modern startup writes the timestamp. The path remains plausible for long-unopened browsers, selectively restored backups, or loss of the companion timestamp key.

Suggested bounded repair:

  1. Preserve whether the local timestamp was actually read as valid before synthesizing any timestamp.
  2. If a server blob exists and local timestamp provenance is absent, overlay server-present keys onto local state and retain local values only for server-missing keys.
  3. Best-effort rewrite the merged complete projection with a current timestamp.
  4. Preserve current valid-timestamp last-write-wins behavior and no-server local seeding.
  5. Add focused regression coverage for an undated migrated local blob conflicting with a dated server blob, a local fallback for a server-missing key, valid-newer-local behavior, and no-server seeding.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Xelvanis on GitHub (Aug 10, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4867 Originally assigned to: @SpicyMarinara on GitHub. <!-- task-id: undated-local-ui-settings-arbitration --> ## Summary A browser-local UI settings blob with no trustworthy `marinara-engine-ui-updated-at` timestamp can be stamped as current during startup and replace the server's complete synced UI settings profile. This can silently revert unrelated cross-device preferences to stale local values. ## Expected behavior When a local UI settings cache has no valid timestamp and a server UI settings blob exists, server-present keys should remain authoritative. Local values should be used only for keys missing from the server, after which the merged complete profile can be rewritten with a current timestamp. Existing behavior should remain unchanged when the local timestamp is valid or when no server settings blob exists yet. ## Actual behavior `useSettingsSync` determines that an undated local profile is customized, assigns it `Date.now()` before reading the server, and then treats it as newer than a dated server profile. The local-wins branch calls `pushNow()`, which serializes and PUTs the entire local `pickSyncedSettings` projection. The server stores the UI settings as one opaque replacement value, so unrelated server-present preferences are overwritten rather than merged. This is a pre-existing compatibility/recovery issue and is not caused by adding `enterToSendGame` to the synced projection. ## Steps to reproduce 1. Use a server with a nonempty `app_settings.ui` profile containing a finite `__updatedAt` and at least one customized shared preference. 2. In another browser, restore or retain a customized/legacy `marinara-engine-ui` local-storage blob whose companion `marinara-engine-ui-updated-at` key is absent or invalid. 3. Start that browser against the same Marinara server. 4. Observe startup settings arbitration. 5. Inspect the resulting server `app_settings.ui` value. 6. The browser synthesizes a current local timestamp and replaces the full server profile, reverting server-present preferences to the stale browser's values. A long-unopened pre-timestamp browser can reach this path after current UI-store migration. Other plausible triggers are restoring the UI local-storage blob without its companion timestamp or selective storage corruption/cleanup. ## Environment - Marinara Engine version: `staging` commit `5732c27c9acccaa22498ecea58afd715a97886dc` - Install type: source/static investigation; applies to browser-local settings sync - OS + version: not exercised - Browser or app shell: not exercised ## Logs, screenshots, or video No runtime logs or screenshots. The issue was established through bounded source/history tracing and prior real-store hydration/projection probes. Relevant code paths: - `packages/client/src/hooks/use-settings-sync.ts` - `readLocalUpdatedAt()` returns `null` for missing/invalid values. - Startup assigns `Date.now()` when local state is customized but undated, before fetching server settings. - `localIsNewer` then selects `pushNow()`. - `pushNow()` PUTs the complete `pickSyncedSettings` projection. - `packages/server/src/routes/app-settings.routes.ts` - `PUT /app-settings/:key` accepts and stores the complete opaque value. - `packages/server/src/services/storage/app-settings.storage.ts` - `set()` replaces the stored value for the key. ## Additional context The realistic blast radius is one user's cross-browser UI preferences, including appearance and synchronized input/chat/image/player preferences. Chats, messages, characters, personas, lorebooks, and other content are not overwritten. The original pre-timestamp cohort is shrinking because a successful modern startup writes the timestamp. The path remains plausible for long-unopened browsers, selectively restored backups, or loss of the companion timestamp key. Suggested bounded repair: 1. Preserve whether the local timestamp was actually read as valid before synthesizing any timestamp. 2. If a server blob exists and local timestamp provenance is absent, overlay server-present keys onto local state and retain local values only for server-missing keys. 3. Best-effort rewrite the merged complete projection with a current timestamp. 4. Preserve current valid-timestamp last-write-wins behavior and no-server local seeding. 5. Add focused regression coverage for an undated migrated local blob conflicting with a dated server blob, a local fallback for a server-missing key, valid-newer-local behavior, and no-server seeding. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:53:14 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#2694
No description provided.