T09 · Insecure Skill Coding Practices
- Location
references/list-coupons.md:67- Finding
Command Injection Through Unvalidated Coupon Timestamp Interpolation
- Content
View full analysis
Vulnerability Details
File Location:
references/list-coupons.md:67-69
Vulnerability Type: Command injection through untrusted MCP response interpolation
Risk Level: MediumVulnerable Code
markdown - `Expires (Remaining)`: format as `YYYY-MM-DD (UTC) ({X} days)`. Use `< 1 day` when less than 24 hours remain. Use `Expired` if already past. The `expire_time_order_by` value is a Unix timestamp (seconds since epoch) — use a programming tool to convert it to UTC date (e.g. `python3 -c "from datetime import *; print(datetime.fromtimestamp({value}, timezone.utc).strftime('%Y-%m-%d'))"`). Batch all timestamps into a single tool call to avoid repeated invocations.Technical Analysis
The workflow directs the Agent to interpolate the MCP-provided
expire_time_order_byvalue directly into Python source passed topython3 -c. No requirement validates that the value is a bounded integer before interpolation.If the Gate MCP server, its transport, or the upstream response is compromised, an attacker-controlled value can be interpreted as a Python expression rather than timestamp data. For example, a value shaped like
__import__('os').system('ATTACKER_COMMAND') or 0would execute the supplied operating-system command when inserted intodatetime.fromtimestamp({value}, ...).The instruction also conflicts with the tool restrictions in
SKILL.md:33-34andreferences/gate-runtime-rules.md:22-23, which limit the Skill to documented Gate MCP tools and prohibit unrelated system tools. Encouraging a programming tool unnecessarily expands the execution surface beyond the minimum privileges required to display a date.Attack Path
- An attacker compromises or impersonates the Gate MCP service, modifies its response, or otherwise gains influence over
expire_time_order_by. - The service returns a malicious Python expression in place of a numeric Unix timestamp.
- The Agent follows the documented workfl ...[truncated 864 chars]
- An attacker compromises or impersonates the Gate MCP service, modifies its response, or otherwise gains influence over
- Remediation
View remediation
Remediation Suggestions
- Remove the instruction to invoke
python3, a shell, or another general-purpose programming tool for timestamp conversion. - Use a trusted, non-executable runtime date-formatting operation that treats the timestamp strictly as data.
- Validate
expire_time_order_bybefore conversion:- Require an integer-only value.
- Reject strings, expressions, and unexpected types.
- Enforce a reasonable Unix timestamp range.
- If an external conversion tool is unavoidable, pass the timestamp through a typed argument or standard input rather than interpolating it into source code.
- Keep the workflow within the two documented Gate MCP tools and the platform's built-in formatting capabilities.
- Add explicit handling for invalid timestamps and return an unavailable or malformed-data indicator rather than attempting execution.
- Remove the instruction to invoke
