Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: Skip invalid-id series sidecars without a retry flag (#8355)

[._.]/ Adam Eivy3e0fff1feb86
diff --git a/server/services/sharing/peerSync.test.js b/server/services/sharing/peerSync.test.js
index c7ef127e84..f03f706ace 100644
--- a/server/services/sharing/peerSync.test.js
+++ b/server/services/sharing/peerSync.test.js
@@ -3266,11 +3266,11 @@ describe('peerSync', () => {
expect(mergeOutlineFromSync).not.toHaveBeenCalled();
});
- it('skips mergeReviewFromSync and marks pending when the series id is malformed (security: #8355)', async () => {
+ it('skips mergeReviewFromSync without a retry flag when the series id is malformed (security: #8355)', async () => {
// A series id containing `../` or not matching the required "ser-" prefix
// must not trigger a merge that could write files outside the series directory.
const manuscriptReview = { schemaVersion: 1, comments: [{ id: 'mrc-1', problem: 'x', status: 'open', updatedAt: '2026-06-02T00:00:00Z' }] };
- await applyIncomingPush({
+ const result = await applyIncomingPush({
kind: 'series',
record: { id: '../../../etc/passwd', name: 'S', deleted: false, deletedAt: null },
issues: [],
@@ -3279,13 +3279,16 @@ describe('peerSync', () => {
sourceInstanceId: 'peer-a',
});
expect(mergeReviewFromSync).not.toHaveBeenCalled();
+ // An invalid id can never become valid — a pending flag would make the
+ // sender withhold its hash and resend forever.
+ expect(result.reviewSyncPending).toBeUndefined();
});
- it('skips mergeOutlineFromSync and marks pending when the series id is malformed (security: #8355)', async () => {
+ it('skips mergeOutlineFromSync without a retry flag when the series id is malformed (security: #8355)', async () => {
// A series id not matching the required "ser-" prefix pattern must not
// trigger a merge that could write files outside the series directory.
const reverseOutline = sampleOutline();
- await applyIncomingPush({
+ const result = await applyIncomingPush({
kind: 'series',
record: { id: 'evil/../../etc/passwd', name: 'S', deleted: false, deletedAt: null },
issues: [],
@@ -3294,6 +3297,7 @@ describe('peerSync', () => {
sourceInstanceId: 'peer-a',
});
expect(mergeOutlineFromSync).not.toHaveBeenCalled();
+ expect(result.outlineSyncPending).toBeUndefined();
});
it('refuses to merge linkedCollection when the incoming record is a tombstone', async () => {
diff --git a/server/services/sharing/peerSyncReceive.js b/server/services/sharing/peerSyncReceive.js
index 1aba82ec4e..2a1b001e3e 100644
--- a/server/services/sharing/peerSyncReceive.js
+++ b/server/services/sharing/peerSyncReceive.js
@@ -276,12 +276,15 @@ export async function applyIncomingPush(payload, authorization) {
if (!localEphemeral && Array.isArray(issues) && issues.length > 0) {
await mergeIssuesFromSync(issues, { source, senderSchemaVersions });
}
- // Bundled sidecar docs (manuscript-review, reverse-outline) are only valid
- // if the series id matches the expected format. A malformed id (e.g.
- // containing `../`) could traverse directories and write files outside the
- // series store. Skip merges for invalid ids — the series record itself is
- // already merged, so mark the bundle as pending to retry next cycle.
+ // Bundled sidecar docs (manuscript-review, reverse-outline) write under the
+ // series record dir, so a malformed id (e.g. containing `../`) would escape
+ // the series store. mergeSeriesFromSync already refused the record itself;
+ // skip its sidecars too. NOT marked pending: an invalid id can never become
+ // valid, so withholding the sender's hash would retry it forever.
const seriesIdValid = SERIES_ID_RE.test(record.id);
+ if (!seriesIdValid && (isPlainObject(manuscriptReview) || isPlainObject(reverseOutline))) {
+ console.warn(`⚠️ peerSync: skipped bundled series sidecars for invalid series id`);
+ }
// Merge the bundled manuscript-review sibling doc, LWW-per-comment. Same
// guards as the issue batch + linkedCollection below: skip for local-
// ephemeral records (the user opted this series out of sync) and tombstone
@@ -295,8 +298,6 @@ export async function applyIncomingPush(payload, authorization) {
if (seriesIdValid && !localEphemeral && record.deleted !== true && isPlainObject(manuscriptReview)) {
const { mergeReviewFromSync } = await import('../pipeline/manuscriptReview.js');
await mergeReviewFromSync(record.id, manuscriptReview).catch(markPending('manuscriptReview'));
- } else if (!seriesIdValid && isPlainObject(manuscriptReview)) {
- markPending('manuscriptReview')(new Error('Invalid series id'));
}
// Merge the bundled reverse-outline sibling doc, whole-doc LWW on
// generatedAt. Same ephemeral/tombstone guards + pending-signal contract as
@@ -306,8 +307,6 @@ export async function applyIncomingPush(payload, authorization) {
if (seriesIdValid && !localEphemeral && record.deleted !== true && isPlainObject(reverseOutline)) {
const { mergeOutlineFromSync } = await import('../pipeline/reverseOutline.js');
await mergeOutlineFromSync(record.id, reverseOutline).catch(markPending('reverseOutline'));
- } else if (!seriesIdValid && isPlainObject(reverseOutline)) {
- markPending('reverseOutline')(new Error('Invalid series id'));
}
} else if (kind === 'writersRoomWork') {
// Did the receiver accept the remote work (insert / remote-won LWW)? This