@teamclaws/teamclaw 2026.11.10 → 2026.11.12

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.
@@ -147,10 +147,10 @@ async function taskCheckpointRoute(ctx) {
147
147
  await handleTaskCheckpointRequest(ctx.deps, ctx.req, ctx.res, ctx.pathname);
148
148
  }
149
149
  async function taskResultContractRoute(ctx) {
150
- await handleTaskResultContractRequest(ctx.deps, ctx.req, ctx.res, ctx.pathname);
150
+ await handleTaskResultContractRequest(ctx.deps, ctx.req, ctx.res, ctx.pathname, ctx.peer);
151
151
  }
152
152
  async function taskResultRoute(ctx) {
153
- await handleTaskResultRequest(ctx.deps, ctx.req, ctx.res, ctx.pathname);
153
+ await handleTaskResultRequest(ctx.deps, ctx.req, ctx.res, ctx.pathname, ctx.peer);
154
154
  }
155
155
  async function taskExecutionEventRoute(ctx) {
156
156
  await handleTaskExecutionEventRequest(ctx.deps, ctx.req, ctx.res, ctx.pathname);
@@ -1,4 +1,5 @@
1
1
  import { generateId, parseJsonBody, sendError, sendJson } from "../protocol.js";
2
+ import { isProtectionOn } from "./security.js";
2
3
  import { normalizeRecommendedSkills, validateActiveRoleId } from "../profile-loader.js";
3
4
  import { deriveProjectSlug, deriveStableProjectKey } from "../openclaw-workspace.js";
4
5
  import { backfillWorkerProgressContract, enrichDeliverablesWithPreviewInference, normalizeTaskHandoffContract, normalizeWorkerProgressContract, normalizeWorkerTaskResultContract, } from "../interaction-contracts.js";
@@ -433,11 +434,42 @@ export async function handleTaskCheckpointRequest(deps, req, res, pathname) {
433
434
  }
434
435
  sendJson(res, 200, { ok: true, updatedAt: task.checkpoint?.updatedAt });
435
436
  }
437
+ /**
438
+ * ClawHub security review 2026.11.11: a submitted previewCommand is run by
439
+ * the controller as a shell process (restricted env, confined cwd - but still
440
+ * arbitrary code as the controller user). While device protection is off,
441
+ * only loopback / LAN peers (the owner's own workers) may supply one; a
442
+ * remote unpaired caller's contract is recorded WITHOUT preview fields so it
443
+ * can never trigger a process. Protection on: the device gate authenticated
444
+ * the caller, so nothing is stripped.
445
+ */
446
+ export function stripPreviewCommandsForUntrustedPeer(body, peer, protectionOn) {
447
+ if (protectionOn || !peer || peer.loopback || peer.lan) {
448
+ return;
449
+ }
450
+ for (const key of ["contract", "resultContract"]) {
451
+ const raw = body[key];
452
+ if (!raw || typeof raw !== "object") {
453
+ continue;
454
+ }
455
+ const deliverables = raw.deliverables;
456
+ if (!Array.isArray(deliverables)) {
457
+ continue;
458
+ }
459
+ for (const deliverable of deliverables) {
460
+ if (deliverable && typeof deliverable === "object") {
461
+ delete deliverable.previewCommand;
462
+ delete deliverable.previewCwd;
463
+ }
464
+ }
465
+ }
466
+ }
436
467
  // POST /api/v1/tasks/:id/result-contract
437
- export async function handleTaskResultContractRequest(deps, req, res, pathname) {
468
+ export async function handleTaskResultContractRequest(deps, req, res, pathname, peer) {
438
469
  const { logger, getTeamState, updateTeamState } = deps;
439
470
  const taskId = pathname.split("/")[4];
440
471
  const body = await parseJsonBody(req);
472
+ stripPreviewCommandsForUntrustedPeer(body, peer, isProtectionOn(getTeamState()));
441
473
  const contract = normalizeWorkerTaskResultContract(body.contract ?? body.resultContract);
442
474
  const workerId = typeof body.workerId === "string" ? body.workerId : undefined;
443
475
  const currentTask = getTeamState()?.tasks[taskId];
@@ -485,10 +517,11 @@ export async function handleTaskResultContractRequest(deps, req, res, pathname)
485
517
  sendJson(res, 201, { task: serializeTask(state.tasks[taskId]) });
486
518
  }
487
519
  // POST /api/v1/tasks/:id/result
488
- export async function handleTaskResultRequest(deps, req, res, pathname) {
520
+ export async function handleTaskResultRequest(deps, req, res, pathname, peer) {
489
521
  const { logger, getTeamState, updateTeamState } = deps;
490
522
  const taskId = pathname.split("/")[4];
491
523
  const body = await parseJsonBody(req);
524
+ stripPreviewCommandsForUntrustedPeer(body, peer, isProtectionOn(getTeamState()));
492
525
  let result = typeof body.result === "string" ? body.result : "";
493
526
  let error = typeof body.error === "string" ? body.error : undefined;
494
527
  const workerId = typeof body.workerId === "string" ? body.workerId : undefined;
@@ -13,9 +13,23 @@ export function teamAutoProjectDir(repoId) {
13
13
  * Git operations for TeamAuto. Authentication uses the device-flow token
14
14
  * inline in the remote URL (x-access-token basic auth) - proven to survive
15
15
  * GitHub's smart-HTTP redirects where extraheader injection does not. The
16
- * token never touches disk: remotes are rewritten per invocation and the
17
- * on-disk remote stays a clean https URL.
16
+ * token never touches disk: fetch/push rewrite the URL per invocation, and
17
+ * the one command that DOES store a URL (the initial clone) has its origin
18
+ * remote rewritten to the clean https URL right afterwards (ClawHub security
19
+ * review 2026.11.10). Every git error is redacted before it can reach a log,
20
+ * the store or a status response.
18
21
  */
22
+ /**
23
+ * Strip GitHub credentials from anything derived from git output: inline
24
+ * x-access-token userinfo and raw token shapes (gho_/ghp_..., github_pat_...).
25
+ * Exported for tests; applied by run() to every failure message.
26
+ */
27
+ export function redactGitSecrets(text) {
28
+ return text
29
+ // Drop the whole userinfo so no "user:secret@" shape survives.
30
+ .replace(/x-access-token:[^@\s/]+@/gi, "[REDACTED]@")
31
+ .replace(/\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,})\b/g, "[REDACTED]");
32
+ }
19
33
  function gitEnv() {
20
34
  return {
21
35
  ...process.env,
@@ -25,13 +39,28 @@ function gitEnv() {
25
39
  };
26
40
  }
27
41
  async function run(args, cwd) {
28
- const { stdout } = await exec("git", args, {
29
- cwd,
30
- env: gitEnv(),
31
- maxBuffer: 16 * 1024 * 1024,
32
- timeout: 120_000,
33
- });
34
- return stdout;
42
+ try {
43
+ const { stdout } = await exec("git", args, {
44
+ cwd,
45
+ env: gitEnv(),
46
+ maxBuffer: 16 * 1024 * 1024,
47
+ timeout: 120_000,
48
+ });
49
+ return stdout;
50
+ }
51
+ catch (err) {
52
+ // git echoes the failing URL on stderr (the inline token userinfo ends
53
+ // up in the message), and callers persist error messages into the store
54
+ // and status responses. Redact before the error leaves this module.
55
+ if (err instanceof Error) {
56
+ err.message = redactGitSecrets(err.message);
57
+ const withStderr = err;
58
+ if (typeof withStderr.stderr === "string") {
59
+ withStderr.stderr = redactGitSecrets(withStderr.stderr);
60
+ }
61
+ }
62
+ throw err;
63
+ }
35
64
  }
36
65
  export function createRepoSync(auth, logger) {
37
66
  async function tokenizedUrl(cloneUrl) {
@@ -39,6 +68,10 @@ export function createRepoSync(auth, logger) {
39
68
  const clean = cloneUrl.replace(/^https:\/\//, "").replace(/\.git$/, "");
40
69
  return `https://x-access-token:${token}@${clean}.git`;
41
70
  }
71
+ /** The token-less https URL that is safe to persist in .git/config. */
72
+ function cleanUrl(cloneUrl) {
73
+ return `https://${cloneUrl.replace(/^https:\/\//, "").replace(/\.git$/, "")}.git`;
74
+ }
42
75
  async function repoDir(repoId) {
43
76
  const { reposRoot, legacyReposRoot } = resolveTeamAutoPaths();
44
77
  await fs.mkdir(reposRoot, { recursive: true });
@@ -82,6 +115,9 @@ export function createRepoSync(auth, logger) {
82
115
  if (!exists) {
83
116
  const authed = await tokenizedUrl(cloneUrl);
84
117
  await run(["clone", "--filter=blob:none", "--no-checkout", authed, dir]);
118
+ // `git clone <url>` persists <url> as the origin remote - rewrite it to
119
+ // the clean https URL so the token never lands in .git/config.
120
+ await run(["remote", "set-url", "origin", cleanUrl(cloneUrl)], dir);
85
121
  await run(["checkout", defaultBranch], dir);
86
122
  }
87
123
  else {
@@ -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.10",
5
+ "version": "2026.11.12",
6
6
  "activation": {
7
7
  "onStartup": true
8
8
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamclaws/teamclaw",
3
- "version": "2026.11.10",
3
+ "version": "2026.11.12",
4
4
  "description": "OpenClaw virtual software team orchestration plugin - controller, role-based workers, Web UI with internet tunnel sharing",
5
5
  "private": false,
6
6
  "keywords": [
@@ -338,11 +338,11 @@ async function taskCheckpointRoute(ctx: RouteContext): Promise<void> {
338
338
  }
339
339
 
340
340
  async function taskResultContractRoute(ctx: RouteContext): Promise<void> {
341
- await handleTaskResultContractRequest(ctx.deps, ctx.req, ctx.res, ctx.pathname);
341
+ await handleTaskResultContractRequest(ctx.deps, ctx.req, ctx.res, ctx.pathname, ctx.peer);
342
342
  }
343
343
 
344
344
  async function taskResultRoute(ctx: RouteContext): Promise<void> {
345
- await handleTaskResultRequest(ctx.deps, ctx.req, ctx.res, ctx.pathname);
345
+ await handleTaskResultRequest(ctx.deps, ctx.req, ctx.res, ctx.pathname, ctx.peer);
346
346
  }
347
347
 
348
348
  async function taskExecutionEventRoute(ctx: RouteContext): Promise<void> {
@@ -18,6 +18,7 @@ import type {
18
18
  WorkerProgressContract,
19
19
  } from "../types.js";
20
20
  import { generateId, parseJsonBody, sendError, sendJson } from "../protocol.js";
21
+ import { isProtectionOn, type SecurityPeer } from "./security.js";
21
22
  import { normalizeRecommendedSkills, validateActiveRoleId } from "../profile-loader.js";
22
23
  import { deriveProjectSlug, deriveStableProjectKey } from "../openclaw-workspace.js";
23
24
  import {
@@ -522,11 +523,47 @@ export async function handleTaskCheckpointRequest(deps: ControllerTaskDomainDeps
522
523
  sendJson(res, 200, { ok: true, updatedAt: task.checkpoint?.updatedAt });
523
524
  }
524
525
 
526
+ /**
527
+ * ClawHub security review 2026.11.11: a submitted previewCommand is run by
528
+ * the controller as a shell process (restricted env, confined cwd - but still
529
+ * arbitrary code as the controller user). While device protection is off,
530
+ * only loopback / LAN peers (the owner's own workers) may supply one; a
531
+ * remote unpaired caller's contract is recorded WITHOUT preview fields so it
532
+ * can never trigger a process. Protection on: the device gate authenticated
533
+ * the caller, so nothing is stripped.
534
+ */
535
+ export function stripPreviewCommandsForUntrustedPeer(
536
+ body: Record<string, unknown>,
537
+ peer: SecurityPeer | undefined,
538
+ protectionOn: boolean,
539
+ ): void {
540
+ if (protectionOn || !peer || peer.loopback || peer.lan) {
541
+ return;
542
+ }
543
+ for (const key of ["contract", "resultContract"]) {
544
+ const raw = body[key];
545
+ if (!raw || typeof raw !== "object") {
546
+ continue;
547
+ }
548
+ const deliverables = (raw as { deliverables?: unknown }).deliverables;
549
+ if (!Array.isArray(deliverables)) {
550
+ continue;
551
+ }
552
+ for (const deliverable of deliverables) {
553
+ if (deliverable && typeof deliverable === "object") {
554
+ delete (deliverable as Record<string, unknown>).previewCommand;
555
+ delete (deliverable as Record<string, unknown>).previewCwd;
556
+ }
557
+ }
558
+ }
559
+ }
560
+
525
561
  // POST /api/v1/tasks/:id/result-contract
526
- export async function handleTaskResultContractRequest(deps: ControllerTaskDomainDeps, req: IncomingMessage, res: ServerResponse, pathname: string): Promise<void> {
562
+ export async function handleTaskResultContractRequest(deps: ControllerTaskDomainDeps, req: IncomingMessage, res: ServerResponse, pathname: string, peer?: SecurityPeer): Promise<void> {
527
563
  const { logger, getTeamState, updateTeamState } = deps;
528
564
  const taskId = pathname.split("/")[4]!;
529
565
  const body = await parseJsonBody(req);
566
+ stripPreviewCommandsForUntrustedPeer(body, peer, isProtectionOn(getTeamState()));
530
567
  const contract = normalizeWorkerTaskResultContract(body.contract ?? body.resultContract);
531
568
  const workerId = typeof body.workerId === "string" ? body.workerId : undefined;
532
569
  const currentTask = getTeamState()?.tasks[taskId];
@@ -576,10 +613,11 @@ export async function handleTaskResultContractRequest(deps: ControllerTaskDomain
576
613
  }
577
614
 
578
615
  // POST /api/v1/tasks/:id/result
579
- export async function handleTaskResultRequest(deps: ControllerTaskDomainDeps, req: IncomingMessage, res: ServerResponse, pathname: string): Promise<void> {
616
+ export async function handleTaskResultRequest(deps: ControllerTaskDomainDeps, req: IncomingMessage, res: ServerResponse, pathname: string, peer?: SecurityPeer): Promise<void> {
580
617
  const { logger, getTeamState, updateTeamState } = deps;
581
618
  const taskId = pathname.split("/")[4]!;
582
619
  const body = await parseJsonBody(req);
620
+ stripPreviewCommandsForUntrustedPeer(body, peer, isProtectionOn(getTeamState()));
583
621
  let result = typeof body.result === "string" ? body.result : "";
584
622
  let error = typeof body.error === "string" ? body.error : undefined;
585
623
  const workerId = typeof body.workerId === "string" ? body.workerId : undefined;
@@ -45,10 +45,25 @@ export function teamAutoProjectDir(repoId: string): string {
45
45
  * Git operations for TeamAuto. Authentication uses the device-flow token
46
46
  * inline in the remote URL (x-access-token basic auth) - proven to survive
47
47
  * GitHub's smart-HTTP redirects where extraheader injection does not. The
48
- * token never touches disk: remotes are rewritten per invocation and the
49
- * on-disk remote stays a clean https URL.
48
+ * token never touches disk: fetch/push rewrite the URL per invocation, and
49
+ * the one command that DOES store a URL (the initial clone) has its origin
50
+ * remote rewritten to the clean https URL right afterwards (ClawHub security
51
+ * review 2026.11.10). Every git error is redacted before it can reach a log,
52
+ * the store or a status response.
50
53
  */
51
54
 
55
+ /**
56
+ * Strip GitHub credentials from anything derived from git output: inline
57
+ * x-access-token userinfo and raw token shapes (gho_/ghp_..., github_pat_...).
58
+ * Exported for tests; applied by run() to every failure message.
59
+ */
60
+ export function redactGitSecrets(text: string): string {
61
+ return text
62
+ // Drop the whole userinfo so no "user:secret@" shape survives.
63
+ .replace(/x-access-token:[^@\s/]+@/gi, "[REDACTED]@")
64
+ .replace(/\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,})\b/g, "[REDACTED]");
65
+ }
66
+
52
67
  function gitEnv(): Record<string, string> {
53
68
  return {
54
69
  ...process.env,
@@ -59,13 +74,27 @@ function gitEnv(): Record<string, string> {
59
74
  }
60
75
 
61
76
  async function run(args: string[], cwd?: string): Promise<string> {
62
- const { stdout } = await exec("git", args, {
63
- cwd,
64
- env: gitEnv(),
65
- maxBuffer: 16 * 1024 * 1024,
66
- timeout: 120_000,
67
- });
68
- return stdout;
77
+ try {
78
+ const { stdout } = await exec("git", args, {
79
+ cwd,
80
+ env: gitEnv(),
81
+ maxBuffer: 16 * 1024 * 1024,
82
+ timeout: 120_000,
83
+ });
84
+ return stdout;
85
+ } catch (err) {
86
+ // git echoes the failing URL on stderr (the inline token userinfo ends
87
+ // up in the message), and callers persist error messages into the store
88
+ // and status responses. Redact before the error leaves this module.
89
+ if (err instanceof Error) {
90
+ err.message = redactGitSecrets(err.message);
91
+ const withStderr = err as Error & { stderr?: unknown };
92
+ if (typeof withStderr.stderr === "string") {
93
+ withStderr.stderr = redactGitSecrets(withStderr.stderr);
94
+ }
95
+ }
96
+ throw err;
97
+ }
69
98
  }
70
99
 
71
100
  export function createRepoSync(auth: GithubAuthManager, logger: { warn: (m: string) => void }) {
@@ -75,6 +104,11 @@ export function createRepoSync(auth: GithubAuthManager, logger: { warn: (m: stri
75
104
  return `https://x-access-token:${token}@${clean}.git`;
76
105
  }
77
106
 
107
+ /** The token-less https URL that is safe to persist in .git/config. */
108
+ function cleanUrl(cloneUrl: string): string {
109
+ return `https://${cloneUrl.replace(/^https:\/\//, "").replace(/\.git$/, "")}.git`;
110
+ }
111
+
78
112
  async function repoDir(repoId: string): Promise<string> {
79
113
  const { reposRoot, legacyReposRoot } = resolveTeamAutoPaths();
80
114
  await fs.mkdir(reposRoot, { recursive: true });
@@ -115,6 +149,9 @@ export function createRepoSync(auth: GithubAuthManager, logger: { warn: (m: stri
115
149
  if (!exists) {
116
150
  const authed = await tokenizedUrl(cloneUrl);
117
151
  await run(["clone", "--filter=blob:none", "--no-checkout", authed, dir]);
152
+ // `git clone <url>` persists <url> as the origin remote - rewrite it to
153
+ // the clean https URL so the token never lands in .git/config.
154
+ await run(["remote", "set-url", "origin", cleanUrl(cloneUrl)], dir);
118
155
  await run(["checkout", defaultBranch], dir);
119
156
  } else {
120
157
  const authed = await tokenizedUrl(cloneUrl);