T09 · Insecure Skill Coding Practices
- Location
SKILL.md:30- Finding
API Credential Persisted in a Predictable Plaintext Configuration File
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, line 30
Vulnerability Type: Plaintext sensitive-data storage
Risk Level: MediumVulnerable Code Snippet
markdown - `apiKey`: 先确认 `ZNOPEN_API_KEY` 已可用;默认从 `~/.znopen/config.json` 读取,缺失时先提示用户提供,提供后回填文件,完成配置。English translation: Confirm that
ZNOPEN_API_KEYis available; read it from~/.znopen/config.jsonby default. If it is missing, ask the user to provide it and write it back to that file.Technical Analysis
The Skill instructs the agent to persist a bearer API credential in the predictable file
~/.znopen/config.json. It does not require an operating-system credential store, encryption at rest, owner-only permissions, ownership verification, symbolic-link protection, or safe atomic file creation.Consequently, the credential may be exposed to other local users or processes when the file or its parent directory has permissive access controls. It may also be captured in home-directory backups or accidentally disclosed with configuration files. Because the credential is used as a bearer token, possession may be sufficient to authenticate requests to the declared service.
Exploitation depends on the attacker first obtaining local read access or access to a copy of the configuration file; the instruction does not itself grant such access.
Attack Path
- A user invokes the Skill without an existing API-key configuration.
- The Skill asks the user for
ZNOPEN_API_KEY. - Following the documented behavior, the agent writes the credential to
~/.znopen/config.json. - The file is created or retained without an explicit requirement for restrictive permissions or secure secret storage.
- An attacker with local filesystem access, access through another compromised process, or access to a leaked backup reads the configuration file.
- The attacker extracts the API key and submits requests with
Authorization: Bearer {ApiKey}to the declared platform endpoint.
Impact A
...[truncated 459 chars]
- Remediation
View remediation
Remediation Suggestions
- Prefer an operating-system credential manager or a dedicated secrets-management service instead of a plaintext JSON file.
- Support ephemeral secret injection through a protected environment or runtime secret facility where appropriate.
- If file-based storage is unavoidable:
- Create
~/.znopenwith owner-only permissions. - Create
config.jsonwith mode0600. - Verify that both the directory and file are owned by the current user.
- Reject symbolic links and unexpected non-regular files.
- Use secure, atomic file creation to avoid race conditions.
- Refuse to read the credential when permissions are overly broad.
- Create
- Never print the API key in standard output, error messages, traces, or logs, and redact it from diagnostic data.
- Avoid collecting the key through channels that retain conversational history when a secure secret-input mechanism is available.
- Document key rotation and revocation procedures and recommend narrowly scoped, short-lived credentials where supported.
- Exclude the configuration file from source control, shared archives, and unencrypted backups.
