T09 · Insecure Skill Coding Practices
- Location
SKILL.md:14- Finding
LLM API Key and Sensitive Agent Context Sent to an Unrestricted Endpoint
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 14–38
Vulnerability Type: Sensitive credential and context disclosure
Risk Level: HighVulnerable Code
markdown Make an HTTP POST request to the mlayer-guard API: **Endpoint:** The value of the MLAYER_GUARD_URL environment variable. **Headers:** - `Content-Type: application/json` - `X-API-Key: <your LLM API key>` (uses your own key for detection) - `X-Model: <model-id>` (optional, defaults to gpt-4o-mini) - `X-Base-URL: <provider-url>` (optional, for non-OpenAI providers) **Body:** ```json { "system_prompt": "You are a helpful assistant.", "user_task": "<what the user originally asked for>", "retrieved_docs": [ { "doc_id": "<tool-name>", "content": "<the tool output to check>", "source": "tool", "trust_tier": "untrusted" } ] }text ### Technical Analysis The Skill directs the Agent to send an LLM API key in the `X-API-Key` header to the URL stored in `MLAYER_GUARD_URL`. It does not specify an approved host, require HTTPS, authenticate the destination, or define certificate, redirect, and domain-validation requirements. The same request includes the original user task, system prompt, tool name, and complete tool output. Tool output may contain email content, private files, database records, API responses, authentication material, personal information, or proprietary data. Consequently, the procedure creates a direct network exfiltration channel for both credentials and operational context. Supplying a general-purpose LLM provider key to an intermediary also exceeds least privilege. A dedicated, narrowly scoped detector credential would be safer. Although remote analysis may be part of the declared detection functionality, transmitting the full unredacted content and the user's own provider credential is not the minimum access required to ...[truncated 1522 chars]- Remediation
View remediation
Remediation Suggestions
- Do not send the user's general-purpose LLM API key to the guard service. Use a dedicated, revocable, least-privilege service token restricted to the detection operation.
- Prefer local prompt-injection analysis so credentials and content do not leave the execution environment.
- If remote processing is necessary, pin the integration to an explicit allowlist of documented HTTPS origins rather than accepting an unrestricted environment-provided URL.
- Reject plaintext HTTP, unexpected ports, redirects to unapproved domains, invalid certificates, and URLs containing embedded credentials.
- Minimize the request body. Do not transmit the full system prompt or original user request unless strictly necessary.
- Redact API keys, authorization headers, cookies, access tokens, personal data, and other secrets from tool output before transmission.
- Require informed user or administrator consent before transmitting content to a third party, and document data retention, access, processing, and deletion policies.
- Apply payload-size limits and field-level schemas to prevent accidental bulk disclosure.
- Use outbound network controls to ensure requests can reach only the approved detection service.
- Rotate any API key that may already have been disclosed through this workflow.
