security: CLI security audit — 6 exploitable vulnerability findings

Merged
CU
3mo ago
+213-0

What

  • Full security audit of the Capacitor CLI (cli/src/) documenting 6 exploitable vulnerabilities with complete attack chains.

Why

  • The CLI handles untrusted input from multiple sources (plugin.xml, package.json, capacitor.config.ts) and passes them to dangerous sinks (shell spawn, file system operations, XML generation) without adequate validation.

How

  • Traced data flow from user inputs (CLI args, config files, Cordova plugin.xml) through the codebase to dangerous sinks (spawn, fs.copy, writeFile, require).
  • Documented each finding with file:line evidence, complete attack chains, and recommended mitigations.

Findings Summary

#SeverityTitleLocation
1HIGHArbitrary command execution via hook scriptscommon.ts:160-206
2HIGHPath traversal in Cordova plugin asset copyingcordova.ts:138, android/update.ts:344
3MEDIUMXML injection in generated config filescordova.ts:207-239
4MEDIUMUnvalidated platform path configconfig.ts:211-212, 267-268
5MEDIUMSymlink following in web asset copycopy.ts:183-186
6LOW-MEDIUMGradle flavor injection in build argumentsandroid/build.ts:14

Testing

  • Manual source code review and data flow analysis across all 18 specified CLI source files.
  • Verified xml2js is NOT vulnerable to XXE.
  • Verified livereload.ts does NOT have SSRF (only modifies local config JSON files).

Not Tested

  • Runtime exploitation of the findings (no example app environment available).
  • Whether fs-extra.copy defaults have changed in newer versions regarding symlink behavior.
Open in Web View Automation 

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.