Back to skill

Security audit

CodeBuddy 每日工作日报生成

Security checks for vulnerabilities and agentic risk

Overview

This skill is a coherent daily-report tool, but it automatically scans broad local work history and raw agent session files without enough scoping or consent.

Review carefully before installing. This skill may expose private repository names, paths, branch names, commit messages, change statistics, and prior CodeBuddy Agent session summaries. Use it only if you are comfortable with home-wide scanning, or modify it to scan only approved directories and disable agent-session collection by default.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • 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)

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
scripts/collect.py:50
Finding

Unrestricted Home-Directory Repository Discovery Violates Least Privilege

Content
View full analysis

Vulnerability Details

File Location: scripts/collect.py:50-53, scripts/collect.py:187-231, and scripts/collect.py:510-530
Vulnerability Type: T05: Unauthorized Access and Privilege Escalation
Risk Level: Medium

Vulnerable Code

python
def get_default_search_dirs() -> list:
    """
    Return search directories. Strategy: scan the ENTIRE home directory.
    No hardcoded guessing — we find ALL repos wherever they are,
    including hidden directories like .qclaw, .gongfeng-copilot, etc.
    """
    home = get_home()
    dirs = [home]  # Start from HOME, the script will walk into all subdirs
python
def discover_repos(search_dirs: list, exclude_dirs: set, max_depth: int) -> list:
    """
    Walk through search directories and find ALL git repositories,
    including those in hidden directories (e.g. .qclaw, .gongfeng-copilot).
    Cross-platform, uses os.walk instead of shell commands.
    """
    repos = []
    seen = set()

    # Merge user-configured excludes with global excludes
    all_excludes = GLOBAL_EXCLUDE_DIRS | exclude_dirs

    for search_dir in search_dirs:
        search_dir = Path(search_dir)
        if not search_dir.is_dir():
            continue

        base_depth = len(search_dir.parts)

        for root, dirs, _files in os.walk(str(search_dir)):
            root_path = Path(root)
            current_depth = len(root_path.parts) - base_depth

            # Prune depth
            if current_depth >= max_depth:
                dirs.clear()
                continue

            # Check if this directory is a git repo
            if ".git" in dirs:
                try:
                    repo_path = root_path.resolve()
                except OSError:
                    continue
                repo_key = str(repo_path)
                if repo_key not in seen:
                    seen.add(repo_key)
                    repos.append(repo_path)
                # Don't recurse deeper into this repo's subdirs
  
...[truncated 3277 chars]
Remediation
View remediation

Remediation Suggestions

  1. Default repository discovery to the current working directory or active workspace rather than the entire home directory.
  2. Require explicit user consent before enabling home-wide recursive discovery.
  3. Support an allowlist of approved repository roots and reject paths outside those roots.
  4. Skip hidden directories by default and provide an explicit opt-in option for scanning them.
  5. Present discovered repositories to the user for confirmation before collecting commit metadata.
  6. Add command-line options such as --workspace, --repo, and --scan-home, with --scan-home disabled by default.
  7. Avoid emitting absolute repository paths unless they are required; use repository names or redacted paths in normal output.
  8. Document the precise data collected and where the generated JSON or report may be stored.

other

Warning
Location
scripts/collect.py:376
Finding

Automatic Collection and Disclosure of Sensitive Agent Session Content

Content
View full analysis

Vulnerability Details

File Location: scripts/collect.py:376-430
Vulnerability Type: other: Sensitive Agent Session Collection
Risk Level: Medium

Vulnerable Code

python
def collect_agent_sessions(target_date: datetime = None) -> list:
    """
    Scan CodeBuddy's brain directory for Agent session overviews
    that were modified on the target date.
    """
    sessions = []
    data_dir = get_codebuddy_data_dir()

    # Look for brain directories
    brain_patterns = [
        data_dir / "User" / "globalStorage" / "tencent-cloud.coding-copilot" / "brain",
        data_dir / "User" / "globalStorage" / "tencent-cloud.codebuddy" / "brain",
    ]

    if target_date is None:
        target_date = datetime.now()
    check_date = target_date.date()

    for brain_dir in brain_patterns:
        if not brain_dir.is_dir():
            continue

        try:
            for session_dir in brain_dir.iterdir():
                if not session_dir.is_dir():
                    continue

                overview_file = session_dir / "overview.md"
                if not overview_file.exists():
                    continue

                # Check if modified today
                try:
                    mtime = datetime.fromtimestamp(overview_file.stat().st_mtime)
                    if mtime.date() != check_date:
                        continue

                    content = overview_file.read_text(encoding="utf-8")
                    if content.strip():
                        sessions.append({
                            "session_id": session_dir.name,
                            "overview_content": content[:3000],  # Limit size
                            "modified_time": mtime.strftime("%Y-%m-%d %H:%M:%S"),
                        })
                except Exception:
                    continue

        except Exception:
            continue

    # Sort by modification time
    sessions.sort(key=lambda s: s["modified_time"], reverse=True)
  
...[truncated 3325 chars]
Remediation
View remediation

Remediation Suggestions

  1. Make Agent-session collection disabled by default and require an explicit option such as --include-agent-sessions.
  2. Request clear user consent before accessing historical Agent storage.
  3. Enumerate matching sessions using metadata only and allow the user to select which sessions may be read.
  4. Apply secret detection and redaction before content is written to standard output or supplied to an Agent.
  5. Redact session identifiers, absolute paths, credentials, tokens, private keys, and other sensitive patterns.
  6. Prefer locally generated high-level summaries over emitting raw overview content.
  7. Provide configurable content limits and an option to exclude raw content entirely.
  8. Warn users that standard output and generated reports may be retained by terminals, CI systems, logging infrastructure, or AI platforms.
  9. Separate session collection from Git activity collection so users can generate repository-only reports without accessing Agent history.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (16)

Ssd 3

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The script is explicitly designed to collect work data from all repositories and agent-session sources, then emit it to stdout as structured JSON. In an agent-skill environment, stdout is often consumed by other components, logs, or UIs, so broad automatic disclosure materially increases the risk of sensitive project and conversation data leakage.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/collect.py (reported line 107)May include surrounding context.

python
"git_author": "",
        "exclude_dirs": [
            "node_modules", "vendor", ".cache", "__pycache__",
            "venv", ".venv", "env", ".env", ".tox",
            "dist", "build", "target", "out",
        ],
        "max_depth": 5,

Ssd 3

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

Reading overview.md files from CodeBuddy brain storage and embedding their contents in the output can leak sensitive conversation history, code context, workspace paths, and task details. The skill context makes this more dangerous because users asking for a daily report may not realize that private agent-session content is being harvested and disclosed.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The README explicitly advertises scanning the entire HOME directory, enumerating all Git repositories, collecting commit history across all branches, and gathering CodeBuddy Agent session overviews, but it does not prominently warn that this may expose sensitive source code metadata, repository names, branch names, commit messages, paths, and AI activity records. In a skill intended for routine report generation, this broad collection increases privacy and confidentiality risk because users may not realize the scope of data accessed or summarized.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
94% confidence
Finding

The skill invokes a local Python script and relies on shell, file reads, and environment-derived paths, but it declares no explicit tool scope or permissions boundary. That makes the skill's effective capabilities opaque to users and enforcement layers, increasing the risk of unintended filesystem scanning and command execution beyond what a user expects from a 'daily report' feature.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The trigger phrase includes a broad catch-all like variations of 'what did I do today/yesterday,' which can cause the skill to activate on ambiguous requests. In this skill's context, accidental activation is more dangerous because execution leads to scanning local repositories and agent session overviews, exposing sensitive work history without sufficiently specific user intent.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The overview says the skill automatically discovers all git repositories and gathers agent session overviews, but it does not clearly warn that this inspects potentially sensitive local code history and AI session content. Users may invoke it without understanding the breadth of collection across all branches and multiple directories, creating a meaningful privacy and confidentiality risk.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The template headings and labels are entirely in Chinese, which implies the skill will generate reports in a fixed language. The file does not offer any language or locale choice, and no justification for a Chinese-only output is documented here.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

All user-facing comments and configuration guidance in this file are written only in Chinese, with no indication that another language is available or that the locale is intentionally region-specific. This can violate a language/locale policy when users are not given an opt-in choice or documented justification for the constraint.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/collect.py (reported line 175)May include surrounding context.

python
def detect_git_author() -> str:
    """Auto-detect the git user name from global git config."""
    try:
        result = subprocess.run(
            ["git", "config", "--global", "user.name"],
            capture_output=True, text=True, timeout=5
        )

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
83% confidence
Finding

The script runs git log against every discovered repository and passes an author filter derived from config or environment. Although it does not use a shell, this still executes an external binary across attacker-controlled repositories and can expose metadata from a very broad set of repos, especially given the skill's automatic home-directory discovery behavior.

Content

Scanner excerpt · scripts/collect.py (reported line 278)May include surrounding context.

python
if author:
            cmd.append(f"--author={author}")

        result = subprocess.run(
            cmd, capture_output=True, text=True, timeout=15
        )

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
82% confidence
Finding

This subprocess call performs git log --stat over all discovered repositories, amplifying the same broad data-collection issue as the previous finding. While not a classic injection flaw, it contributes to automatic collection of potentially sensitive work history and file-change statistics from repositories the user may not expect to be scanned.

Content

Scanner excerpt · scripts/collect.py (reported line 354)May include surrounding context.

python
if author:
            cmd.append(f"--author={author}")

        result = subprocess.run(
            cmd, capture_output=True, text=True, timeout=15
        )

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The skill reads CodeBuddy session overview files and includes their contents in JSON output without any explicit warning, consent gate, or redaction. These overviews can contain sensitive prompts, code snippets, file paths, internal project details, or other workspace data that may be unintentionally disclosed downstream.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
83% confidence
Finding

The README presents the skill only in Chinese and English, with no indication that users can choose other languages or that the locale restriction is intentional for a region-specific use case. Under the language/locale policy, constraining the skill to specific languages without user opt-in can be a natural-language policy issue.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

The save step instructs writing the generated report to disk but does not warn that the report may contain sensitive summaries of repositories, commit messages, branch names, and agent session content. Persisting that information can create an additional exposure surface through local files, backups, syncing services, or accidental sharing.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The script defaults to scanning the entire home directory, including hidden folders, to locate repositories, which is broader than users typically expect for a daily-report tool. In this skill context, automatic filesystem-wide discovery increases the chance of pulling in personal, confidential, or unrelated repositories without informed consent.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.