T09 · Insecure Skill Coding Practices
- Location
references/auth.md:78- Finding
Bearer Token Persisted in Agent Memory Without Secret-Storage Protections
- Content
View full analysis
Vulnerability Details
File Location:
references/auth.md:78-106
Vulnerability Type: Plaintext persistent credential storage
Risk Level: MediumVulnerable Code Snippet
text Step 3: Save credentials to memory Option one: - Save only the token to memory. Option two: - Save the identity ID to memory immediately. - Save the token to memory. - Reuse the same identity ID to obtain a new token after expiration. { "zhangben_token": "USER_PROVIDED_TOKEN", "auth_method": "wechat" } { "zhangben_identity_id": "32_CHARACTER_IDENTITY_ID", "zhangben_token": "API_OBTAINED_TOKEN", "auth_method": "api" }The same requirement is summarized in
SKILL.md:22, which directs the agent to save the identity identifier and token to memory after authentication.Technical Analysis
The Skill explicitly instructs the agent to place a bearer token in persistent memory or configuration. The documentation does not require an operating-system credential vault, encryption at rest, access controls, token redaction, or a defined retention policy.
A bearer token grants access based on possession. Consequently, any user, process, extension, agent, or later session that can read the shared memory may be able to impersonate the account. The identity identifier is also persisted for API-based authentication, increasing the amount of reusable authentication material exposed through the same storage channel.
This is an insecure secret-management practice rather than agent memory poisoning: the stored values are credentials, not attacker-controlled behavioral rules.
Attack Path
- A user authenticates through either the WeChat-token or API-token method.
- The agent saves
zhangben_tokenin persistent memory as instructed. - An attacker obtains read access to the agent's memory, configuration, backup, diagnostic output, or another session sharing that state.
- The attacker extracts th ...[truncated 944 chars]
- Remediation
View remediation
Remediation Suggestions
- Never store raw bearer tokens in conversational or general-purpose agent memory.
- Use an operating-system-backed credential vault or a dedicated MCP secret facility with per-Skill access controls.
- Store only an opaque credential reference in agent memory.
- Encrypt credentials at rest and restrict access to the minimum process identity.
- Ensure tokens are short-lived, narrowly scoped, revocable, and rotated after suspected disclosure.
- Redact tokens from prompts, tool output, logs, traces, exceptions, backups, and diagnostic reports.
- Provide an explicit logout operation that revokes the server-side token and deletes all local credential material.
- Document token expiration, scope, retention, and deletion behavior.
- Avoid storing the reusable identity identifier beside the token; if it must be retained, protect it as authentication material.
