Back to skill

Security audit

Archery SQL Query

Security checks for vulnerabilities and agentic risk

Overview

This database-query skill is not clearly malicious, but it needs Review because it handles real database credentials, sessions, and arbitrary SQL with unsafe defaults and weak safeguards.

Install only if you trust the Archery server and need this database access. Use HTTPS, a least-privilege or read-only Archery account where possible, protect ~/.archery with restrictive permissions, avoid the cookies command, do not put passwords in shell history, and manually review any generated DELETE SQL before running it.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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
Findings (4)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/archery_query.py:19
Finding

Plaintext HTTP Defaults Expose Credentials, Session Cookies, SQL, and Query Results

Content
View full analysis
None: parser.add_argument( "--base-url", default="http://your-archery-server:9123", help="Archery base URL", ) ``` From `scripts/archery_mcp_server.py`: ```python def build_client() -> ArcheryClient: client = ArcheryClient( base_url=os.getenv("ARCHERY_BASE_URL", "http://your-archery-server:9123"), timeout=int(os.getenv("ARCHERY_TIMEOUT", "15")), verify=not env_bool("ARCHERY_INSECURE", False), session_file=os.getenv("ARCHERY_SESSION_FILE", "~/.archery/cache/session.json"), ) ``` The configuration documentation also recommends a plaintext endpoint: ```json { "archery_username": "your_username", "archery_password": "your_password", "archery_base_url": "http://your-server:9123" } ``` ### Technical Analysis The Skill defaults to and documents unencrypted HTTP for communication with the Archery server. The HTTP client transmits authentication credentials to `/authenticate/`, sends authenticated session cookies in later requests, submits SQL statements, and receives database query results. TLS certificate verification does not protect an `http://` connection. Consequently, any actor able to observe or alter traffic between the client and Archery can read or modify sensitive data. The documentation makes insecure deployment more likely because users may copy the provided configuration directly. ### Attack Path 1. A user follows t ...[truncated 1024 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/archery_client.py:148
Finding

Session Cookies Are Persisted Without Enforced File Permissions and Can Be Printed in Plaintext

Content
View full analysis
None: if not self.session_file: raise ArcheryError("session_file is not configured") self.session_file.parent.mkdir(parents=True, exist_ok=True) payload = { "base_url": self.base_url, "cookies": self._cookie_dict(), } self.session_file.write_text( json.dumps(payload, indent=2, ensure_ascii=False) + "\n" ) ``` From `scripts/archery_cli.py`: ```python if args.command == "cookies": client.ensure_session() dump( {"base_url": client.base_url, "cookies": client._cookie_dict()}, args.pretty, ) return 0 ``` ### Technical Analysis The session file contains authentication cookies, including the Archery session identifier. The code creates its parent directory and writes the file without explicitly setting restrictive permissions. The resulting access mode depends on the process umask and pre-existing filesystem state. In permissive environments, other local users may be able to read the session. In addition, the `cookies` command deliberately prints the full cookie dictionary. This can expose active authentication material through terminal capture, redirected files, CI logs, support transcripts, or other process-output collection systems. A session cookie is a bearer credential: possession may be sufficient to impersonate the authenticated user until the session expires or is revoked. ### Attack Path 1. A user logs in, causing the client to save authentication cookies in `~/.archery/cache/session.json`. 2. The file is created under a permissive umask or inside a directory with insufficient access restrictions. 3. Another local account or process reads the session file. 4. Alterna ...[truncated 762 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/archery_cli.py:61
Finding

Archery Password Is Accepted as a Command-Line Argument

Content
View full analysis
Remediation
View remediation

T08 · Insecure Dependencies

Note
Location
requirements.txt:1
Finding

Dependency Version Is Not Reproducibly Pinned

Content
View full analysis
=2.28.0 ``` ### Technical Analysis The dependency declaration permits any current or future `requests` release at or above version 2.28.0. Installations performed at different times can therefore resolve to different package versions without a corresponding change to the project. This is not evidence that the current `requests` package is malicious. The weakness is a lack of reproducibility and review control: future releases or altered transitive dependencies can be introduced automatically. It also increases the likelihood of unexpected compatibility or security regressions. ### Attack Path 1. An operator installs the project dependencies at a later date. 2. The package resolver selects a newer, previously unaudited `requests` release or changed transitive dependency. 3. The newly resolved code is imported by `archery_client.py`. 4. Any compromised or vulnerable dependency behavior executes within the user's Python process. 5. Because the process handles Archery credentials, session cookies, SQL, and query results, a dependency compromise could access those assets. ### Impact Assessment Potential impact depends on the behavior of a future or compromised dependency release. Code imported into this project runs with the same operating-system privileges as the Skill and can potentially read configuration credentials, session files, submitted SQL, and database results. No current malicious dependency was identified from the reviewed manifest. ]]>
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
Findings (39)

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding

The declared purpose focuses on database querying, but the documented behavior also includes local configuration management, alias persistence, cache manipulation, and CLI management workflows. This mismatch can cause users or an orchestrating agent to invoke the skill under the assumption it is query-only, while it actually modifies local state and expands access patterns.

Content

No source excerpt is available for this finding.

os.system() or os exec-family call

High
Category
Dangerous Code Execution
Confidence
85% confidence
Finding

os.system() and os exec-family calls run shell commands with the process's full privileges, enabling arbitrary command execution.

Content

Scanner excerpt · scripts/archery_mcp_wrapper.py (reported line 40)May include surrounding context.

python
os.environ["ARCHERY_PASSWORD"] = password

    server_path = Path(__file__).with_name("archery_mcp_server.py")
    os.execvp("python3", ["python3", str(server_path)])


if __name__ == "__main__":

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The README explicitly promotes executing arbitrary SQL queries and even says the tool can be used for deduplication and data cleaning, but it does not warn that unrestricted SQL may modify or delete production data. In a database-query skill, this omission materially increases the risk of accidental destructive operations, especially if users assume the tool is query-only.

Content

No source excerpt is available for this finding.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
80% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

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

设置权限:

bash
chmod 600 ~/.archery/config.json

2. 安装依赖

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
80% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

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

设置权限:

bash
chmod 600 ~/.archery/config.json

2. 安装依赖

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
80% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · references/config-example.md (reported line 94)May include surrounding context.

设置权限:

bash
chmod 600 ~/.archery/config.json

2. 安装依赖

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
93% confidence
Finding

The skill documents shell execution, network access to an Archery server, and local file read/write of credentials and cache files, but it declares no explicit tool scope or permissions boundary. In an agent setting, missing scope makes it easier for the skill to be invoked with broader-than-necessary capabilities, increasing the blast radius if prompts are manipulated or the skill is misused.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The manifest description says the skill should be used for a wide range of generic database-related operations and includes broad terms like "Archery", "TiDB", "MySQL", and "数据库相关操作". These terms are common in normal technical conversation and the description does not clearly bound when the skill should or should not activate, increasing the risk of unintended invocation.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The documentation advertises generating DELETE statements for duplicate data without an explicit destructive-action warning near the feature description. In a database operations skill, this is dangerous because users or agents may treat generated SQL as routine output and execute irreversible deletions on production data.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The duplicate-data workflow gives step-by-step instructions for producing deletion SQL, including output files and deletion strategy, but omits a clear safety gate before handling user data destructively. Because the skill operates in a real database administration context, omission of warnings and review requirements materially raises the risk of accidental mass deletion.

Content

No source excerpt is available for this finding.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
80% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · references/config-example.md (reported line 95)May include surrounding context.

bash
chmod 600 ~/.archery/config.json
chmod 700 ~/.archery

Git 忽略

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The CLI includes a cookies command that prints the current saved session cookies to stdout. Session cookies are bearer credentials; exposing them is unnecessary for the stated database-query purpose and enables session hijacking if terminal output, logs, shell history wrappers, or agent transcripts are accessible to others.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The cookies command dumps raw saved cookies directly to stdout via client._cookie_dict(). In an agent or CLI environment, stdout is often captured in logs, transcripts, CI output, or shared terminals, so this creates a straightforward credential disclosure path that can be used to impersonate the user on the Archery platform.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The client persists active authentication cookies, including session identifiers and CSRF tokens, to disk in plaintext JSON without any protection, warning, or lifecycle controls. If the session file is readable by other local users, included in backups, synced to cloud storage, or accidentally committed, an attacker can reuse the cookies to impersonate the user against the Archery platform until the session expires or is revoked.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This code reads sensitive authentication material from environment variables, including username, password, OTP, phone, and key, and then performs a login request to a remote Archery service. There is no confirmation prompt, user-facing log/print, or explanatory comment/docstring in this file warning that credentials will be consumed and transmitted for authentication.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The query tool sends user-provided SQL and database identifiers to the Archery backend and returns query results, which can affect privacy and data exposure. In this code file there is no confirmation, user-facing logging, or warning comment/docstring explaining that queries and related metadata are transmitted to an external server.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The natural-language strings in the docstring and error messages are presented only in Chinese, with no indication that the skill is intentionally limited to Chinese-speaking users or that another language option exists. This can violate language/locale policy when a skill imposes a specific language without user opt-in or documented justification.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The wrapper reads credentials from disk and exports them into process environment variables before launching another program. Environment variables are commonly exposed to child processes, debugging tools, crash reports, and in some environments to other local users or logs, so this broadens secret exposure beyond the original config file.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The script silently persists instance/database mappings to a global cache under the user's home directory whenever --instance and --db are provided directly. While this is likely meant as a convenience feature, writing state without explicit user consent can leak sensitive environment metadata, create unexpected persistence across projects, and violate least-surprise expectations for a database-querying skill.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This Python file contains natural-language documentation entirely in Chinese, and later prints command usage and status messages in Chinese as well. Under the policy rules, forcing a specific language without opt-in or an explicitly documented locale-specific justification is a natural-language policy violation.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

Manifest 将该 skill 描述为通过 Archery 平台进行数据库查询、探索和查重等数据库相关操作,但此文件实现了 add/remove/init/clear 等本地持久化状态修改能力。虽然缓存是实现细节,但这些显式的配置管理与删除操作构成了额外的可变更行为,和描述中的查询型用途不一致。

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The manifest describes this skill as being used for SQL queries, database exploration, and duplicate-data lookup, which suggests analysis-oriented behavior. In this file, the default behavior goes beyond querying by preparing destructive SQL deletion commands (generate_delete=True by default), which materially expands the skill from inspection into remediation.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The CLI description says Archery 表去重查询工具, emphasizing querying, while the implementation writes artifact files including executable DELETE batches. This is a meaningful behavior expansion because it operationalizes record removal rather than only reporting duplicates.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The module docstring, help descriptions, and user-facing messages are presented in Chinese only, which imposes a specific language on users without opt-in. The file does not indicate that the tool is intentionally limited to a Chinese-speaking audience or provide an alternative language option.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

This code performs remote API calls to list database resources, which transmits instance and database selection information to an external Archery server. While the script prints search progress, it does not clearly disclose that using the tool will contact a remote service and retrieve metadata from that system.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.