#2571·quartz

Use argument arrays for git/npm child processes and JSON-escape generated plugin imports

Author: nomad-geekCreated Sep 27, 2026Updated Sep 27, 2026

CodeQL flags a few places in the v5 CLI and plugin loader where shell commands and generated source are built by string interpolation. None of them is reachable from page content: the inputs come from quartz.config.yaml, quartz.lock.json, command-line arguments or the working directory. But they break on unusual paths or names, and they would be simple to harden. References are to 97a2d05.

Shell commands built by interpolation

  • quartz/cli/handlers.js:640: git add ${LOCKFILE_PATH} is unquoted, so a working directory with a space or a shell metacharacter breaks it.
  • quartz/cli/plugin-git-handlers.js:1196: npm install ${parsed.name}. The name only has to start with @, contain / and not contain :, so ; or $(…) get through to the shell.
  • quartz/plugins/loader/gitLoader.ts:532 and :544: git clone puts the repository in double quotes but inserts the ref unquoted, so a plugin source such as github:owner/repo#main;cmd runs cmd.
  • Not flagged, same pattern: restoring from the lock file builds git checkout ${entry.commit} and --branch ${entry.ref} (plugin-git-handlers.js around lines 438, 850, 1096 and 1112).

Suggested fix: run these with argument arrays instead of a shell, for example execFileSync("git", ["clone", "--depth", "1", ...(ref ? ["--branch", ref] : []), "--", repo, dir]), execFileSync("npm", ["install", name]) and execFileSync("git", ["add", LOCKFILE_PATH]).

Generated plugin imports

  • quartz/cli/plugin-git-handlers.js:308, :328 and quartz/plugins/loader/gitLoader.ts:1075, :1095 escape only some characters in the plugin name they write into generated TypeScript. The same generators also write from "./${pluginName}" with no escaping at all (plugin-git-handlers.js:288/297, gitLoader.ts:1056/1064).

Suggested fix: write the name with JSON.stringify(pluginName) in every generated import.

A false positive for reference quartz/plugins/emitters/componentResources.ts:27 is reported as a weak password hash. It's a truncated sha256 of file content used for cache-busting file names, so there's nothing to change, but a comment there would save other users the same investigation.