Skip to content

fix(paragraph-cli): prevent windows command injection and map base url configuration - #4

Open
magqqgq wants to merge 1 commit into
paragraph-xyz:mainfrom
magqqgq:magqqgq-patch-1
Open

fix(paragraph-cli): prevent windows command injection and map base url configuration#4
magqqgq wants to merge 1 commit into
paragraph-xyz:mainfrom
magqqgq:magqqgq-patch-1

Conversation

@magqqgq

@magqqgq magqqgq commented Aug 29, 2026

Copy link
Copy Markdown

Description

This PR addresses a high-severity command injection vulnerability in the CLI's browser authentication flow and resolves a medium-severity configuration mismatch[cite: 40]. The update ensures that server-provided login URLs are handled securely on Windows and that custom API endpoint overrides are correctly mapped to the underlying SDK[cite: 40].

Key Changes

  • Command Injection Prevention (src/services/browser-auth.ts):
    • Removed the unsafe cmd.exe /c start shell dispatch, which previously allowed shell metacharacters and environment expansion in untrusted URLs to cross the CLI's process-launch boundary[cite: 40].
    • The openBrowser function now explicitly validates http: and https: URL schemes and passes the normalized URL directly to explorer.exe using execFile, safely avoiding the Windows shell[cite: 40].
  • Configuration Alignment (src/services/client.ts):
    • Mapped the documented PARAGRAPH_API_URL environment variable directly to the SDK's newly exposed baseURL option, ensuring the CLI reliably overrides the hard-coded API endpoint[cite: 40].
  • Regression Testing (test/browser-auth.test.ts):
    • Added dedicated regression tests to verify non-HTTP URL scheme rejection and validate the secure execFile launcher invocation[cite: 40].

Validation & Testing

  • Static Verification: TypeScript syntax parsing (node --experimental-strip-types --check) passed successfully for the modified source and test files[cite: 40].
  • Reviewer Action Required: The native CLI build (npm run build) and regression suite (npm test) were blocked during the offline audit because tsup and vitest dependencies were absent in the workspace[cite: 40]. A maintainer must install dependencies and execute the full test suite locally before merging[cite: 40].

…l configuration

### Description
This PR addresses a high-severity command injection vulnerability in the CLI's browser authentication flow and resolves a medium-severity configuration mismatch[cite: 40]. The update ensures that server-provided login URLs are handled securely on Windows and that custom API endpoint overrides are correctly mapped to the underlying SDK[cite: 40].

### Key Changes
* **Command Injection Prevention (`src/services/browser-auth.ts`):**
  - Removed the unsafe `cmd.exe /c start` shell dispatch, which previously allowed shell metacharacters and environment expansion in untrusted URLs to cross the CLI's process-launch boundary[cite: 40].
  - The `openBrowser` function now explicitly validates `http:` and `https:` URL schemes and passes the normalized URL directly to `explorer.exe` using `execFile`, safely avoiding the Windows shell[cite: 40].
* **Configuration Alignment (`src/services/client.ts`):**
  - Mapped the documented `PARAGRAPH_API_URL` environment variable directly to the SDK's newly exposed `baseURL` option, ensuring the CLI reliably overrides the hard-coded API endpoint[cite: 40].
* **Regression Testing (`test/browser-auth.test.ts`):**
  - Added dedicated regression tests to verify non-HTTP URL scheme rejection and validate the secure `execFile` launcher invocation[cite: 40].

### Validation & Testing
* **Static Verification:** TypeScript syntax parsing (`node --experimental-strip-types --check`) passed successfully for the modified source and test files[cite: 40].
* **Reviewer Action Required:** The native CLI build (`npm run build`) and regression suite (`npm test`) were blocked during the offline audit because `tsup` and `vitest` dependencies were absent in the workspace[cite: 40]. A maintainer must install dependencies and execute the full test suite locally before merging[cite: 40].
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.

1 participant