Skip to content

Validate Pi sub-agent invocation parameters - #74370

Merged
pelikhan merged 2 commits into
mainfrom
copilot/sighthound-fix-security-findings
Nov 3, 2026
Merged

pelikhan merged 2 commits into
mainfrom
copilot/sighthound-fix-security-findings

Conversation

Copilot AI commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Security findings flagged package-validation commands and Pi sub-agent delegation as potential command injection paths. The Go commands already resolve fixed executable names and validate package names; this change hardens validation at the Pi tool boundary.

  • Validate delegation input: Reject malformed parameters, blank tasks, and agents not declared in the manifest before dispatch.
  • Keep task data separate from execution: The task remains on child stdin; it is not added to command arguments, and the process launches with shell: false.
if (!params || typeof params !== "object" || Array.isArray(params) ||
    typeof params.agent !== "string" ||
    typeof params.task !== "string" || !params.task.trim()) {
  throw new Error("Choose a declared Pi sub-agent and provide a non-empty task");
}

Copilot AI changed the title [WIP] Fix critical security findings in github/gh-aw Validate Pi sub-agent invocation parameters Nov 3, 2026
Copilot AI requested a review from pelikhan November 3, 2026 03:44
@pelikhan
pelikhan marked this pull request as ready for review November 3, 2026 05:25
Copilot AI adaptive review requested due to automatic review settings November 3, 2026 05:25
@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Ponytail Reviewer

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Ponytail Reviewer · routed: gpt56 max · ~2 AIC · ⌖ ~1 AIC · ⊞ 118 · ◷

Generated by Ponytail Reviewer for #74370

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft.

Design Decision Gate 🏗️

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Design Decision Gate 🏗️ · routed: gpt56 max · ~1 AIC · ⌖ ~2 AIC · ⊞ 7.7K · ◷

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Test Quality Sentinel · sonnet50 · ~15 AIC · ⌖ ~21 AIC · ⊞ 12.9K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (pr-code-quality-reviewer)
reviewed_at: 2026-11-03T05:28:33Z
review_event: COMMENT
top_themes: [unbounded delegated task input]
files_reviewed: [actions/setup/js/pi_subagent_extension.cjs, actions/setup/js/pi_subagent_extension.test.cjs]
comment_count: 1

Note

This comment is managed by comment memory.

Expand the saved memory block to view or edit the persistent context for this thread.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~2 AIC · ⌖ ~1 AIC · ⊞ 1.7K · ◷
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: non-blocking concern

The parameter-shape validation is correct, but delegated tasks remain unbounded and can impose avoidable memory/runtime pressure on the child process. I left one inline comment requesting a task-size limit and regression test.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~2 AIC · ⌖ ~1 AIC · ⊞ 1.7K
Comment /review to run again

description: `Delegate a task to a declared agent in an isolated Pi session. Available agents: ${agents.map(agent => `${agent.name}: ${agent.description}`).join("; ")}`,
parameters: { type: "object", properties: { agent: { type: "string", enum: agents.map(agent => agent.name) }, task: { type: "string", minLength: 1 } }, required: ["agent", "task"], additionalProperties: false },
async execute(_id, params, signal, _onUpdate, ctx) {
if (!params || typeof params !== "object" || Array.isArray(params) || typeof params.agent !== "string" || typeof params.task !== "string" || !params.task.trim())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new boundary still accepts arbitrarily large task strings and writes them directly to child stdin, so a huge invocation can consume substantial memory or keep the child busy despite this validation hardening.

💡 Bound delegated task size

Add a documented maximum task length (and a regression test) before dispatch, or otherwise enforce a resource limit at this boundary. The existing schema only has minLength, so it does not prevent oversized input.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Applied /tdd and /codebase-design. The hardening is sound: the guard runs before agents.find and before any dispatch, and the task still goes to child stdin with shell: false. Three small test-coverage items remain.

📋 Key Themes & Highlights

Key Themes

  • Test table gaps: the new guard has two clauses (agent type, task type) with no matching test rows.
  • Dispatch ordering is untested: nothing asserts that a rejected call emits no dispatch event.
  • Redundant clause: typeof params.agent !== "string" duplicates the strict === in the find.

Positive Highlights

  • ✅ Validation happens before the agent lookup, so malformed input never reaches runPiSubagent.
  • ✅ Non-object and array params are rejected explicitly.
  • ✅ The shell: false and stdin-only task design is unchanged and correct.

Verification

  • I ran the validation logic directly with Node against 10 malformed or undeclared inputs. Each one throws the expected error.
  • I could not run the Vitest suite: npm ci failed on a sandbox TLS certificate error, so the new it.each row is unverified.

@copilot please address the review comments above.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~3 AIC · ⌖ ~1 AIC · ⊞ 5.4K
Comment /matt to run again

expect(registerTool).not.toHaveBeenCalled();
});

it.each([null, [], { agent: "unknown", task: "Read." }, { agent: "reader", task: " " }])("rejects malformed or undeclared invocation parameters: %j", async params => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/tdd] The new typeof guards have no test row for a non-string task. With { agent: "reader", task: 5 } only the first clause protects the call. If that clause were removed, .trim() would throw a TypeError with a different message, and this suite would not catch it.

💡 Suggested rows

Add these two rows to the array on line 61:

  • { agent: 1, task: "Read." }
  • { agent: "reader", task: 5 }

One row per guard clause makes the table read as a spec for the boundary.

@copilot please address this.

const registerTool = vi.fn();
extension({ registerTool });
const tool = registerTool.mock.calls[0][0];
await expect(tool.execute("id", params, undefined, undefined, { cwd: dir })).rejects.toThrow("Choose a declared Pi sub-agent");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/tdd] The test checks the rejection but not the "before dispatch" guarantee the PR description relies on. A change that moved validation after the dispatch event would still pass this test.

💡 Suggested assertion

Add after line 66:

expect(process.stdout.write).not.toHaveBeenCalled();

process.stdout.write is already mocked in beforeEach, so no extra setup is needed.

@copilot please address this.

description: `Delegate a task to a declared agent in an isolated Pi session. Available agents: ${agents.map(agent => `${agent.name}: ${agent.description}`).join("; ")}`,
parameters: { type: "object", properties: { agent: { type: "string", enum: agents.map(agent => agent.name) }, task: { type: "string", minLength: 1 } }, required: ["agent", "task"], additionalProperties: false },
async execute(_id, params, signal, _onUpdate, ctx) {
if (!params || typeof params !== "object" || Array.isArray(params) || typeof params.agent !== "string" || typeof params.task !== "string" || !params.task.trim())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: typeof params.agent !== "string" is redundant. The strict === in the find on line 212 already rejects non-string values, so behavior is identical without this clause.

@copilot please address this.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The undeclared-agent error misleadingly asks for a non-empty task when a valid task is supplied and omits the declared agent names needed to correct the selection.

1 open issue
What changed in this PR

Hardens gh-aw’s Pi sub-agent delegation boundary in response to #74044 by validating invocation parameters before agent lookup and dispatch.

Changes:

  • Rejects malformed parameters and blank tasks before looking up the declared agent.
  • Adds regression cases for null, array, undeclared-agent, and whitespace-only-task inputs.
File Description
actions/​setup/​js/​pi_subagent_extension.test.cjs Adds invalid-invocation regression cases.
actions/​setup/​js/​pi_subagent_extension.cjs Validates parameter shape and task content before agent lookup.

Review effort: Max (auto)

throw new Error("Choose a declared Pi sub-agent and provide a non-empty task");
const agent = agents.find(candidate => candidate.name === params.agent);
if (!agent || typeof params.task !== "string" || !params.task.trim()) throw new Error("Choose a declared Pi sub-agent and provide a non-empty task");
if (!agent) throw new Error("Choose a declared Pi sub-agent and provide a non-empty task");
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Note

The pull request was not created — a fallback review issue was created instead due to protected file changes: #74424

PR finisher pass: merged main locally and addressed the listed review items in pi_subagent_extension.cjs/test: added a 256 KiB task cap, removed the redundant agent typeof check, added an agent-specific error listing declared names, and added tests for non-string task/agent and no-dispatch-before-validation. Submitted for publication (not confirmed pushed). Local validation: vitest/prettier could not run (npm registry cert failure); verified behavior manually with node. Review replies/resolutions deferred until the fix is published. CI needs a maintainer re-trigger after publication.

PR finisher dispatch requested for the following outstanding work: review items 1-6 above.

Sous-chef head: 3f49ac2
Sous-chef work: 109b1babe01c52fb09f7a8bd457aaf5608b1ec5f3653120859eabfe061a2f82b 22bfcc08194b185bc50915edcfbb9961ca57b0e94b27c3adbeee976915f037bf 2ec9930af21c7ab5843507c239aca219a022ca9967305138d3e081c1dd4bef5e e39025aa0662d5bc54a3912373c4980a125093f132c06611d498292417db0f55 eb2e0e3c302867b82c07cb8cba44167f3a14c33a5d226f2355396dcec5d2d024
Sous-chef state: 3d906f84d18c4198d9f6546bcca02dc8b1f2d79b1108764fc33962adb22cebeb

Generated by 🏁 PR Finisher · copilot · auto · ~22 AIC · ⌖ ~2 AIC · ⊞ 10.7K · ◷

@pelikhan
pelikhan merged commit 41bb19a into main Nov 3, 2026
79 checks passed
@pelikhan
pelikhan deleted the copilot/sighthound-fix-security-findings branch November 3, 2026 06:21
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[sighthound] Security findings in github/gh-aw

3 participants