T09 · Insecure Skill Coding Practices
- Location
scripts/vm_api.sh:29- Finding
JSON Injection Through Unescaped VM Creation Arguments
- Content
View full analysis
Vulnerability Details
File Location:
scripts/vm_api.sh, lines 29-39
Vulnerability Type: Improper JSON construction using unescaped user input
Risk Level: HighVulnerable Code
bash create) template_name="${2:-}" vm_name="${3:-}" if [[ -z "$template_name" || -z "$vm_name" ]]; then usage exit 1 fi curl -s -X POST "$NEBULA_CLAW_DEVELOPER_API_BASE/vms" \ -H "Content-Type: application/json" \ -d "{\"template_name\":\"$template_name\",\"name\":\"$vm_name\"}" ;;Technical Analysis
The
template_nameandvm_namecommand-line arguments are interpolated directly into a JSON string without JSON encoding or input validation. Shell quoting prevents ordinary shell command substitution from being re-evaluated, but it does not make the resulting JSON safe.An argument containing quotation marks, backslashes, or JSON delimiters can terminate its intended string value and introduce additional properties. This is especially significant because
references/api.md, lines 24-33, documents optionalone_userandone_passwordfields:json { "template_name": "curated-ubuntu-24-04-for-nebula-claw-developer", "name": "test-nebula-api-2026-04-10", "one_user": "restrictedapi", "one_password": "change-me" }If the server accepts these overrides, injected properties could alter which OpenNebula credentials are used. Even where credential overrides are rejected, an attacker can still produce malformed requests or inject other properties supported by the API.
Attack Path
- An attacker gains the ability to influence either argument supplied to
vm_api.sh create. - The attacker includes JSON syntax in an argument, such as quotation marks followed by additional property names and values.
- The script inserts the argument into the request body without escaping it.
- The API parses the injected properties as part of the request.
- I ...[truncated 1049 chars]
- An attacker gains the ability to influence either argument supplied to
- Remediation
View remediation
Remediation Suggestions
-
Build the request body with a real JSON encoder rather than string interpolation. For example:
bash payload="$( jq -n \ --arg template_name "$template_name" \ --arg name "$vm_name" \ '{template_name: $template_name, name: $name}' )" curl --fail-with-body --silent --show-error \ -X POST "$NEBULA_CLAW_DEVELOPER_API_BASE/vms" \ -H "Content-Type: application/json" \ --data-binary "$payload" -
Validate template and VM names against strict server-compatible patterns and length limits.
-
Enforce the curated template allowlist on the server; client-side validation must not be treated as an authorization boundary.
-
Remove per-request credential override support from production deployments. If testing requires it, place it behind separate authentication and explicit authorization.
-
Configure the server to reject unknown JSON properties and duplicate property names.
-
Add tests using quotation marks, backslashes, control characters, duplicate keys, and nested JSON fragments.
-
