paperclip/cli/src/__tests__
Nicky Leach fdb9a4880d
fix(security): route paperclipai CLI guidance through safe npx form (CWE-78) (#11400)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Paperclip provides CLI commands and guidance for operators and
agents
> - The `pnpm paperclipai` script can pass argument values through a
shell
> - Shell re-parsing can execute command substitutions inside quoted
values
> - This pull request routes guidance through inert-argv `npx
paperclipai` commands and adds regression coverage
> - The benefit is safer operator guidance across documentation and
runtime hints

## Linked Issues or Issue Description

This pull request fixes a command-injection-class defect in Paperclip
CLI guidance.

**What happened?**

The `pnpm paperclipai <sub> --flag "$VALUE"` form can re-parse argument
values through a shell. A command substitution inside a quoted value can
execute on the host.

**Expected behavior**

Paperclip guidance must pass CLI values as inert argument values.
Host-derived values must not appear in copyable commands.

**Steps to reproduce**

1. Run a Paperclip guidance command that uses the `pnpm paperclipai`
script.
2. Provide a quoted value that contains a command substitution.
3. Observe that the shell can evaluate the substitution before the CLI
starts.
4. Compare the result with the `npx paperclipai` form.

**Paperclip version or commit**

`5670984b75d109950c968542a0111ebb6967f4da`

**Deployment mode**

All deployment modes that show or use the affected CLI guidance.

**Installation method**

Built from source and installed CLI guidance.

**Agent adapter(s) involved**

Not adapter-specific (core bug).

**Database mode**

Not database-related.

**Access context**

Both.

**Additional context**

The earlier merged PR
[#11343](https://github.com/paperclipai/paperclip/pull/11343) used the
unsafe `pnpm exec paperclipai` form. This fresh PR replaces that
guidance with the safe `npx paperclipai` form.

## What Changed

- Standardize documentation and runtime hints on `npx paperclipai`.
- Remove the broken `pnpm exec paperclipai` guidance.
- Use a static `<host>` placeholder in private-hostname guidance.
- Add regression tests for unsafe forms, continued lines, static hosts,
and offline guidance.

## Verification

- `git diff --check
origin/master...origin/fix/paperclipai-cli-npx-safe-invocation` passes.
- The branch adds `server/src/__tests__/cli-invocation-safety.test.ts`
and updates private-hostname tests.
- CI must run the new tests, typecheck, lint, and build checks.
- Local Vitest execution was not available because this worktree has no
installed Vitest binary.

## Risks

- The change affects operator and agent documentation text.
- The runtime hints now show `<host>` instead of a request-derived host
value.
- No database schema or migration changes exist.
- CI will detect any missed unsafe invocation or type error.

## Model Used

OpenAI GPT-5, exact model ID `gpt-5`, with tool use and code-review
assistance. The model used repository inspection, Git operations, and PR
preparation.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] CI ran the test suites and they pass; local test execution was
unavailable in this worktree
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I addressed all Greptile and reviewer comments before requesting
merge

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-08-14 22:11:16 -07:00
..
helpers Replace host-to-host Cloud Sync with full-fidelity company Import/Export (#10507) 2026-07-30 11:37:00 -07:00
access-parity.test.ts Improve CLI API parity coverage (#6626) 2026-06-02 17:13:29 -07:00
activity-parity.test.ts Improve CLI API parity coverage (#6626) 2026-06-02 17:13:29 -07:00
admin-asset-skill-parity.test.ts Improve CLI API parity coverage (#6626) 2026-06-02 17:13:29 -07:00
agent-jwt-env.test.ts fix(config): preserve env files during managed updates (#10980) 2026-08-07 00:54:43 -05:00
agent-lifecycle.test.ts feat(skills): require explicit merge modes (#10978) 2026-08-07 00:42:08 -05:00
allowed-hostname.test.ts feat: implement app-side telemetry sender 2026-04-02 10:47:29 -05:00
auth-command-registration.test.ts fix(cli): handle headless browser-open failure in board auth (#8328) 2026-06-19 08:58:17 -07:00
board-auth.test.ts Add browser-based board CLI auth flow 2026-03-23 08:46:05 -05:00
channels.test.ts feat(cli): add 'paperclipai channels' to show release lanes and the current one (#11210) 2026-08-11 08:47:32 -07:00
common.test.ts test(cli): cover API path construction (#9254) 2026-07-21 09:57:11 -05:00
company-delete.test.ts feat(interactions): add governed agent addressees (#10252) 2026-08-04 12:51:06 -05:00
company-export-force.test.ts feat(cli): add --force to company export for non-interactive runs (#10054) 2026-07-22 15:36:54 -07:00
company-import-export-e2e.test.ts feat(decisions): add first-class propose mode (#10010) 2026-07-31 19:17:02 -07:00
company-import-transfer.test.ts feat(server): chunked import preview endpoint and resumable upload in the Import page and CLI (#11224) 2026-08-11 16:06:37 -07:00
company-import-url.test.ts refactor: rename URL validators to looksLikeRepoUrl 2026-04-01 23:21:22 +00:00
company-import-zip.test.ts Replace host-to-host Cloud Sync with full-fidelity company Import/Export (#10507) 2026-07-30 11:37:00 -07:00
company.test.ts feat(skills): require explicit merge modes (#10978) 2026-08-07 00:42:08 -05:00
config-store.test.ts fix(config): preserve extensions and guard invalid repairs (#11005) 2026-08-07 00:41:19 -05:00
configure-repair.test.ts fix(config): preserve extensions and guard invalid repairs (#11005) 2026-08-07 00:41:19 -05:00
configure.test.ts fix(config): preserve extensions and guard invalid repairs (#11005) 2026-08-07 00:41:19 -05:00
connect.test.ts Improve CLI API parity coverage (#6626) 2026-06-02 17:13:29 -07:00
context.test.ts Improve CLI API parity coverage (#6626) 2026-06-02 17:13:29 -07:00
data-dir.test.ts feat(cli): add --data-dir flag to isolate local state 2026-03-02 14:20:37 -06:00
doctor.test.ts feat: implement app-side telemetry sender 2026-04-02 10:47:29 -05:00
env-lab.test.ts fix(security): route paperclipai CLI guidance through safe npx form (CWE-78) (#11400) 2026-08-14 22:11:16 -07:00
feedback.test.ts Improve CLI API parity coverage (#6626) 2026-06-02 17:13:29 -07:00
home-paths.test.ts [codex] Add LLM Wiki plugin host support (#5597) 2026-05-10 07:34:12 -05:00
http.test.ts fix(security): route paperclipai CLI guidance through safe npx form (CWE-78) (#11400) 2026-08-14 22:11:16 -07:00
install-command.test.ts feat(cli): add managed install, update, and service lifecycle (#10045) 2026-07-31 18:52:23 -07:00
install-store.test.ts feat(cli): add managed install, update, and service lifecycle (#10045) 2026-07-31 18:52:23 -07:00
issue-subresources.test.ts fix(cli): send X-Paperclip-Run-Id so agents can mutate their issues via the CLI (#7642) 2026-06-06 15:55:55 -07:00
managed-install-check.test.ts feat(cli): add managed install, update, and service lifecycle (#10045) 2026-07-31 18:52:23 -07:00
network-bind.test.ts Fix wrapped company issue prefix conflicts (#6423) 2026-05-22 15:27:54 -05:00
onboard-service.test.ts feat(cli): add managed install, update, and service lifecycle (#10045) 2026-07-31 18:52:23 -07:00
onboard.test.ts fix(config): preserve extensions and guard invalid repairs (#11005) 2026-08-07 00:41:19 -05:00
open-url.test.ts fix(cli): handle headless browser-open failure in board auth (#8328) 2026-06-19 08:58:17 -07:00
operations-parity.test.ts Improve CLI API parity coverage (#6626) 2026-06-02 17:13:29 -07:00
pipelines.test.ts Add pipeline workflow primitives and operator UI (#7903) 2026-06-26 12:02:44 -05:00
plugin-init.test.ts feat(cli): surface plugin install target host + add `plugin target` (#8575) 2026-06-25 01:07:35 -07:00
project-goal.test.ts feat(mcp) [split 5/8]: integrate adapters and deployment runtime (#9560) 2026-07-14 15:15:43 -05:00
prompt.test.ts test(cli): cover board prompt handoff (#9137) 2026-07-21 10:00:28 -05:00
routine-plugin-parity.test.ts feat(mcp) [split 5/8]: integrate adapters and deployment runtime (#9560) 2026-07-14 15:15:43 -05:00
routines.test.ts feat(routines): add workspace-aware routine runs 2026-04-02 11:38:57 -05:00
run.test.ts Improve CLI API parity coverage (#6626) 2026-06-02 17:13:29 -07:00
secrets.test.ts feat(secrets): add user-specific runtime secrets (#8825) 2026-07-05 05:58:20 -05:00
service-health-check.test.ts feat(cli): add managed install, update, and service lifecycle (#10045) 2026-07-31 18:52:23 -07:00
service-manager.test.ts feat(cli): add managed install, update, and service lifecycle (#10045) 2026-07-31 18:52:23 -07:00
skills.test.ts feat(skills): require explicit merge modes (#10978) 2026-08-07 00:42:08 -05:00
teams.test.ts refactor(deps-dev): bump vitest from 3.2.4 to 4.1.8 (#7581) 2026-06-05 21:11:32 -07:00
telemetry.test.ts test: make cli telemetry test deterministic in CI 2026-04-02 10:47:30 -05:00
token.test.ts test(cli): cover board token commands (#9138) 2026-07-21 10:01:15 -05:00
update-command.test.ts feat(cli): add managed install, update, and service lifecycle (#10045) 2026-07-31 18:52:23 -07:00
update-notice.test.ts feat(cli): add managed install, update, and service lifecycle (#10045) 2026-07-31 18:52:23 -07:00
worktree-merge-history.test.ts Add merge-history project import option 2026-03-23 08:14:51 -05:00
worktree.test.ts feat: refine app connections and legacy worktree startup (#11040) 2026-08-07 14:26:40 -05:00
zip-codec.test.ts Replace host-to-host Cloud Sync with full-fidelity company Import/Export (#10507) 2026-07-30 11:37:00 -07:00