T05 · Unauthorized Access and Privilege Escalation
Warning
- Location
- context.md:84
- Finding
- Agent Guidance Encourages Access to Sensitive Environment Files<![CDATA[ ## Vulnerability Details **File Location**: `context.md`, lines 84-86 **Vulnerability Type**: Sensitive credential-file access beyond least-privilege requirements **Risk Level**: Medium ### Vulnerable Code ```markdown ## Tools - Logs: vercel cli or axiom - DB: psql (see .env for connection) ``` ### Technical Analysis The guidance directs an AI coding agent to inspect `.env` to obtain a database connection. Environment files commonly contain multiple credentials, including database passwords, API tokens, signing keys, and deployment secrets unrelated to the requested database operation. Reading the entire file violates least-privilege principles when only one designated connection variable is required. The guidance does not require the agent to limit access to a specific variable, redact values, avoid displaying secrets, or prevent credentials from entering model context, terminal logs, shell history, or generated responses. The skill itself does not read the file or exfiltrate credentials. Exploitation therefore depends on a downstream agent following this recommendation in a repository containing sensitive environment variables. ### Attack Path 1. A project adopts the suggested agent configuration. 2. The project has a `.env` file containing a database URL and other sensitive credentials. 3. A coding agent receives a database-related task and follows the instruction to inspect `.env`. 4. The agent reads the complete file rather than retrieving only the required variable. 5. Secrets become available in the agent's context and may subsequently appear in terminal output, logs, prompts, generated commands, or responses. 6. Anyone with access to those channels may obtain and misuse the exposed credentials. ### Impact Assessment Potentially exposed privileges are limited to those granted by credentials stored in the environment file. Depending on the project, this could include database access, third-party API access, deployment permissions, or cl ...[truncated 241 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Replace the instruction to inspect `.env` with a reference to a specific environment variable, such as `DATABASE_URL`, without displaying its value. - Explicitly prohibit reading or printing complete `.env` files. - Require a dedicated, least-privilege database account for agent-assisted operations. - Restrict credentials to the exact database, schema, and operations needed for the task. - Use a secret manager or controlled credential-injection mechanism instead of exposing plaintext secrets to the agent. - Require redaction of passwords, tokens, and connection parameters from responses, command output, logs, and screenshots. - Prefer short-lived credentials and rotate any secret that may have entered model context or logs. ]]>
