T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/validate_env.py:209
- Finding
- Generated schemas store sensitive environment values in plaintext## Vulnerability Details **File Location**: `scripts/validate_env.py:209-213` **Vulnerability Type**: Plaintext disclosure of sensitive configuration values **Risk Level**: High ### Vulnerable Code ```python var_def = { 'type': var_type, 'required': True, } if value: var_def['example'] = value if any(s in key.upper() for s in ['SECRET', 'PASSWORD', 'KEY', 'TOKEN', 'API_KEY']): var_def['sensitive'] = True schema['variables'][key] = var_def ``` ### Technical Analysis Schema generation copies every nonempty environment value into the schema's `example` field. This occurs before or independently of the sensitive-key classification. Setting `sensitive` to `True` only adds metadata and does not redact, omit, or encrypt the value. Consequently, variables such as `DATABASE_PASSWORD`, `API_KEY`, `ACCESS_TOKEN`, and connection strings containing credentials are written verbatim to generated schema output. The documented workflow in `SKILL.md` advises users to generate a schema from a working `.env` file and add that schema to a repository, making accidental credential publication a realistic outcome. ### Attack Path 1. A working `.env` file contains active passwords, API keys, tokens, or credential-bearing connection strings. 2. The user follows the documented workflow and runs: ```bash python3 scripts/validate_env.py --generate-schema .env -o env-schema.json ``` 3. `generate_schema()` copies each populated value into the corresponding `example` property. 4. The generated schema is committed to source control, uploaded as a CI artifact, or shared with another party. 5. Anyone able to access that artifact can recover the credentials in plaintext and use them against the associated services. ### Impact Assessment This issue compromises the confidentiality of every populated value in the input `.env` file. An attacker does not gain local privilege escalation through the validator itse ...[truncated 429 chars]
- Remediation
- ## Remediation Suggestions - Never copy the value of a sensitive variable into an auto-generated schema. - Determine sensitivity before assigning the `example` field and omit that field for sensitive variables: ```python sensitive = any( marker in key.upper() for marker in ['SECRET', 'PASSWORD', 'KEY', 'TOKEN', 'API_KEY'] ) var_def['sensitive'] = sensitive if value and not sensitive: var_def['example'] = value ``` - Prefer neutral placeholders such as `REDACTED` or `your-secret-here` only if an example is required. - Expand sensitive-key detection to cover common names such as `CREDENTIAL`, `PRIVATE`, `AUTH`, and credential-bearing connection strings. - Display a warning that generated schema files must be reviewed before being committed or shared. - Document that schemas should be generated from sanitized template files such as `.env.example`, not production `.env` files. - Add tests confirming that generated schema output never contains known secret fixture values. - If affected schemas have already been published, remove them from repository history and artifact storage, then rotate all exposed credentials.
