Skip to content

Security Advisory: Prompt Injection Risk via Fetched UI Component Code #46

@joergmichno

Description

@joergmichno

Summary

magic-mcp fetches external UI component code (similar to shadcn) and injects it into AI coding assistants (Cursor, Windsurf, Cline). When fetched component code contains attacker-crafted content, prompt injection payloads embedded in code comments, variable names, or documentation strings can hijack the AI assistant's behavior.

Attack Vector

  1. Attacker publishes a UI component with prompt injection hidden in code comments or documentation
  2. Developer's AI assistant fetches the component via magic-mcp → injected content enters the LLM context
  3. Injection instructs the AI to introduce backdoors, exfiltrate environment variables, or modify other project files

Impact

  • Code Backdoor Injection: AI inserts malicious code into the developer's project (data exfiltration, reverse shells, credential theft)
  • Supply Chain Attack: A single malicious component can compromise every project that uses magic-mcp to fetch it
  • Environment Variable Exfiltration: Injection could instruct the AI to read and expose .env files, API keys, or signing credentials
  • Silent Compromise: Injected code modifications may be subtle enough to pass code review

OWASP Classification

  • OWASP LLM Top 10: LLM01 (Prompt Injection)
  • OWASP Agentic Top 10: AG01 (Prompt Injection via Tool Results), AG07 (Supply Chain Vulnerability)

Recommendation

  1. Add a Security Warning to the README about the risks of fetching external code into AI context
  2. Implement code content sanitization before passing to LLM
  3. Add integrity checks (checksums, signatures) for fetched components
  4. Consider a curated/verified component registry with security reviews

References


Free compliance check: Run your own prompts through our EU AI Act compliance scanner — instant results, no account required: prompttools.co/report

Best,
Joerg Michno
ClawGuard — Open-Source AI Agent Security | 225 patterns, 15 languages

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions