Back to skill

Security audit

Grok Image Generation

Security checks for vulnerabilities and agentic risk

Overview

This is a coherent xAI image-generation skill, but its edit command can upload any readable local file to xAI without checking that it is really an image.

Review before installing. Use this only with trusted prompts and explicitly chosen image files, avoid sensitive workspaces or paths containing secrets, and consider requiring image validation, file-size limits, workspace/path restrictions, and a clear upload disclosure before allowing edit mode.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/grok_imagine.py:38
Finding

Arbitrary Local File Disclosure Through Unvalidated Image Upload

Content
View full analysis
dict: data = json.dumps(payload).encode("utf-8") req = request.Request( url, data=data, headers={ "Authorization": f"Bearer {api_key}", "Content-Type": "application/json", }, method="POST", ) try: with request.urlopen(req, timeout=300) as resp: return json.loads(resp.read().decode("utf-8", errors="replace")) except error.HTTPError as e: body = e.read().decode("utf-8", errors="replace") raise RuntimeError(f"HTTP {e.code}: {body}") except error.URLError as e: raise RuntimeError(f"Request failed: {e}") def image_to_data_uri(path: Path) -> str: mime, _ = mimetypes.guess_type(path.name) if not mime: mime = "image/png" raw = path.read_bytes() return f"data:{mime};base64,{base64.b64encode(raw).decode('ascii')}" ``` ```python def build_edit_image_payload(paths: list[str], urls: list[str]) -> list[dict] | dict: refs: list[dict] = [] for p in paths: uri = image_to_data_uri(Path(p)) refs.append({"url": uri, "type": "image_url"}) for u in urls: refs.append({"url": u, "type": "image_url"}) if not refs: raise RuntimeError("Provide at least one --image or --image-url for edit mode") if len(refs) == 1: return refs[0] if len(refs) > 3: raise RuntimeError("xAI image edit supports up to 3 source images") return refs def cmd_edit(args) -> int: image_payload = build_edit_image_payload(args.image or [], args.image_url or []) payload = { "model": args.model, "prompt": args.prompt, "image": image_payload, "n": args ...[truncated 3082 chars]
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (6)

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
91% confidence
Finding

The skill instructs use of environment variables, local file I/O, and outbound network access to xAI, but it does not declare any explicit tool scope or permissions in the skill metadata. That makes the skill's capabilities under-specified, reducing reviewability and increasing the chance of unintended access to sensitive files, secrets, or network destinations when the skill is invoked.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The skill supports editing and variation workflows using local source images, but the description does not clearly warn that those images may be uploaded to xAI for processing. This creates a privacy and data-handling risk because users may provide sensitive, proprietary, or personal images without informed consent about third-party transmission.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
60% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · references/api-reference.md (reported line 6)May include surrounding context.

md
from pathlib import Path
from urllib import request, error

BASE_URL = "https://api.x.ai/v1"
DEFAULT_MODEL = "grok-imagine-image-quality"

External Transmission

Medium
Category
Data Exfiltration
Confidence
60% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · scripts/grok_imagine.py (reported line 12)May include surrounding context.

python
from pathlib import Path
from urllib import request, error

BASE_URL = "https://api.x.ai/v1"
DEFAULT_MODEL = "grok-imagine-image-quality"

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The script posts user-supplied prompts to the xAI image generation endpoint, and in edit mode it can also transmit local image contents after base64 encoding. Although the API usage is functionally implied by the tool's purpose, the code lacks an explicit disclosure in comments, help text, or runtime output that user content is sent to a remote service.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
78% confidence
Finding

The script automatically creates an output directory and writes generated images and full API response metadata to local files. While saving outputs is consistent with the tool's purpose, there is no clear warning in comments or CLI help that multiple files, including a response JSON, will be created on disk.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.