T05 · Unauthorized Access and Privilege Escalation
- Location
- SKILL.md:103
- Finding
- Mandatory Inspection of Credential-Bearing Files and Environment Variables<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:103-109` **Vulnerability Type**: Sensitive credential access beyond minimum required privileges **Risk Level**: Medium ### Vulnerable Code ```markdown ### Step 1: Check for Trails API Key **BEFORE generating any integration code**, check if the user has a Trails API key: 1. **Search for API key** in: - `.env` files → `TRAILS_API_KEY` or `NEXT_PUBLIC_TRAILS_API_KEY` - Environment variables in the project - Configuration files ``` ### Technical Analysis The Skill requires the agent to inspect `.env` files, project environment variables, and configuration files before generating integration code. These locations commonly contain credentials unrelated to Trails in addition to the named Trails variables. Even if the intended search is limited to `TRAILS_API_KEY` and `NEXT_PUBLIC_TRAILS_API_KEY`, retrieving their values places secret material into the agent's tool output and working context. The values may subsequently appear in transcripts, model-provider telemetry, terminal logs, debugging output, or accidentally generated responses. Reading credential values is not necessary to determine whether a project is ready for integration. The Skill can ask the user whether a key is configured or perform an existence-only check that never returns the value. ### Attack Path 1. The Skill activates for a Trails-related request. 2. Its mandatory workflow directs the agent to inspect `.env`, runtime environment, and configuration files. 3. A tool invocation reads or returns an actual API-key value. 4. The credential enters the agent session, tool logs, or transcript. 5. A later diagnostic, generated configuration, support interaction, or accidental output discloses the credential. 6. Anyone obtaining the key may access Trails APIs within the key's assigned privileges and quota. ### Impact Assessment Potential exposure includes Trails API credentials and, if the search is implemented too broadly ...[truncated 319 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Replace mandatory credential searches with an explicit question asking whether the required variable is configured. 2. If automated checking is needed, perform an existence-only check and never return the value: ```bash if [ -n "${TRAILS_API_KEY+x}" ]; then echo "TRAILS_API_KEY is configured" else echo "TRAILS_API_KEY is not configured" fi ``` 3. Require explicit user consent before inspecting any `.env` or configuration file. 4. Restrict searches to exact variable names and prevent surrounding file contents from being returned. 5. Redact values at the tool boundary before they enter agent context. 6. Document that API keys must never be included in prompts, generated code, logs, or support messages. ]]>
