Back to skill

Security audit

Brain Tease Game

Security checks for vulnerabilities and agentic risk

Overview

The skill is mostly a brain-teaser game, but it can automatically reuse credentials from agent configuration files and has avoidable local file-safety issues.

Review this skill before installing. It is not clearly malicious, but you should avoid using it in an environment with Claude/OpenClaw credentials unless the credential-loading behavior is removed or limited to BRAIN_TEASER_API_KEY, and the diagnostic config print and session ID path handling are fixed.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (2)

T09 · Insecure Skill Coding Practices

Warning
Location
ai_generator.py:91
Finding

Automatic Reuse and Cleartext Logging of External API Credentials

Content
View full analysis

Vulnerability Details

File Location: ai_generator.py:91-101, 228-232
Vulnerability Type: Sensitive credential exposure and excessive credential access
Risk Level: Medium

Vulnerable Code

python
# 2. Read Claude Code configuration
claude_settings_path = Path.home() / ".claude" / "settings.json"
if claude_settings_path.exists():
    try:
        with open(claude_settings_path, 'r', encoding='utf-8') as f:
            settings = json.load(f)

        env = settings.get('env', {})
        if env.get('ANTHROPIC_AUTH_TOKEN'):
            return {
                'api_key': env['ANTHROPIC_AUTH_TOKEN'],
                'base_url': env.get('ANTHROPIC_BASE_URL'),
                'model': env.get('ANTHROPIC_MODEL', 'glm-4-flash')
            }
    except (json.JSONDecodeError, KeyError):
        pass
python
generator = AIQuestionGenerator()

if generator.is_available():
    print(f"API configuration: {generator.config}")
    print(f"Available model: {generator.config.get('model')}")

The configuration is subsequently supplied to the API client:

python
self.client = OpenAI(
    api_key=self.config['api_key'],
    base_url=self.config['base_url']
)

Technical Analysis

When the dedicated BRAIN_TEASER_API_KEY variable is absent, the Skill automatically reads ~/.claude/settings.json and reuses ANTHROPIC_AUTH_TOKEN. This credential belongs to another application's configuration and is accessed without a separate, explicit opt-in for credential sharing.

More critically, the module's executable test path prints the entire generator.config dictionary. Because that dictionary contains the unredacted api_key, directly executing ai_generator.py writes the credential to standard output. Standard output may be retained in shell history captures, CI logs, agent transcripts, debugging systems, or centralized logging infrastructure.

The discovered cred ...[truncated 1709 chars]

Remediation
View remediation

Remediation Suggestions

  1. Remove automatic reuse of ANTHROPIC_AUTH_TOKEN. By default, accept only the Skill-specific BRAIN_TEASER_API_KEY.
  2. If importing another application's credentials is required, place it behind an explicit configuration option and obtain clear user consent.
  3. Never print the complete configuration dictionary. Log only non-sensitive fields and redact secrets, for example:
    python
    safe_config = {
        "base_url": generator.config.get("base_url"),
        "model": generator.config.get("model"),
        "api_key": "[REDACTED]"
    }
    print(f"API configuration: {safe_config}")
    
  4. Remove or isolate executable diagnostic code from production packages.
  5. Permit only explicitly configured, trusted API endpoints and require HTTPS except for a clearly enabled loopback-only development mode.
  6. Validate endpoint hostnames against an allowlist where deployments have a fixed provider.
  7. Rotate any credential that may already have appeared in logs and purge affected logs according to the applicable retention policy.

T09 · Insecure Skill Coding Practices

Warning
Location
session.py:93
Finding

Path Traversal Through Unvalidated Session Identifiers

Content
View full analysis

Vulnerability Details

File Location: session.py:93-108, 130-134
Vulnerability Type: Path traversal and unsafe file access
Risk Level: Medium

Vulnerable Code

python
def get_session(self, session_id: str) -> Optional[Session]:
    """
    Get a session.

    Args:
        session_id: Session ID

    Returns:
        Session object or None
    """
    session_file = SESSIONS_DIR / f"{session_id}.json"
    if not session_file.exists():
        return None

    try:
        with open(session_file, 'r', encoding='utf-8') as f:
            data = json.load(f)
        return Session.from_dict(data)
    except (json.JSONDecodeError, KeyError):
        return None

The same unsafe path construction is present in the deletion method:

python
def delete_session(self, session_id: str) -> None:
    """Delete a session."""
    session_file = SESSIONS_DIR / f"{session_id}.json"
    if session_file.exists():
        session_file.unlink()

Technical Analysis

session_id is controlled by CLI input in commands such as answer, hint, reveal, next, status, and interactive. It is directly interpolated into a path without validating that it is an eight-character hexadecimal identifier and without confirming that the resolved path remains beneath SESSIONS_DIR.

pathlib.Path does not automatically prevent traversal. A value containing components such as ../../../target produces a path equivalent to:

text
~/.cache/brain-teaser/sessions/../../../target.json

The operating system resolves the .. components, allowing the process to address JSON files outside the intended session directory.

Through currently exposed commands, a traversed file must contain JSON compatible with the Session data structure to be successfully interpreted. If it does, selected fields can be returned by status or game-output functions. Unexpected but valid JSON struct ...[truncated 2016 chars]

Remediation
View remediation

Remediation Suggestions

  1. Strictly validate every externally supplied session identifier before constructing a path:
    python
    import re
    
    SESSION_ID_PATTERN = re.compile(r"^[0-9a-f]{8}$")
    
    def validate_session_id(session_id: str) -> None:
        if not SESSION_ID_PATTERN.fullmatch(session_id):
            raise ValueError("Invalid session ID")
    
  2. Apply the validation consistently in get_session, update_session, _save_session, and delete_session.
  3. Add defense-in-depth containment checks:
    python
    base = SESSIONS_DIR.resolve()
    session_file = (base / f"{session_id}.json").resolve()
    
    if session_file.parent != base:
        raise ValueError("Session path escapes storage directory")
    
  4. Reject all path separators, absolute paths, . components, and .. components.
  5. Validate loaded JSON against the expected schema before constructing a Session.
  6. Catch schema-related exceptions such as TypeError and ValueError, while logging only non-sensitive diagnostic information.
  7. Add regression tests covering ../, absolute paths, encoded separators, excessive-length identifiers, malformed JSON, and valid JSON with an incompatible schema.
  8. Keep delete_session inaccessible to untrusted input until the same validation and containment controls are implemented.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Memory PoisoningPersistent Context Injection, Context Window Stuffing, Memory Manipulation
  • Rogue AgentSelf-Modification, Session Persistence
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
Findings (50)

Agent Config Directory Access

High
Category
Agent Snooping
Confidence
90% confidence
Finding

Skill reads from agent configuration directories (.claude/, .codex/, .gemini/). These directories may contain API keys, personal settings, and other credentials that the skill has no legitimate need to access.

Content

Scanner excerpt · README.md (reported line 137)May include surrounding context.

md
### 配置读取优先级

1. 环境变量 `BRAIN_TEASER_API_KEY`
2. `~/.claude/settings.json`
3. `~/.openclaw/openclaw.json`

### 支持的 API

Agent Config Directory Access

High
Category
Agent Snooping
Confidence
90% confidence
Finding

Skill reads from agent configuration directories (.claude/, .codex/, .gemini/). These directories may contain API keys, personal settings, and other credentials that the skill has no legitimate need to access.

Content

Scanner excerpt · README.md (reported line 339)May include surrounding context.

md
### 配置读取优先级

1. 环境变量 `BRAIN_TEASER_API_KEY`
2. `~/.claude/settings.json`
3. `~/.openclaw/openclaw.json`

### 支持的 API

Agent Config Directory Access

High
Category
Agent Snooping
Confidence
90% confidence
Finding

Skill reads from agent configuration directories (.claude/, .codex/, .gemini/). These directories may contain API keys, personal settings, and other credentials that the skill has no legitimate need to access.

Content

Scanner excerpt · README.md (reported line 541)May include surrounding context.

md
### 配置读取优先级

1. 环境变量 `BRAIN_TEASER_API_KEY`
2. `~/.claude/settings.json`
3. `~/.openclaw/openclaw.json`

### 支持的 API

Agent Config Directory Access

High
Category
Agent Snooping
Confidence
90% confidence
Finding

Skill reads from agent configuration directories (.claude/, .codex/, .gemini/). These directories may contain API keys, personal settings, and other credentials that the skill has no legitimate need to access.

Content

Scanner excerpt · ai_generator.py (reported line 246)May include surrounding context.

python
### 配置读取优先级

1. 环境变量 `BRAIN_TEASER_API_KEY`
2. `~/.claude/settings.json`
3. `~/.openclaw/openclaw.json`

### 支持的 API

Memory Manipulation

High
Category
Memory Poisoning
Confidence
80% confidence
Finding

Skill manipulates agent memory, state, or stored context. Memory corruption can alter personality, override safety rules, or cause unpredictable behavior.

Content

Scanner excerpt · README.md (reported line 294)May include surrounding context.

md
./invoke.sh interactive <session_id> "hint"
./invoke.sh interactive <session_id> "your answer"

# Reset history
./invoke.sh reset-history

# Check status

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The documented purpose understates sensitive behavior by omitting that the skill may read agent config files, consume credentials, and send data to an external LLM-compatible API. That mismatch prevents informed consent and can lead users to expose secrets or local context to external services unexpectedly.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

The documented purpose understates sensitive behavior by omitting that the skill may read agent config files, consume credentials, and send data to an external LLM-compatible API. That mismatch prevents informed consent and can lead users to expose secrets or local context to external services unexpectedly.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The documented purpose understates sensitive behavior by omitting that the skill may read agent config files, consume credentials, and send data to an external LLM-compatible API. That mismatch prevents informed consent and can lead users to expose secrets or local context to external services unexpectedly.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

The documented purpose understates sensitive behavior by omitting that the skill may read agent config files, consume credentials, and send data to an external LLM-compatible API. That mismatch prevents informed consent and can lead users to expose secrets or local context to external services unexpectedly.

Content

No source excerpt is available for this finding.

Agent Config Directory Access

High
Category
Agent Snooping
Confidence
94% confidence
Finding

The skill documents reading credentials from ~/.claude/settings.json and ~/.openclaw/openclaw.json, which are agent/client configuration locations that may contain secrets or unrelated settings. Accessing these files for a game skill broadens secret exposure and creates a path for over-collection beyond what the feature strictly needs.

Content

Scanner excerpt · SKILL.md (reported line 86)May include surrounding context.

md
API 配置读取优先级:
1. 环境变量 `BRAIN_TEASER_API_KEY`
2. `~/.claude/settings.json`
3. `~/.openclaw/openclaw.json`

---

Memory Manipulation

High
Category
Memory Poisoning
Confidence
80% confidence
Finding

A reset-history command modifies stored session/history state and can erase safeguards such as no-repeat tracking or auditability of prior interactions. In isolation this is an admin-like feature, but without access controls or confirmation it can be invoked accidentally or abusively to manipulate memory/state.

Content

Scanner excerpt · SKILL.md (reported line 139)May include surrounding context.

./invoke.sh interactive {session_id} "hint" ./invoke.sh interactive {session_id} "your answer"

Reset history

./invoke.sh reset-history

text

Agent Config Directory Access

High
Category
Agent Snooping
Confidence
94% confidence
Finding

As in the Chinese section, the English documentation specifies reading agent config directories for API credentials. For a brain-teaser skill, that context makes the behavior less justifiable and more dangerous because the capability is unrelated to core gameplay and may expose stored secrets.

Content

Scanner excerpt · SKILL.md (reported line 164)May include surrounding context.

md
API configuration priority:
1. Environment variable `BRAIN_TEASER_API_KEY`
2. `~/.claude/settings.json`
3. `~/.openclaw/openclaw.json`

---

Agent Config Directory Access

High
Category
Agent Snooping
Confidence
94% confidence
Finding

The Japanese section repeats the same config-directory access behavior, confirming it is a designed capability rather than an isolated documentation artifact. Shared config access increases the blast radius if the skill or its prompts are ever abused, because other agent secrets may reside there.

Content

Scanner excerpt · SKILL.md (reported line 242)May include surrounding context.

md
API設定の優先順位:
1. 環境変数 `BRAIN_TEASER_API_KEY`
2. `~/.claude/settings.json`
3. `~/.openclaw/openclaw.json`

---

Agent Config Directory Access

High
Category
Agent Snooping
Confidence
99% confidence
Finding

Access to ~/.claude/settings.json is highly sensitive because it may expose tokens, model configuration, and endpoint details from another agent environment. A brain teaser skill has no legitimate need to inspect that directory, so this is an unjustified expansion of privilege and trust boundary crossing.

Content

Scanner excerpt · ai_generator.py (reported line 76)May include surrounding context.

python
优先级:
        1. 环境变量 BRAIN_TEASER_API_KEY
        2. Claude Code 配置 ~/.claude/settings.json
        3. OpenClaw 配置 ~/.openclaw/openclaw.json

        Returns:

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

Reading ~/.claude/settings.json and ~/.openclaw/openclaw.json gives this game access to unrelated user credentials and local service configuration. That behavior creates unauthorized cross-context secret use and could route requests through a user’s existing AI account or local gateway without clear approval.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The optional AI generation feature documents API key configuration and third-party provider support, but it does not warn that user prompts, answers, or gameplay context may be transmitted to external services. In a game skill this can still expose user-entered content and metadata to providers the user may not expect.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
50% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · README.md (reported line 130)May include surrounding context.

bash
# 环境变量配置
export BRAIN_TEASER_API_KEY=your-api-key
export BRAIN_TEASER_API_BASE=https://api.example.com/v1  # 可选
export BRAIN_TEASER_MODEL=gpt-4  # 可选

External Transmission

Medium
Category
Data Exfiltration
Confidence
50% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · README.md (reported line 332)May include surrounding context.

bash
# 环境变量配置
export BRAIN_TEASER_API_KEY=your-api-key
export BRAIN_TEASER_API_BASE=https://api.example.com/v1  # 可选
export BRAIN_TEASER_MODEL=gpt-4  # 可选

External Transmission

Medium
Category
Data Exfiltration
Confidence
50% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · README.md (reported line 534)May include surrounding context.

bash
# 环境变量配置
export BRAIN_TEASER_API_KEY=your-api-key
export BRAIN_TEASER_API_BASE=https://api.example.com/v1  # 可选
export BRAIN_TEASER_MODEL=gpt-4  # 可选

Session Persistence

Medium
Category
Rogue Agent
Confidence
60% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · README.md (reported line 416)May include surrounding context.

md
Issues and Pull Requests are welcome!

1. Fork this repository
2. Create feature branch (`git checkout -b feature/amazing-feature`)
3. Commit changes (`git commit -m 'Add amazing feature'`)
4. Push to branch (`git push origin feature/amazing-feature`)
5. Create Pull Request

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
90% confidence
Finding

The manifest does not declare tool scope even though the documented behavior includes reading environment variables, reading local config files, persisting history, and optional external API use. Missing explicit permissions weakens reviewability and can cause the skill to run with broader capabilities than users expect.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

Free-form interactive intent detection can misclassify ordinary user text as commands such as reveal or next, causing unintended state changes or answer disclosure. In agent settings, ambiguous command parsing also increases prompt-injection and command-confusion risk because arbitrary text doubles as control input.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
85% confidence
Finding

The optional AI generation feature implies outbound transmission to an external API endpoint. External transmission is not inherently malicious, but in this context it becomes a security issue because the documentation lacks strong disclosure about what user content may be sent and because the skill is presented primarily as a local game.

Content

Scanner excerpt · SKILL.md (reported line 80)May include surrounding context.

bash
export BRAIN_TEASER_API_KEY=your-api-key
export BRAIN_TEASER_API_BASE=https://api.example.com/v1  # 可选
export BRAIN_TEASER_MODEL=gpt-4  # 可选

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
86% confidence
Finding

A broad natural-language start trigger overlaps with normal conversation and may cause the skill to activate unexpectedly. Unintended activation matters more here because the skill also documents file/config access and optional external API use, expanding the consequences of accidental invocation.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The README describes credential-based AI generation but does not warn that prompts, question context, and possibly user inputs may be sent to an external service. Without a clear disclosure, users cannot make an informed privacy decision, and sensitive content could be transmitted off-device unexpectedly.

Content

No source excerpt is available for this finding.