T09 · Insecure Skill Coding Practices
- Location
scripts/test-reverse-alias.sh:30- Finding
jq Expression Injection Through Untrusted Alias Input
- Content
View full analysis
Vulnerability Details
File Location:
scripts/test-reverse-alias.sh, lines 30–31
Vulnerability Type: Untrusted input embedded in dynamically constructed jq source code
Risk Level: Mediumbash ALIAS_ID=$(curl -s "https://app.simplelogin.io/api/aliases?page_id=0" \ -H "Authentication: $API_KEY" | jq -r ".aliases[] | select(.email==\"$ALIAS_EMAIL\") | .id")Technical Analysis
ALIAS_EMAILis inserted directly into a double-quoted jq program. Shell quoting prevents direct shell command injection, but it does not ensure that the value remains a jq string literal. An argument containing jq metacharacters and escaped quotation marks can terminate the intended comparison and inject additional jq filter expressions.Because jq exposes operations such as environment access through
env, injected expressions may read environment variables available to the script. An attacker can also manipulate the resultingALIAS_ID, potentially causing the subsequent authenticated request to operate on a different alias belonging to the same SimpleLogin account.No validation is performed to ensure that the extracted identifier is a single numeric value before it is inserted into the API URL.
Attack Path
- An attacker obtains the ability to control the first command-line argument passed to
test-reverse-alias.sh. - The attacker supplies an alias containing quotation marks and jq syntax that terminates the intended
.emailcomparison. - The script interpolates that value into the jq program.
- jq evaluates the injected expression rather than treating the entire argument as inert email-address data.
- The expression can alter the selected alias identifier or access environment values.
- The resulting output is assigned to
ALIAS_IDand used in the authenticated contact-creation request.
Impact Assessment
Exploitation occurs with the privileges and environment of the user running the script. I ...[truncated 527 chars]
- An attacker obtains the ability to control the first command-line argument passed to
- Remediation
View remediation
Remediation Suggestions
Pass the alias as jq data through
--arginstead of constructing jq source code dynamically:bash ALIAS_ID=$( curl --fail-with-body --silent --show-error \ "https://app.simplelogin.io/api/aliases?page_id=0" \ -H "Authentication: $API_KEY" | jq -r --arg alias "$ALIAS_EMAIL" \ '.aliases[] | select(.email == $alias) | .id' )Apply the following additional controls:
- Validate
ALIAS_EMAILas an email address before using it. - Require
ALIAS_IDto match^[0-9]+$. - Reject output containing multiple identifiers.
- Use
curl --fail-with-body --silent --show-errorso HTTP failures are not processed as valid API responses. - Handle jq parse failures explicitly rather than relying only on an empty-result check.
- Validate
