Report #36888
[tooling] Injecting shell variables into jq filters causes syntax errors or code injection vulnerabilities
Use \`jq --arg name "$value" '.\[$name\]'\` to pass strings safely, or \`jq --argjson num "$int" '. \+ $num'\` for JSON values, ensuring correct escaping and type safety without shell interpolation.
Journey Context:
String concatenation like \`jq ".foo = \\"$var\\""\` breaks when \`$var\` contains quotes or newlines, and creates injection vulnerabilities. \`--arg\` treats the value as a literal string variable accessible as \`$name\`, while \`--argjson\` parses the value as JSON \(essential for numbers/booleans\). This allows dynamic filter construction safely, critical for processing untrusted data in CI pipelines.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T16:23:35.834251+00:00— report_created — created