Back to skill

Security audit

semantic-search

Security checks for vulnerabilities and agentic risk

Overview

This appears to be a real semantic search and Text-to-SQL skill, but it can run AI-generated database queries and includes exposed internal-looking credentials/configuration that require careful review.

Install only after reviewing the database role, model endpoints, and exposed PROJECT_CONFIG.md values. Use read-only least-privilege database credentials, rotate any credentials that match the published examples, pin dependencies, avoid sending sensitive schema/sample rows to external providers unless approved, and do not enable Text-to-SQL on production data without parser-based SQL validation, row limits, audit logs, and access controls.

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 (6)

T09 · Insecure Skill Coding Practices

Error
Location
src/text2sql.py:95
Finding

LLM-Generated SQL Is Executed After Bypassable Blacklist Validation

Content
View full analysis
bool: sql_upper = sql.upper().strip() # Must start with SELECT or WITH (Common Table Expressions) if not (sql_upper.startswith("SELECT") or sql_upper.startswith("WITH")): return False # Forbidden keywords that modify data or schema forbidden_keywords = [ "INSERT INTO", "UPDATE", "DELETE FROM", "DROP TABLE", "DROP DATABASE", "ALTER TABLE", "TRUNCATE TABLE", "CREATE TABLE", "CREATE DATABASE", "GRANT", "REVOKE", "COMMIT", "ROLLBACK" ] for keyword in forbidden_keywords: if re.search(r'\b' + re.escape(keyword) + r'\b', sql_upper): return False return True ``` ```python response = call_openai_sdk(messages) sql_query = self._extract_sql_from_llm(response) ``` ```python if not self._is_valid_select_statement(sql): error_msg = "安全警告: 仅允许SELECT查询, 检测到潜在DML/DDL命令" logger.warning(f"{error_msg} SQL: {sql}") return { "execution_result": None, "error_message": error_msg, "sql_query": sql } status, result = self.db_env._sync_query_gen_sql(sql) ``` ### Technical Analysis The application asks an LLM to generate SQL from caller-controlled natural language and then executes that SQL against the configured database. The only security boundary is a textual blacklist. Checking whether a string starts with `SELECT` or `WITH` does not prove that it is a side-effect-free query. PostgreSQL permits calls to privileged or volatile functions from a `SELECT`, including functions that may read server-side files, invoke extensions, or modify state. The blacklist is incomplete and does not validate statement count, syntax structure, referenced schemas, functions, tables, or resource scope. If the under ...[truncated 1107 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
src/text2sql.py:472
Finding

Untrusted Metadata Table Name Is Interpolated Directly Into SQL

Content
View full analysis
List[Dict]: table_data = [] try: if hasattr(self.db_env, "_sync_query"): raw_data = self.db_env._sync_query( f"select * from public.{table_name} limit 1" ) else: try: loop = asyncio.get_event_loop() except RuntimeError: loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) raw_data = loop.run_until_complete( self.db_env.query(f"select * from public.{table_name} limit 1") ) ``` ### Technical Analysis The table name comes from an HTTP metadata response and is placed directly into an SQL statement as an identifier. SQL value parameterization does not normally support identifiers, so identifiers must be resolved from a trusted mapping or safely quoted with a database-specific identifier API. No validation restricts `view_name` to a single legal identifier. Consequently, a compromised metadata service, tampered response, or malici ...[truncated 967 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
PROJECT_CONFIG.md:9
Finding

Plaintext Credentials and Internal Infrastructure Topology Are Included in the Package

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
src/main.py:102
Finding

Caller-Supplied Security Configuration Is Silently Ignored

Content
View full analysis
SemanticSearch: """懒加载 SemanticSearch 实例""" if self._search_instance is None: self._search_instance = SemanticSearch() return self._search_instance @property def data_gen(self) -> DataGen: """懒加载 DataGen 实例""" if self._data_gen_instance is None: self._data_gen_instance = DataGen() return self._data_gen_instance ``` ### Technical Analysis The constructor accepts and stores a caller-supplied configuration, but the runtime objects are created without receiving that configuration. `SemanticSearch`, `DataGen`, and their downstream clients instead rely on imported global configuration. This violates the documented custom-configuration boundary. An operator can believe that a restricted database or approved model endpoint has been selected while the Skill silently uses a project-global database, metadata service, LLM, reranker, or embedding endpoint. ### Attack Path 1. An operator supplies an isolated configuration containing an approved database and LLM endpoint. 2. `SemanticSearchSkill` stores the configuration in `self.config`. 3. Access to `search` or `data_gen` constructs downstream classes without passing `self.config`. 4. Downstream modules load global `CONFIG`. 5. Queries and database-derived content are processed by unintended services, or operations run against an unintended database. ### Impact Assessment The flaw can cause cross-environment data access, tenant-boundary violations, and unintended disclosure to globally configured AI services. It also prevents operators from reliably enforcing TLS, cred ...[truncated 106 chars]
Remediation
View remediation

T08 · Insecure Dependencies

Warning
Location
requirements.txt:1
Finding

Unpinned Third-Party Dependencies Create Non-Reproducible and Unsafe Installations

Content
View full analysis
=0.115.0 pydantic>=2.0.0 uvicorn>=0.24.0 # Vector Database lancedb>=0.5.0 adbc-driver-flightsql>=0.8.0 grpcio>=1.60.0 pandas>=2.0.0 # AI/ML langgraph>=0.0.1 langchain>=0.1.0 transformers>=4.36.0 sentence-transformers>=2.2.0 # Embedding & Rerank FlagEmbedding>=1.2.0 bge-reranker>=1.1.0 # LLM dashscope>=1.14.0 openai>=1.0.0 # Utils python-dotenv>=1.0.0 pyyaml>=6.0 loguru>=0.7.0 numpy>=1.24.0 ``` The documented installation command is: ```bash pip install -r requirements.txt ``` ### Technical Analysis Every dependency uses a lower-bound constraint rather than an exact reviewed version. No lockfile or package hashes are supplied. A future installation can therefore resolve materially different versions from those reviewed during publication. Packages may execute code during installation or import. Broad dependency trees associated with machine-learning frameworks further increase the number of packages whose integrity and compatibility must be trusted. No specific malicious package was identified in the dependency list; the confirmed weakness is the absence of reproducible dependency resolution and integrity enforcement. ### Attack Path 1. A user runs the documented installation command. 2. The package resolver selects the newest versions satisfying the lower bounds. 3. A compromised, malicious, or incompatible future release is downloaded. 4. Package installation or import executes code under the installing user's privileges. 5. The Skill environment or host may be compromised, or security behavior may change without review. ### Impact Assessment A compromised dependency can execute with the privileges of the installation or runtime account, access environment credentials, modify files, and intercept database or LLM traffic. Even without ma ...[truncated 125 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
src/text2sql.py:156
Finding

Untrusted User, Metadata, and Database Content Can Inject Instructions Into the SQL-Generating LLM

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (81)

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 · .gitignore (reported line 27)May include surrounding context.

text
*.egg

# 配置文件
.env
.env.local
*.local
config.yaml

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 · .gitignore (reported line 28)May include surrounding context.

text
# 配置文件
.env
.env.local
*.local
config.yaml
config.local.yaml

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 · README.md (reported line 24)May include surrounding context.

export LLM_API_KEY="sk-xxx"

text

**方式 2: .env 文件**
```bash
cp .env.example .env
# 编辑 .env 填入实际配置

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 · README.md (reported line 27)May include surrounding context.

export LLM_API_KEY="sk-xxx"

text

**方式 2: .env 文件**
```bash
cp .env.example .env
# 编辑 .env 填入实际配置

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 · README.md (reported line 26)May include surrounding context.

方式 2: .env 文件

bash
cp .env.example .env
# 编辑 .env 填入实际配置

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

If the underlying skill includes undeclared write/create capabilities such as vector table creation or example writes while presenting itself as a read-oriented search tool, that is a meaningful security concern. Hidden mutation of backend resources can violate least privilege and may alter indexed data or database state unexpectedly.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
90% confidence
Finding

If the underlying skill includes undeclared write/create capabilities such as vector table creation or example writes while presenting itself as a read-oriented search tool, that is a meaningful security concern. Hidden mutation of backend resources can violate least privilege and may alter indexed data or database state unexpectedly.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
92% confidence
Finding

If the underlying skill includes undeclared write/create capabilities such as vector table creation or example writes while presenting itself as a read-oriented search tool, that is a meaningful security concern. Hidden mutation of backend resources can violate least privilege and may alter indexed data or database state unexpectedly.

Content

No source excerpt is available for this finding.

Possible Typosquatting: 'uvicorn' resembles popular package 'gunicorn'

High
Category
Supply Chain
Confidence
70% confidence
Finding

Package name closely resembles a popular package, suggesting possible typosquatting. Attackers publish malicious packages with similar names to trick developers into installing them.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
96% confidence
Finding

The agent sends user queries, full table schema, sample row data, and retrieved context to an LLM via call_openai_sdk, which can expose sensitive business data or personal data to an external model provider or downstream logging systems. In an enterprise semantic-search/Text-to-SQL skill, this is especially risky because schema names, sample values, and context often contain confidential metadata that materially increases data leakage impact.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The guide instructs users to configure external LLM providers and API keys for intent recognition, SQL generation, and query enhancement, but it does not clearly disclose that user queries, database schema, or other contextual metadata may be transmitted to third-party services. In a semantic search and Text-to-SQL skill, that omission can cause unintended data exposure because operators may enable cloud LLMs without understanding that potentially sensitive enterprise metadata leaves their environment.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

This is a markdown file, so SQP-2 applies to user-facing descriptions of behaviors affecting privacy or system integrity. The examples instruct users to set FLIGHT_DB_PASSWORD, api_key, and inline passwords in config/code, but provide no warning to avoid committing secrets, using placeholders only in local test setups, or protecting credential files.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
99% confidence
Finding

The document embeds multiple live-sensitive secrets and internal service endpoints, including database credentials, Nacos username/password, and PostgreSQL credentials, along with internal IPs and ports. This materially increases the risk of unauthorized access, lateral movement, environment mapping, and compromise of connected data/AI infrastructure; the skill context makes it more dangerous because this is an enterprise semantic-search system tied to databases, message queues, and model services rather than a harmless example.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The document advertises semantic search, file search, and Text-to-SQL capabilities using external FlightSQL, LLM, and embedding services, but does not clearly warn that user queries, schema metadata, and possibly file-derived content may be transmitted to those services. In an enterprise search skill, this omission is security-relevant because users may unknowingly submit sensitive business data, database structure, or internal document content to third-party systems.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The natural-language instructions and examples are fully localized to Chinese, which can amount to a language policy violation when no user opt-in or alternative language option is provided. The file does not state that the skill is region-specific or intentionally limited to Chinese-speaking users.

Content

No source excerpt is available for this finding.

Rp1

Medium
Category
MCP Rug Pull
Confidence
70% confidence
Finding

npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.

Content

No source excerpt is available for this finding.

Rp1

Medium
Category
MCP Rug Pull
Confidence
70% confidence
Finding

npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.

Content

No source excerpt is available for this finding.

Rp1

Medium
Category
MCP Rug Pull
Confidence
70% confidence
Finding

npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
88% confidence
Finding

The manifest declares environment-variable requirements and describes Python execution plus database/network connectivity, but it does not define any explicit tool scope such as allowed tools or permissions. This creates an authorization and transparency gap: consumers cannot easily tell what external access the skill may use, increasing the risk of unintended secret access, file reads, or network operations.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The documentation advertises Text-to-SQL generation and query execution without warning that natural-language prompts may retrieve sensitive records from connected databases. Because this skill is designed to transform user input into executable database queries, omission of data-exposure warnings and guardrails materially increases the risk of unauthorized or overbroad data access.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The setup instructions include plaintext credential examples in environment variables and config files but do not warn users about secure secret handling. This encourages insecure operational practices such as committing passwords to files, shell history, or shared configuration, which can lead to credential theft and downstream database compromise.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The manifest description is written entirely in Chinese and does not indicate that the skill is China-specific or that users can choose another language or locale. This creates a natural-language locale policy concern because the skill presentation appears to assume a specific language without opt-in or justification.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The module docstrings, comments, printed output, and example queries are written entirely in Chinese, which imposes a specific language experience on users and developers interacting with this example file. There is no indication that alternative languages are supported or that Chinese is a justified region-specific requirement.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The rerank path sends the user query and candidate document content to external rerank services via call_qwen_rerank and fallback call_rerank_sdk. Because the retrieved content can include file names, business classifications, coverage metadata, and other enterprise search corpus data, this creates a real outbound data exposure risk if users or administrators are not informed and if data minimization, consent, or vendor controls are absent.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The code logs the full LLM field search response, which is derived from table metadata and user queries and may contain sensitive schema details, business terminology, or inferred data relationships. In an enterprise semantic-search/Text-to-SQL context, logs are often broadly accessible to operators and retained centrally, so this creates a realistic confidentiality risk even if no direct external attacker controls the logger.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.