Repository navigation
fix: harden Squad input handling - #2543
Conversation
Relates to #2538 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
🟠 Impact Analysis — PR #2543Risk tier: 🟠 HIGH 📊 Summary
🎯 Risk Factors
📦 Modules Affectedroot (1 file)
squad-cli (5 files)
squad-sdk (13 files)
tests (9 files)
|
🛫 PR Readiness Check
PR Scope: 📦🔧 Mixed (product + infrastructure)
|
| Status | Check | Details |
|---|---|---|
| ❌ | Single commit | 6 commits — consider squashing before review |
| ✅ | Not in draft | Ready for review |
| ✅ | Branch up to date | Up to date with dev |
| ❌ | Copilot review | No Copilot review yet — it may still be processing |
| ✅ | Changeset present | Changeset file found |
| ✅ | Scope clean | No .squad/ or docs/proposals/ files |
| ✅ | No merge conflicts | No merge conflicts |
| ✅ | Copilot threads resolved | All 1 Copilot thread(s) resolved |
| ✅ | CI passing | All checks passing |
Files Changed (28 files, +691 −122)
| File | +/− |
|---|---|
.changeset/secure-release-paths.md |
+8 −0 |
packages/squad-cli/src/cli/commands/doctor.ts |
+1 −1 |
packages/squad-cli/src/cli/commands/migrate.ts |
+12 −7 |
packages/squad-cli/src/cli/core/team-md.ts |
+8 −1 |
packages/squad-cli/src/cli/core/upgrade.ts |
+8 −7 |
packages/squad-cli/src/cli/shell/index.ts |
+6 −1 |
packages/squad-sdk/src/agents/onboarding.ts |
+22 −7 |
packages/squad-sdk/src/backend/durable-http-backend.ts |
+3 −1 |
packages/squad-sdk/src/casting/handwritten-registry.ts |
+15 −4 |
packages/squad-sdk/src/client/adapters/apply.ts |
+12 −3 |
packages/squad-sdk/src/client/adapters/coordinator.ts |
+5 −2 |
packages/squad-sdk/src/config/init.ts |
+73 −44 |
packages/squad-sdk/src/config/team-capabilities.ts |
+26 −4 |
packages/squad-sdk/src/platform/comms-teams.ts |
+19 −1 |
packages/squad-sdk/src/platform/detect.ts |
+25 −6 |
packages/squad-sdk/src/ralph/triage.ts |
+44 −8 |
packages/squad-sdk/src/resolution.ts |
+89 −18 |
packages/squad-sdk/src/state-backend.ts |
+8 −4 |
packages/squad-sdk/src/storage/in-memory-storage-provider.ts |
+2 −1 |
test/clients.test.ts |
+1 −1 |
test/comms-teams.test.ts |
+5 −0 |
test/init-scaffolding.test.ts |
+2 −0 |
test/init-sdk.test.ts |
+98 −0 |
test/migrate.test.ts |
+76 −0 |
test/platform-adapter.test.ts |
+27 −0 |
test/profile-boundary.test.ts |
+83 −1 |
test/ralph-triage.test.ts |
+9 −0 |
test/team-capabilities.test.ts |
+4 −0 |
Total: +691 −122
This check runs automatically on every push. Fix any ❌ items and push again.
See CONTRIBUTING.md and PR Requirements for details.
🏗️ Architectural Review
Automated architectural review — informational only. |
There was a problem hiding this comment.
🟡 Changes recommended
The migration generator still interpolates unescaped Markdown values, which can produce invalid squad.config.ts or allow crafted values to execute when the configuration is loaded.
1 open issue
What changed in this PR
This PR hardens input handling across Squad’s CLI and SDK as part of the Squad 2.0.0 release remediation.
Changes:
- Escape generated configuration and Markdown, validate Azure remote hosts, and restrict self-upgrade selections.
- Replace several complex regular expressions with explicit string scanning.
- Add targeted regression coverage and a CLI/SDK patch changeset.
| File | Description |
|---|---|
test/team-capabilities.test.ts |
Tests backslash escaping and malformed HTML comments. |
test/platform-adapter.test.ts |
Covers spoofed Azure hosts and valid SSH remotes. |
test/init-sdk.test.ts |
Checks generated configuration preserves escaped project metadata. |
test/init-scaffolding.test.ts |
Adds invalid SemVer greeting cases. |
test/comms-teams.test.ts |
Tests single-pass entity decoding and nested markup. |
test/clients.test.ts |
Simplifies an expected-value assertion without changing coverage. |
packages/squad-sdk/src/storage/in-memory-storage-provider.ts |
Simplifies trailing-slash removal after path normalization. |
packages/squad-sdk/src/state-backend.ts |
Removes trailing slashes with explicit scanning. |
packages/squad-sdk/src/resolution.ts |
Trims project-key edge hyphens without complex matching. |
packages/squad-sdk/src/ralph/triage.ts |
Scans Markdown links and simplifies routing token matching. |
packages/squad-sdk/src/platform/detect.ts |
Validates remote protocols and hosts before selecting Azure. |
packages/squad-sdk/src/platform/comms-teams.ts |
Scans HTML tags and decodes entities once. |
packages/squad-sdk/src/config/team-capabilities.ts |
Strengthens comment removal and Markdown escaping. |
packages/squad-sdk/src/config/init.ts |
Escapes generated metadata and updates version and remote parsing. |
packages/squad-sdk/src/client/adapters/coordinator.ts |
Extracts headings using prefix checks. |
packages/squad-sdk/src/client/adapters/apply.ts |
Simplifies TOML matching and trailing-line-break handling. |
packages/squad-sdk/src/casting/handwritten-registry.ts |
Simplifies agent-ID and universe-metadata parsing. |
packages/squad-sdk/src/backend/durable-http-backend.ts |
Scans trailing URL slashes explicitly. |
packages/squad-sdk/src/agents/onboarding.ts |
Replaces the routing-array regex with string scanning. |
packages/squad-cli/src/cli/shell/index.ts |
Detects quota errors through line-based scanning. |
packages/squad-cli/src/cli/core/upgrade.ts |
Restricts upgrade selections and reuses host-based remote detection. |
packages/squad-cli/src/cli/core/team-md.ts |
Removes coding-agent sections using explicit boundaries. |
packages/squad-cli/src/cli/commands/migrate.ts |
Strengthens JavaScript string-literal escaping. |
packages/squad-cli/src/cli/commands/doctor.ts |
Simplifies trailing-separator matching on resolved paths. |
.changeset/secure-release-paths.md |
Records patch releases for the CLI and SDK hardening. |
Review effort: Max (adaptive)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Reject legacy team roots before accessing profile paths, while preserving fail-closed alias resolution. Closes #2538 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Escape agent-derived configuration values and resolve profile links without following them into retired trees. Closes #2538 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

What
Harden CLI and SDK input handling to address the product-side CodeQL alerts blocking Squad 2.0.0 promotion.
Why
Relates to #2538. Inputs used in generated configuration, remote detection, text parsing, and self-upgrade commands need safe handling without changing normal upgrade behavior.
How
Escape generated strings and Markdown, validate remote hosts and upgrade selections, and replace pathological regular expressions with linear parsing. The release-workflow and script changes are in a separate PR. The changeset belongs on dev; the sanitized 2.0.0 promotion tree must omit unconsumed changesets.
Validation was run on the combined remediation worktree before the PRs were separated:
SKIP_BUILD_BUMP=1 npm run build: passed.npm run lint: passed.npm run lint:eslint: passed with existing warnings.npx --no-install vitest run test/resolution.test.ts test/cli/doctor.test.ts test/migrate.test.ts test/migration.test.ts --maxWorkers=2 --testTimeout=30000 --hookTimeout=30000: passed, 156 tests.npm testwas not run locally; CI must run it. A longer targeted state-backend run was interrupted before the branch split and is not claimed as passing.npx changeset add/.changeset/*.md, directCHANGELOG.mdentry for maintainers, orskip-changeloglabel for no user-facing changes)PR Readiness Checklist
Branch & Commit
dev(notmain)dev(git fetch upstream && git rebase upstream/dev)git diff --cached --stat)Build & Test
npm run buildpassesnpm testpasses (all tests green)npm run lintpasses (type check clean)npm run lint:eslintpassesThe full-suite checkbox awaits CI. The user approved the >20-file release remediation.
Changeset
npx changeset add(ifpackages/squad-sdk/src/orpackages/squad-cli/src/changed)CHANGELOG.mdentry (maintainers only — write-protected for external contributors)skip-changeloglabel applied (if no user-facing changes)The changeset was written directly in the repository format.
Docs
N/A: no new feature or capability.
Exports
N/A: no new module or export.
Breaking Changes
Malformed or spoofed Azure remote URLs no longer select the Azure adapter. Unsupported self-upgrade selections fail explicitly.
Waivers
None requested. Required CI must pass before merge.