Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(okx): stop spreading a third-party error onto a public probe response

nirholas5840605fe364
diff --git a/api/okx/3d/[service].js b/api/okx/3d/[service].js
index e2359278f..8af9cbaf2 100644
--- a/api/okx/3d/[service].js
+++ b/api/okx/3d/[service].js
@@ -78,14 +78,23 @@ function serviceFrom(req) {
return m ? m[1] : '';
}
+// A failing probe reports structured detail by attaching it to its error as
+// `detail`, the only property read here. Spreading the error object itself (what
+// this used to do) copies a third-party error's own enumerable fields onto the
+// response: an AWS SDK S3 error carries `name`, which silently replaced the
+// subsystem's name with `SignatureDoesNotMatch`, and it carries the request's
+// signing material (StringToSign, CanonicalRequest, SignatureProvided) plus the
+// bucket host, all served from an endpoint that is public, unauthenticated and
+// listed on the OKX marketplace. The fixed keys are written after the spread so
+// no detail can overwrite the subsystem's identity or verdict either.
async function probe(name, fn) {
const started = Date.now();
try {
const detail = await fn();
- return { name, ok: true, latency_ms: Date.now() - started, ...(detail || {}) };
+ return { ...(detail || {}), name, ok: true, latency_ms: Date.now() - started };
} catch (err) {
- const { message, stack, ...detail } = err && typeof err === 'object' ? err : {};
- return { name, ok: false, latency_ms: Date.now() - started, error: String(err?.message || err), ...detail };
+ const detail = err && typeof err === 'object' && err.detail && typeof err.detail === 'object' ? err.detail : null;
+ return { ...(detail || {}), name, ok: false, latency_ms: Date.now() - started, error: String(err?.message || err) };
}
}
@@ -135,8 +144,8 @@ async function healthReport() {
// Three or more real submits in the hour is enough to judge. A median
// past 45 s means a ChatGPT-class client never sees the accept; more
// failures than successes means the lane is not taking jobs.
- if (samples >= 3 && p50 != null && p50 > 45_000) throw Object.assign(new Error(`median submit ${p50} ms over the last hour`), detail);
- if (samples >= 3 && errors * 2 > samples) throw Object.assign(new Error(`${errors} of ${samples} submits failed in the last hour`), detail);
+ if (samples >= 3 && p50 != null && p50 > 45_000) throw Object.assign(new Error(`median submit ${p50} ms over the last hour`), { detail });
+ if (samples >= 3 && errors * 2 > samples) throw Object.assign(new Error(`${errors} of ${samples} submits failed in the last hour`), { detail });
return detail;
}),
probe('render', async () => {
diff --git a/tests/api/okx-identity-studio.test.js b/tests/api/okx-identity-studio.test.js
index 211b9827b..e75d625f2 100644
--- a/tests/api/okx-identity-studio.test.js
+++ b/tests/api/okx-identity-studio.test.js
@@ -310,6 +310,44 @@ describe('free lanes over HTTP', () => {
expect(JSON.parse(res.body).ok).toBe(false);
});
+ // Live on 2026-09-09: GET /health answered with a subsystem literally named
+ // "SignatureDoesNotMatch" carrying the R2 request's StringToSign,
+ // CanonicalRequest and SignatureProvided. probe() spread the caught error, so
+ // an AWS SDK error's own `name` replaced the subsystem's and its signing
+ // material rode along, on a row that is public, unauthenticated, and listed on
+ // the OKX marketplace.
+ it('GET /health names the failing subsystem and leaks no signing material from a storage error', async () => {
+ mountHealthyProbes();
+ const r2 = await import('../../api/_lib/r2.js');
+ const awsError = () =>
+ Object.assign(new Error('The request signature we calculated does not match the signature you provided.'), {
+ name: 'SignatureDoesNotMatch',
+ Code: 'SignatureDoesNotMatch',
+ $fault: 'client',
+ $metadata: { httpStatusCode: 403 },
+ StringToSign: 'AWS4-HMAC-SHA256\n20260909T053242Z\n20260909/auto/s3/aws4_request',
+ CanonicalRequest: 'PUT\n/okx-identity/health-probe.txt\nhost:chatty-storage.example.r2.cloudflarestorage.com',
+ SignatureProvided: '85e96ef6b6e492eaee9ac0c5a53d6d3fd38769efbfb1e20ad417418f502e443d',
+ });
+ vi.mocked(r2.headObject).mockRejectedValueOnce(awsError()).mockRejectedValueOnce(awsError());
+ vi.mocked(r2.putObject).mockRejectedValueOnce(awsError());
+
+ const res = makeRes();
+ await handler(makeReq({ method: 'GET', service: 'health' }), res);
+
+ expect(res.statusCode).toBe(503);
+ const body = JSON.parse(res.body);
+ const storage = body.subsystems.find((s) => s.name === 'storage');
+ expect(storage).toBeDefined();
+ expect(storage.ok).toBe(false);
+ // The reason stays readable; only the error object's guts are dropped.
+ expect(storage.error).toContain('signature');
+ expect(body.subsystems.map((s) => s.name)).not.toContain('SignatureDoesNotMatch');
+ for (const secret of ['StringToSign', 'CanonicalRequest', 'SignatureProvided', '$metadata', '85e96ef6']) {
+ expect(res.body).not.toContain(secret);
+ }
+ });
+
// The static generation probe read all-green on 2026-08-25 while every text
// submit hung for 95 s+. The submit-latency probe judges the last hour of
// REAL forge_3d calls instead, so a stalled lane shows up here.