@teamclaws/teamclaw 2026.11.9 → 2026.11.10
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/dist/src/controller/http-server.js +5 -1
- package/dist/src/controller/repo-routes.js +14 -2
- package/dist/src/controller/security.js +29 -0
- package/dist/src/protocol.js +43 -4
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/src/controller/http-server.ts +5 -1
- package/src/controller/repo-routes.ts +13 -2
- package/src/controller/security.ts +31 -0
- package/src/protocol.ts +40 -4
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
// controller-tools.ts, kickoff-orchestrator.ts, prompt-injector.ts.
|
|
45
45
|
// ===========================================================================
|
|
46
46
|
import http from "node:http";
|
|
47
|
-
import { sendJson, sendError } from "../protocol.js";
|
|
47
|
+
import { sendJson, sendError, BodyTooLargeError } from "../protocol.js";
|
|
48
48
|
import { getActiveProfile } from "../profile-loader.js";
|
|
49
49
|
import { autoAssignPendingTasks } from "./task-assignment.js";
|
|
50
50
|
import { createTunnelManager, gatePageHtml } from "./tunnel-manager.js";
|
|
@@ -212,6 +212,10 @@ export function createControllerHttpServer(deps) {
|
|
|
212
212
|
}
|
|
213
213
|
catch (err) {
|
|
214
214
|
logger.error(`Controller HTTP error: ${err instanceof Error ? err.message : String(err)}`);
|
|
215
|
+
if (err instanceof BodyTooLargeError) {
|
|
216
|
+
sendError(res, 413, err.message);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
215
219
|
sendError(res, 500, "Internal server error");
|
|
216
220
|
}
|
|
217
221
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sendJson, sendError, pinnedCorsAllowOrigin, readRequestBody } from "../protocol.js";
|
|
1
|
+
import { sendJson, sendError, pinnedCorsAllowOrigin, readRequestBody, MAX_BUNDLE_BODY_BYTES, BodyTooLargeError } from "../protocol.js";
|
|
2
2
|
import { getActiveProfile, validateActiveRoleId } from "../profile-loader.js";
|
|
3
3
|
import { ensureControllerGitRepo, exportControllerGitBundle, importControllerGitBundle } from "../git-collaboration.js";
|
|
4
4
|
import { recordTaskExecutionEvent } from "./task-execution.js";
|
|
@@ -73,7 +73,19 @@ export async function handleRepoBundleRequest(deps, res) {
|
|
|
73
73
|
export async function repoImportRoute(ctx) {
|
|
74
74
|
const { req, res, requestUrl, deps } = ctx;
|
|
75
75
|
const { config, logger, updateTeamState } = deps;
|
|
76
|
-
|
|
76
|
+
let body;
|
|
77
|
+
try {
|
|
78
|
+
// Repo bundles are binary git bundles - bounded by the bundle limit, not
|
|
79
|
+
// the JSON limit (2026.11.9 review: request bodies are capped everywhere).
|
|
80
|
+
body = await readRequestBody(req, MAX_BUNDLE_BODY_BYTES);
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
if (err instanceof BodyTooLargeError) {
|
|
84
|
+
sendError(res, 413, `bundle body exceeds the ${err.limitBytes}-byte limit`);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
throw err;
|
|
88
|
+
}
|
|
77
89
|
if (!body.length) {
|
|
78
90
|
sendError(res, 400, "bundle body is required");
|
|
79
91
|
return;
|
|
@@ -350,6 +350,7 @@ export function applyResponseCorsPolicy(req, res, protectionOn) {
|
|
|
350
350
|
res.setHeader("Access-Control-Allow-Origin", origin);
|
|
351
351
|
res.setHeader("Vary", "Origin");
|
|
352
352
|
}
|
|
353
|
+
const MUTATING_HTTP_METHODS = new Set(["POST", "PUT", "PATCH", "DELETE"]);
|
|
353
354
|
/**
|
|
354
355
|
* True when the request path must NOT be blocked by the device gate:
|
|
355
356
|
* health (liveness probes), UI static assets and the tunnel gate pages
|
|
@@ -425,6 +426,22 @@ export function createSecurityMiddleware(deps) {
|
|
|
425
426
|
const state = deps.getTeamState();
|
|
426
427
|
const protectionOn = isProtectionOn(state);
|
|
427
428
|
applyResponseCorsPolicy(req, res, protectionOn);
|
|
429
|
+
// ClawHub security review 2026.11.9 (finding 3): a cross-site page in the
|
|
430
|
+
// OWNER's own browser reaches this controller as a loopback peer, so the
|
|
431
|
+
// loopback-only reset hatch would honour it (JSON POST + wildcard CORS in
|
|
432
|
+
// L0). Chromium / Firefox / Safari 16.4+ label such requests
|
|
433
|
+
// Sec-Fetch-Site: cross-site; refuse every mutating method carrying that
|
|
434
|
+
// label regardless of protection level. Non-browser clients omit the
|
|
435
|
+
// header and are unaffected; same-origin UI traffic is same-origin.
|
|
436
|
+
const method = (req.method ?? "GET").toUpperCase();
|
|
437
|
+
if (MUTATING_HTTP_METHODS.has(method) && req.headers["sec-fetch-site"] === "cross-site") {
|
|
438
|
+
deps.logger.warn(`Controller: rejected cross-site ${method} ${pathname} from ${peer.ip} (Sec-Fetch-Site: cross-site)`);
|
|
439
|
+
sendJson(res, 403, {
|
|
440
|
+
error: "forbidden",
|
|
441
|
+
hint: "Cross-site requests cannot change controller state; load the controller UI from its own origin.",
|
|
442
|
+
});
|
|
443
|
+
return false;
|
|
444
|
+
}
|
|
428
445
|
if (!protectionOn) {
|
|
429
446
|
recordNonLanPeerSignal(deps, state, peer, pathname);
|
|
430
447
|
return true;
|
|
@@ -797,6 +814,18 @@ export async function handleSecurityDeviceDeleteRequest(ctx) {
|
|
|
797
814
|
return;
|
|
798
815
|
}
|
|
799
816
|
const caller = authenticateDeviceToken(state, extractDeviceToken(req));
|
|
817
|
+
// ClawHub security review 2026.11.9 (finding 2): deleting the LAST paired
|
|
818
|
+
// device drops protection to L0 for everyone - exactly what /security/reset
|
|
819
|
+
// does - so it is a controller-host action too. Remote devices may revoke
|
|
820
|
+
// other devices, but the final one must be removed (or reset) from the host.
|
|
821
|
+
const isLastDevice = devices.length === 1;
|
|
822
|
+
if (isLastDevice && !(ctx.peer?.loopback ?? false)) {
|
|
823
|
+
sendJson(res, 403, {
|
|
824
|
+
error: "forbidden",
|
|
825
|
+
hint: "This is the last paired device; removing it would disable protection for everyone. Run the removal or POST /api/v1/security/reset from the controller host.",
|
|
826
|
+
});
|
|
827
|
+
return;
|
|
828
|
+
}
|
|
800
829
|
deps.updateTeamState((s) => {
|
|
801
830
|
if (!s.security) {
|
|
802
831
|
return;
|
package/dist/src/protocol.js
CHANGED
|
@@ -58,7 +58,7 @@ export function secretsEqual(a, b) {
|
|
|
58
58
|
return left.length === right.length && timingSafeEqual(left, right);
|
|
59
59
|
}
|
|
60
60
|
async function parseJsonBody(req) {
|
|
61
|
-
const raw = await readRequestBody(req);
|
|
61
|
+
const raw = await readRequestBody(req, MAX_JSON_BODY_BYTES);
|
|
62
62
|
if (!raw.length) {
|
|
63
63
|
return {};
|
|
64
64
|
}
|
|
@@ -69,14 +69,53 @@ async function parseJsonBody(req) {
|
|
|
69
69
|
throw new Error(`Invalid JSON body: ${err instanceof Error ? err.message : String(err)}`);
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
|
|
72
|
+
/** JSON request bodies never legitimately exceed a few MiB (task text, config). */
|
|
73
|
+
export const MAX_JSON_BODY_BYTES = 8 * 1024 * 1024;
|
|
74
|
+
/** Repo bundle imports are binary git bundles - large, but still bounded. */
|
|
75
|
+
export const MAX_BUNDLE_BODY_BYTES = 256 * 1024 * 1024;
|
|
76
|
+
export class BodyTooLargeError extends Error {
|
|
77
|
+
limitBytes;
|
|
78
|
+
constructor(limitBytes) {
|
|
79
|
+
super(`request body exceeds the ${limitBytes}-byte limit`);
|
|
80
|
+
this.limitBytes = limitBytes;
|
|
81
|
+
this.name = "BodyTooLargeError";
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* ClawHub security review 2026.11.9 (finding 4): the reader used to buffer
|
|
86
|
+
* whatever the peer sent before any route looked at it, so an unauthenticated
|
|
87
|
+
* caller could exhaust gateway memory with a single oversized request. The
|
|
88
|
+
* stream is aborted as soon as the limit is crossed.
|
|
89
|
+
*/
|
|
90
|
+
async function readRequestBody(req, maxBytes = MAX_JSON_BODY_BYTES) {
|
|
73
91
|
return new Promise((resolve, reject) => {
|
|
74
92
|
const chunks = [];
|
|
75
|
-
|
|
93
|
+
let total = 0;
|
|
94
|
+
let settled = false;
|
|
95
|
+
req.on("data", (chunk) => {
|
|
96
|
+
if (settled)
|
|
97
|
+
return;
|
|
98
|
+
total += chunk.length;
|
|
99
|
+
if (total > maxBytes) {
|
|
100
|
+
settled = true;
|
|
101
|
+
req.destroy();
|
|
102
|
+
reject(new BodyTooLargeError(maxBytes));
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
chunks.push(chunk);
|
|
106
|
+
});
|
|
76
107
|
req.on("end", () => {
|
|
108
|
+
if (settled)
|
|
109
|
+
return;
|
|
110
|
+
settled = true;
|
|
77
111
|
resolve(Buffer.concat(chunks));
|
|
78
112
|
});
|
|
79
|
-
req.on("error",
|
|
113
|
+
req.on("error", (err) => {
|
|
114
|
+
if (settled)
|
|
115
|
+
return;
|
|
116
|
+
settled = true;
|
|
117
|
+
reject(err);
|
|
118
|
+
});
|
|
80
119
|
});
|
|
81
120
|
}
|
|
82
121
|
/**
|
package/openclaw.plugin.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "teamclaw",
|
|
3
3
|
"name": "TeamClaw",
|
|
4
4
|
"description": "Virtual team collaboration - multiple OpenClaw instances form a virtual software company with role-based task routing.",
|
|
5
|
-
"version": "2026.11.
|
|
5
|
+
"version": "2026.11.10",
|
|
6
6
|
"activation": {
|
|
7
7
|
"onStartup": true
|
|
8
8
|
},
|
package/package.json
CHANGED
|
@@ -47,7 +47,7 @@ import http from "node:http";
|
|
|
47
47
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
48
48
|
import type { OpenClawPluginApi, PluginLogger } from "../../api.js";
|
|
49
49
|
import type { PluginConfig, TeamState } from "../types.js";
|
|
50
|
-
import { sendJson, sendError } from "../protocol.js";
|
|
50
|
+
import { sendJson, sendError, BodyTooLargeError } from "../protocol.js";
|
|
51
51
|
import { getActiveProfile, type TeamProfileCapabilities } from "../profile-loader.js";
|
|
52
52
|
import { TaskRouter } from "./task-router.js";
|
|
53
53
|
import { MessageRouter } from "./message-router.js";
|
|
@@ -287,6 +287,10 @@ export function createControllerHttpServer(deps: ControllerHttpDeps): http.Serve
|
|
|
287
287
|
await handleRequest(req, res, pathname, deps, peer);
|
|
288
288
|
} catch (err) {
|
|
289
289
|
logger.error(`Controller HTTP error: ${err instanceof Error ? err.message : String(err)}`);
|
|
290
|
+
if (err instanceof BodyTooLargeError) {
|
|
291
|
+
sendError(res, 413, err.message);
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
290
294
|
sendError(res, 500, "Internal server error");
|
|
291
295
|
}
|
|
292
296
|
});
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import type { ServerResponse } from "node:http";
|
|
12
12
|
import type { PluginLogger } from "../../api.js";
|
|
13
13
|
import type { GitRepoState, PluginConfig, TeamState } from "../types.js";
|
|
14
|
-
import { sendJson, sendError, pinnedCorsAllowOrigin, readRequestBody } from "../protocol.js";
|
|
14
|
+
import { sendJson, sendError, pinnedCorsAllowOrigin, readRequestBody, MAX_BUNDLE_BODY_BYTES, BodyTooLargeError } from "../protocol.js";
|
|
15
15
|
import { getActiveProfile, validateActiveRoleId } from "../profile-loader.js";
|
|
16
16
|
import { ensureControllerGitRepo, exportControllerGitBundle, importControllerGitBundle } from "../git-collaboration.js";
|
|
17
17
|
import { recordTaskExecutionEvent } from "./task-execution.js";
|
|
@@ -104,7 +104,18 @@ export async function handleRepoBundleRequest(deps: RepoRouteDeps, res: ServerRe
|
|
|
104
104
|
export async function repoImportRoute(ctx: RouteContext): Promise<void> {
|
|
105
105
|
const { req, res, requestUrl, deps } = ctx;
|
|
106
106
|
const { config, logger, updateTeamState } = deps;
|
|
107
|
-
|
|
107
|
+
let body: Buffer;
|
|
108
|
+
try {
|
|
109
|
+
// Repo bundles are binary git bundles - bounded by the bundle limit, not
|
|
110
|
+
// the JSON limit (2026.11.9 review: request bodies are capped everywhere).
|
|
111
|
+
body = await readRequestBody(req, MAX_BUNDLE_BODY_BYTES);
|
|
112
|
+
} catch (err) {
|
|
113
|
+
if (err instanceof BodyTooLargeError) {
|
|
114
|
+
sendError(res, 413, `bundle body exceeds the ${err.limitBytes}-byte limit`);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
throw err;
|
|
118
|
+
}
|
|
108
119
|
if (!body.length) {
|
|
109
120
|
sendError(res, 400, "bundle body is required");
|
|
110
121
|
return;
|
|
@@ -410,6 +410,8 @@ export type SecurityMiddlewareDeps = {
|
|
|
410
410
|
|
|
411
411
|
export type SecurityMiddleware = (req: IncomingMessage, res: ServerResponse, pathname: string, peer: SecurityPeer) => boolean;
|
|
412
412
|
|
|
413
|
+
const MUTATING_HTTP_METHODS: ReadonlySet<string> = new Set(["POST", "PUT", "PATCH", "DELETE"]);
|
|
414
|
+
|
|
413
415
|
/**
|
|
414
416
|
* True when the request path must NOT be blocked by the device gate:
|
|
415
417
|
* health (liveness probes), UI static assets and the tunnel gate pages
|
|
@@ -496,6 +498,23 @@ export function createSecurityMiddleware(deps: SecurityMiddlewareDeps): Security
|
|
|
496
498
|
|
|
497
499
|
applyResponseCorsPolicy(req, res, protectionOn);
|
|
498
500
|
|
|
501
|
+
// ClawHub security review 2026.11.9 (finding 3): a cross-site page in the
|
|
502
|
+
// OWNER's own browser reaches this controller as a loopback peer, so the
|
|
503
|
+
// loopback-only reset hatch would honour it (JSON POST + wildcard CORS in
|
|
504
|
+
// L0). Chromium / Firefox / Safari 16.4+ label such requests
|
|
505
|
+
// Sec-Fetch-Site: cross-site; refuse every mutating method carrying that
|
|
506
|
+
// label regardless of protection level. Non-browser clients omit the
|
|
507
|
+
// header and are unaffected; same-origin UI traffic is same-origin.
|
|
508
|
+
const method = (req.method ?? "GET").toUpperCase();
|
|
509
|
+
if (MUTATING_HTTP_METHODS.has(method) && req.headers["sec-fetch-site"] === "cross-site") {
|
|
510
|
+
deps.logger.warn(`Controller: rejected cross-site ${method} ${pathname} from ${peer.ip} (Sec-Fetch-Site: cross-site)`);
|
|
511
|
+
sendJson(res, 403, {
|
|
512
|
+
error: "forbidden",
|
|
513
|
+
hint: "Cross-site requests cannot change controller state; load the controller UI from its own origin.",
|
|
514
|
+
});
|
|
515
|
+
return false;
|
|
516
|
+
}
|
|
517
|
+
|
|
499
518
|
if (!protectionOn) {
|
|
500
519
|
recordNonLanPeerSignal(deps, state, peer, pathname);
|
|
501
520
|
return true;
|
|
@@ -912,6 +931,18 @@ export async function handleSecurityDeviceDeleteRequest(ctx: RouteContext): Prom
|
|
|
912
931
|
return;
|
|
913
932
|
}
|
|
914
933
|
const caller = authenticateDeviceToken(state, extractDeviceToken(req));
|
|
934
|
+
// ClawHub security review 2026.11.9 (finding 2): deleting the LAST paired
|
|
935
|
+
// device drops protection to L0 for everyone - exactly what /security/reset
|
|
936
|
+
// does - so it is a controller-host action too. Remote devices may revoke
|
|
937
|
+
// other devices, but the final one must be removed (or reset) from the host.
|
|
938
|
+
const isLastDevice = devices.length === 1;
|
|
939
|
+
if (isLastDevice && !(ctx.peer?.loopback ?? false)) {
|
|
940
|
+
sendJson(res, 403, {
|
|
941
|
+
error: "forbidden",
|
|
942
|
+
hint: "This is the last paired device; removing it would disable protection for everyone. Run the removal or POST /api/v1/security/reset from the controller host.",
|
|
943
|
+
});
|
|
944
|
+
return;
|
|
945
|
+
}
|
|
915
946
|
deps.updateTeamState((s) => {
|
|
916
947
|
if (!s.security) {
|
|
917
948
|
return;
|
package/src/protocol.ts
CHANGED
|
@@ -67,7 +67,7 @@ export function secretsEqual(a: string, b: string): boolean {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
async function parseJsonBody(req: IncomingMessage): Promise<Record<string, unknown>> {
|
|
70
|
-
const raw = await readRequestBody(req);
|
|
70
|
+
const raw = await readRequestBody(req, MAX_JSON_BODY_BYTES);
|
|
71
71
|
if (!raw.length) {
|
|
72
72
|
return {};
|
|
73
73
|
}
|
|
@@ -79,14 +79,50 @@ async function parseJsonBody(req: IncomingMessage): Promise<Record<string, unkno
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
/** JSON request bodies never legitimately exceed a few MiB (task text, config). */
|
|
83
|
+
export const MAX_JSON_BODY_BYTES = 8 * 1024 * 1024;
|
|
84
|
+
/** Repo bundle imports are binary git bundles - large, but still bounded. */
|
|
85
|
+
export const MAX_BUNDLE_BODY_BYTES = 256 * 1024 * 1024;
|
|
86
|
+
|
|
87
|
+
export class BodyTooLargeError extends Error {
|
|
88
|
+
constructor(readonly limitBytes: number) {
|
|
89
|
+
super(`request body exceeds the ${limitBytes}-byte limit`);
|
|
90
|
+
this.name = "BodyTooLargeError";
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* ClawHub security review 2026.11.9 (finding 4): the reader used to buffer
|
|
96
|
+
* whatever the peer sent before any route looked at it, so an unauthenticated
|
|
97
|
+
* caller could exhaust gateway memory with a single oversized request. The
|
|
98
|
+
* stream is aborted as soon as the limit is crossed.
|
|
99
|
+
*/
|
|
100
|
+
async function readRequestBody(req: IncomingMessage, maxBytes: number = MAX_JSON_BODY_BYTES): Promise<Buffer> {
|
|
83
101
|
return new Promise((resolve, reject) => {
|
|
84
102
|
const chunks: Buffer[] = [];
|
|
85
|
-
|
|
103
|
+
let total = 0;
|
|
104
|
+
let settled = false;
|
|
105
|
+
req.on("data", (chunk: Buffer) => {
|
|
106
|
+
if (settled) return;
|
|
107
|
+
total += chunk.length;
|
|
108
|
+
if (total > maxBytes) {
|
|
109
|
+
settled = true;
|
|
110
|
+
req.destroy();
|
|
111
|
+
reject(new BodyTooLargeError(maxBytes));
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
chunks.push(chunk);
|
|
115
|
+
});
|
|
86
116
|
req.on("end", () => {
|
|
117
|
+
if (settled) return;
|
|
118
|
+
settled = true;
|
|
87
119
|
resolve(Buffer.concat(chunks));
|
|
88
120
|
});
|
|
89
|
-
req.on("error",
|
|
121
|
+
req.on("error", (err) => {
|
|
122
|
+
if (settled) return;
|
|
123
|
+
settled = true;
|
|
124
|
+
reject(err);
|
|
125
|
+
});
|
|
90
126
|
});
|
|
91
127
|
}
|
|
92
128
|
|