T03 · Remote Payload Retrieval and Execution
Error
- Location
- SKILL.md:39
- Finding
- Unpinned Remote Package Output Is Executed Through eval<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 39-51 **Vulnerability Type**: Remote package execution and unsafe shell evaluation **Risk Level**: Critical ### Vulnerable Code ```sh **B. OAuth via the mobile QR-login flow** In the Canvas mobile app: Account → **QR for Login** (or "Pair with Observer/QR Login"), scan it with any camera to get the URL it encodes (`https://sso.canvaslms.com/canvas/login?domain=...&code=...`). Exchange it once for OAuth credentials with the helper this same repo ships (no MCP server needs to be *running* — it's a one-off CLI). It prints four `NAME=value` lines to stdout (`CANVAS_BASE_URL`/`CANVAS_CLIENT_ID`/`CANVAS_CLIENT_SECRET`/`CANVAS_REFRESH_TOKEN`) — **export them into the shell**, since the next `curl` reads them as env vars and this step can't be skipped: ```sh eval "$(npx canvas-parent-mcp-qr-login "<qr-url>" | sed 's/^/export /')" ``` ``` ### Technical Analysis The command invokes an unpinned npm package through `npx`. If that package is not already installed locally, `npx` can retrieve and execute it from the package registry. The effective implementation can therefore change after the Skill has been reviewed. The package's standard output is subsequently transformed with `sed` and executed directly by the current shell through `eval`. There is no parser restricting the output to the four expected environment-variable assignments. Shell metacharacters, command substitutions, redirections, and additional statements emitted by the package would all be interpreted as commands. The combination is more dangerous than merely using an unpinned dependency: arbitrary output from remotely sourced executable code is explicitly passed into a second shell-evaluation stage. ### Attack Path 1. An attacker compromises the npm package, a transitive dependency, the publisher account, or the package-distribution channel. 2. The affected package version is made to emit malicious shell syntax in addition to, ...[truncated 841 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove `eval` entirely. 2. Pin the helper package to a specifically reviewed version instead of allowing `npx` to select the current registry version. 3. Lock and verify package integrity through a reviewed lockfile or an equivalent cryptographic integrity mechanism. 4. Prefer shipping a small, auditable helper with the Skill rather than retrieving executable code during use. 5. Parse helper output as data: - Permit only `CANVAS_BASE_URL`, `CANVAS_CLIENT_ID`, `CANVAS_CLIENT_SECRET`, and `CANVAS_REFRESH_TOKEN`. - Reject duplicate, missing, or unexpected fields. - Validate values before assigning them. - Assign values using shell-safe mechanisms rather than evaluating generated source code. 6. Run any unavoidable credential helper in a constrained subprocess with minimum filesystem and network privileges. ]]>
