Skip to content

Commit 3a9cce5

Browse files
committed
fix(security): contain public worker rejection details
1 parent edfc57b commit 3a9cce5

9 files changed

Lines changed: 156 additions & 32 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ checkpoint, and status-only commits are intentionally omitted.
5858

5959
### Fixed
6060

61+
- Replaced public Worker exception text with endpoint-owned error codes and bounded direct-publication rejection categories, preserving distinct operational fingerprints without exposing submitted values or stack traces.
6162
- Replaced terminal live proof's authenticated `xvfb-run` wrapper with a TCP-disabled local Xvfb display so readiness probes and recording can connect without X authorization failures.
6263
- Made terminal live-proof recording wait for Xvfb and ffmpeg readiness and clean finalization, with tmux pane diagnostics on failure.
6364
- Routed every durable review-record publication lane through one shared, host-authenticated live-proof dispatcher, including queued exact-review batches grouped per target repository.

‎dashboard/exact-review-direct-publication.ts‎

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,6 +1696,80 @@ export async function validateDirectPublicationPlan(
16961696
};
16971697
}
16981698

1699+
export function directPublicationRejectionDetail(error: unknown): string {
1700+
const message = error instanceof Error ? error.message : "";
1701+
switch (message) {
1702+
case "invalid direct publication canonical target key":
1703+
return "invalid direct publication canonical target key";
1704+
case "invalid direct publication fence key":
1705+
return "invalid direct publication fence key";
1706+
case "invalid direct publication source SHA":
1707+
return "invalid direct publication source SHA";
1708+
case "invalid direct publication revision":
1709+
return "invalid direct publication revision";
1710+
case "invalid direct publication lifecycle plan":
1711+
return "invalid direct publication lifecycle plan";
1712+
case "invalid direct publication identity":
1713+
return "invalid direct publication identity";
1714+
case "a direct publication plan must change a path":
1715+
return "a direct publication plan must change a path";
1716+
case "a direct publication plan exceeds the exact-review tuple file limit":
1717+
return "a direct publication plan exceeds the exact-review tuple file limit";
1718+
case "direct publication total does not match its operations":
1719+
return "direct publication total does not match its operations";
1720+
case "direct publication plan exceeds the per-POST byte limit":
1721+
return "direct publication plan exceeds the per-POST byte limit";
1722+
case "conflicting direct publication retry":
1723+
return "conflicting direct publication retry";
1724+
case "direct publication source run identity is unavailable":
1725+
return "direct publication source run identity is unavailable";
1726+
case "direct publication source SHA is unavailable":
1727+
return "direct publication source SHA is unavailable";
1728+
}
1729+
if (message.startsWith("invalid bounded state mutation path:")) {
1730+
return "invalid bounded state mutation path";
1731+
}
1732+
if (message.startsWith("invalid or repeated direct publication path:")) {
1733+
return "invalid or repeated direct publication path";
1734+
}
1735+
if (message.startsWith("direct publication path is outside ")) {
1736+
return "direct publication path is outside its target tuple";
1737+
}
1738+
if (message.startsWith("invalid mutation mode for ")) return "invalid mutation mode";
1739+
if (message.startsWith("invalid mutation byte count for ")) return "invalid mutation byte count";
1740+
if (message.startsWith("deleted mutation paths must not carry content:")) {
1741+
return "deleted mutation paths must not carry content";
1742+
}
1743+
if (message.startsWith("missing or invalid mutation content for ")) {
1744+
return "missing or invalid mutation content";
1745+
}
1746+
if (message.startsWith("mutation byte count does not match content for ")) {
1747+
return "mutation byte count does not match content";
1748+
}
1749+
if (message.startsWith("canonical record content is not UTF-8:")) {
1750+
return "canonical record content is not UTF-8";
1751+
}
1752+
if (message.startsWith("canonical tuple has invalid primary/sidecar structure:")) {
1753+
return "canonical tuple has invalid primary/sidecar structure";
1754+
}
1755+
if (message.startsWith("canonical closed tuple retains a work plan:")) {
1756+
return "canonical closed tuple retains a work plan";
1757+
}
1758+
if (message.startsWith("canonical tuple references a missing decision packet:")) {
1759+
return "canonical tuple references a missing decision packet";
1760+
}
1761+
if (message.startsWith("canonical tuple decision packet reference is inconsistent:")) {
1762+
return "canonical tuple decision packet reference is inconsistent";
1763+
}
1764+
if (message.startsWith("direct publication tuple writes both primary sections:")) {
1765+
return "direct publication tuple writes both primary sections";
1766+
}
1767+
if (message.startsWith("canonical record tuple exceeds its file limit:")) {
1768+
return "canonical record tuple exceeds its file limit";
1769+
}
1770+
return "direct publication request failed";
1771+
}
1772+
16991773
function storedOperationsFrom(
17001774
operations: readonly CanonicalDirectPublicationOperation[],
17011775
): DirectPublicationStoredOperation[] {

‎dashboard/exact-review-queue.ts‎

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
EXACT_REVIEW_DIRECT_PUBLICATION_MAX_POST_BYTES,
2828
REVIEW_COVERAGE_INVENTORY_KEY,
2929
ExactReviewDirectPublicationStore,
30+
directPublicationRejectionDetail,
3031
normalizeReviewCoverageInventory,
3132
sha256Hex,
3233
validateCanonicalRecordTupleMutation,
@@ -3044,7 +3045,7 @@ export class ExactReviewQueue {
30443045
202,
30453046
);
30463047
} catch (error) {
3047-
const detail = sanitizedServerError(error);
3048+
const detail = directPublicationRejectionDetail(error);
30483049
console.warn("direct_publication_plan_rejected");
30493050
return json(
30503051
{
@@ -3185,8 +3186,8 @@ export class ExactReviewQueue {
31853186
this.githubWebhookReadModelStore.ingest(await request.json().catch(() => null)),
31863187
202,
31873188
);
3188-
} catch (error) {
3189-
return json({ error: sanitizedServerError(error) }, 400);
3189+
} catch {
3190+
return json({ error: "invalid_github_webhook_read_model_delivery" }, 400);
31903191
}
31913192
}
31923193

@@ -3256,8 +3257,8 @@ export class ExactReviewQueue {
32563257
this.githubWebhookReadModelStore.repair(await request.json().catch(() => null)),
32573258
202,
32583259
);
3259-
} catch (error) {
3260-
return json({ error: sanitizedServerError(error) }, 400);
3260+
} catch {
3261+
return json({ error: "invalid_github_webhook_read_model_repair" }, 400);
32613262
}
32623263
}
32633264

@@ -3266,8 +3267,8 @@ export class ExactReviewQueue {
32663267
return json(
32673268
await this.githubWebhookReadModelStore.readItem(await request.json().catch(() => null)),
32683269
);
3269-
} catch (error) {
3270-
return json({ error: sanitizedServerError(error) }, 400);
3270+
} catch {
3271+
return json({ error: "invalid_github_webhook_read_model_item_request" }, 400);
32713272
}
32723273
}
32733274

@@ -3278,8 +3279,8 @@ export class ExactReviewQueue {
32783279
await request.json().catch(() => null),
32793280
),
32803281
);
3281-
} catch (error) {
3282-
return json({ error: sanitizedServerError(error) }, 400);
3282+
} catch {
3283+
return json({ error: "invalid_github_webhook_read_model_comments_request" }, 400);
32833284
}
32843285
}
32853286

@@ -3290,8 +3291,8 @@ export class ExactReviewQueue {
32903291
await request.json().catch(() => null),
32913292
),
32923293
);
3293-
} catch (error) {
3294-
return json({ error: sanitizedServerError(error) }, 400);
3294+
} catch {
3295+
return json({ error: "invalid_github_webhook_read_model_activity_request" }, 400);
32953296
}
32963297
}
32973298

@@ -3302,8 +3303,8 @@ export class ExactReviewQueue {
33023303
await request.json().catch(() => null),
33033304
),
33043305
);
3305-
} catch (error) {
3306-
return json({ error: sanitizedServerError(error) }, 400);
3306+
} catch {
3307+
return json({ error: "invalid_github_webhook_read_model_workflows_request" }, 400);
33073308
}
33083309
}
33093310

@@ -3314,8 +3315,8 @@ export class ExactReviewQueue {
33143315
await request.json().catch(() => null),
33153316
),
33163317
);
3317-
} catch (error) {
3318-
return json({ error: sanitizedServerError(error) }, 400);
3318+
} catch {
3319+
return json({ error: "invalid_github_webhook_read_model_placeholders_request" }, 400);
33193320
}
33203321
}
33213322

‎docs/proof/direct-publication-reject-detail/README.md‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ The behavior contract is:
1111
`error: "invalid_direct_publication_plan"`, `fallback_required: true`, and a non-empty `detail`
1212
naming the invalid revision;
1313
- a structurally different plan whose operation targets the wrong item returns the same unchanged
14-
error classification with a non-empty path-specific `detail`;
15-
- the two validation failures produce different detail values.
14+
error classification with a bounded `detail` that names the violated tuple invariant without
15+
echoing the submitted path;
16+
- the two validation failures produce different bounded detail values.
1617

1718
The script boots the Worker, drives `/api/exact-review-queue`, terminates the full Wrangler process
1819
tree, and inspects Wrangler's persisted SQLite database for the direct-publication table. Only that
@@ -32,5 +33,5 @@ transcript, build/install logs, and a redacted Wrangler log.
3233

3334
This proof does not change or test retry/permanence policy, does not identify or fix the underlying
3435
CodexBar rejection, and does not deploy or mutate production. OpenClaw Bay is unaffected: the
35-
change enriches an internal publication rejection and its downstream diagnostic fingerprint, with
36-
no Bay observer data or control surface change.
36+
change keeps internal publication rejection fingerprints distinct without exposing submitted
37+
values, with no Bay observer data or control surface change.

‎docs/proof/direct-publication-reject-detail/run-proof.sh‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,13 @@ REVISION_STATUS="$revision_status" PATH_STATUS="$path_status" node -e '
197197
assert.ok(body.detail.length > 0);
198198
}
199199
assert.match(revision.detail, /invalid direct publication revision/);
200-
assert.match(outsidePath.detail, /direct publication path is outside steipete-CodexBar#2797/);
200+
assert.equal(outsidePath.detail, "direct publication path is outside its target tuple");
201201
assert.notEqual(revision.detail, outsidePath.detail);
202202
const lines = [
203203
"Durable Object initialized: exact_review_direct_publication_plans table present",
204204
"invalid revision: HTTP " + process.env.REVISION_STATUS + "; error=" + revision.error + "; fallback_required=" + revision.fallback_required + "; detail=" + revision.detail,
205205
"outside path: HTTP " + process.env.PATH_STATUS + "; error=" + outsidePath.error + "; fallback_required=" + outsidePath.fallback_required + "; detail=" + outsidePath.detail,
206-
"distinct validation details: true",
206+
"distinct bounded validation details: true",
207207
];
208208
fs.writeFileSync(process.argv[3], lines.join("\n") + "\n");
209209
' \

‎docs/proof/mixed-case-publication-slugs/README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ The behavior contract is:
1111
`records/steipete-CodexBar/...` path returns HTTP 202 with an accepted or deduped receipt;
1212
- the real Worker export surface serves that record only from `steipete-codexbar`, and the
1313
persisted Durable Object SQLite contains no `steipete-CodexBar` canonical or export row;
14-
- a signed plan whose operation names `steipete-other` returns the detailed HTTP 400
15-
`invalid_direct_publication_plan` response;
14+
- a signed plan whose operation names `steipete-other` returns the HTTP 400
15+
`invalid_direct_publication_plan` response with a bounded tuple-invariant detail;
1616
- a signed all-lowercase `openclaw/openclaw` plan still returns HTTP 202 with an accepted or
1717
deduped receipt.
1818

‎docs/proof/mixed-case-publication-slugs/run-proof.sh‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,7 @@ MIXED_STATUS="$mixed_status" DIFFERENT_STATUS="$different_status" LOWERCASE_STAT
245245
assert.deepEqual(uppercaseExport.records, []);
246246
assert.equal(different.error, "invalid_direct_publication_plan");
247247
assert.equal(different.fallback_required, true);
248-
assert.match(
249-
different.detail,
250-
/direct publication path is outside steipete-CodexBar#2517: records\/steipete-other\/items\/2517\.md/,
251-
);
248+
assert.equal(different.detail, "direct publication path is outside its target tuple");
252249
const lines = [
253250
"Durable Object initialized: exact_review_direct_publication_plans table present",
254251
"mixed-case repository with uppercase path: HTTP " + process.env.MIXED_STATUS + "; accepted=" + mixed.accepted + "; deduped=" + mixed.deduped + "; canonical_target_key=" + mixed.canonical_target_key,

‎test/dashboard-worker-publication-lifecycle.test.ts‎

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,37 @@ test("direct publication endpoint authenticates, dedupes, and returns a structur
181181
fallback_required: boolean;
182182
detail: string;
183183
};
184-
assert.equal(invalidPlanResponse.error, "invalid_direct_publication_plan");
185-
assert.equal(invalidPlanResponse.fallback_required, true);
186-
assert.match(invalidPlanResponse.detail, /^invalid bounded state mutation path: /);
187-
assert.match(invalidPlanResponse.detail, /\[REDACTED\]/);
188-
assert.doesNotMatch(invalidPlanResponse.detail, /alice|hunter2|ghp_[A-Za-z0-9_]+/);
184+
assert.deepEqual(invalidPlanResponse, {
185+
error: "invalid_direct_publication_plan",
186+
fallback_required: true,
187+
detail: "invalid bounded state mutation path",
188+
});
189+
const dualPrimaryBody = JSON.stringify({
190+
...payload,
191+
totalBytes: 2,
192+
operations: [
193+
payload.operations[0],
194+
{
195+
...payload.operations[0],
196+
path: "records/openclaw-openclaw/closed/701.md",
197+
},
198+
],
199+
});
200+
const dualPrimarySignature = `sha256=${createHmac("sha256", "test-secret").update(dualPrimaryBody).digest("hex")}`;
201+
const dualPrimary = await worker.fetch(
202+
new Request(url, {
203+
method: "POST",
204+
headers: { "x-clawsweeper-exact-review-signature": dualPrimarySignature },
205+
body: dualPrimaryBody,
206+
}),
207+
env,
208+
);
209+
assert.equal(dualPrimary.status, 400);
210+
assert.deepEqual(await dualPrimary.json(), {
211+
error: "invalid_direct_publication_plan",
212+
fallback_required: true,
213+
detail: "direct publication tuple writes both primary sections",
214+
});
189215
for (const expected of [
190216
{ accepted: true, deduped: false },
191217
{ accepted: false, deduped: true },

‎test/github-webhook-read-model.test.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,30 @@ test("signed webhook loopback covers lifecycle, comments, reviews, checks, runs,
314314
assert.equal(afterDuplicate.watermark, workflows.watermark);
315315
});
316316

317+
test("read-model failures expose only endpoint-owned error codes", async () => {
318+
const queue = new ExactReviewQueue({ storage: new MemoryDurableStorage() }, {});
319+
const cases = [
320+
["ingest", "invalid_github_webhook_read_model_delivery"],
321+
["repair", "invalid_github_webhook_read_model_repair"],
322+
["item", "invalid_github_webhook_read_model_item_request"],
323+
["comments", "invalid_github_webhook_read_model_comments_request"],
324+
["activity", "invalid_github_webhook_read_model_activity_request"],
325+
["workflows", "invalid_github_webhook_read_model_workflows_request"],
326+
["placeholders", "invalid_github_webhook_read_model_placeholders_request"],
327+
] as const;
328+
329+
for (const [operation, error] of cases) {
330+
const response = await queue.fetch(
331+
new Request(`https://queue/github-read-model/${operation}`, {
332+
method: "POST",
333+
body: JSON.stringify({ invalid: "private-path-marker" }),
334+
}),
335+
);
336+
assert.equal(response.status, 400);
337+
assert.deepEqual(await response.json(), { error });
338+
}
339+
});
340+
317341
test("dashboard workflow snapshot preserves health decisions while removing run and job polls", async () => {
318342
const storage = new MemoryDurableStorage();
319343
const store = new GithubWebhookReadModelStore(storage);

0 commit comments

Comments
 (0)