Back to skill

Security audit

A股信号追踪

Security checks for vulnerabilities and agentic risk

Overview

The skill's main instructions fit finance signal tracking, but the package includes under-disclosed finance tooling that can use local databases, API keys, remote model downloads, and unsafe model checkpoint loading if run.

Install only if you are comfortable with a finance research package that includes broader experimental tooling than the tracker description suggests. Avoid running the predictor, training, or evaluation scripts on untrusted inputs, review any UST_URL and API-key configuration, and expect local SQLite caches/files to be created if the bundled utilities are used.

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/utils/predictor/evaluation.py:25
Finding
Unsafe PyTorch Checkpoint Deserialization Can Lead to Arbitrary Code Execution<![CDATA[ ## Vulnerability Details **File Location**: `scripts/utils/predictor/evaluation.py:25-40` **Vulnerability Type**: Unsafe deserialization of a potentially untrusted model checkpoint **Risk Level**: High ### Vulnerable Code ```python class NewsModelEvaluator: def __init__(self, model_path=None): self.trainer = AutoSynthesisTrainer() self.device = self.trainer.device if model_path is None: # Try to find the latest model in exports/models model_files = glob.glob(os.path.join(SRC_DIR, "exports/models/*.pt")) if not model_files: logger.warning("⚠️ No trained models found in exports/models/. Using base model (zero-init proj).") else: model_path = max(model_files, key=os.path.getctime) if model_path: self.load_weights(model_path) def load_weights(self, path): logger.info(f"🔄 Loading model weights from {path}...") checkpoint = torch.load(path, map_location=self.device) self.trainer.model.news_proj.load_state_dict(checkpoint['news_proj_state_dict']) logger.success("✅ News projection layer loaded.") ``` ### Technical Analysis The evaluator loads a caller-supplied checkpoint or automatically selects the newest `.pt` file from `exports/models`. It then passes that file to `torch.load()` without explicitly enabling a restricted weights-only mode. PyTorch checkpoint loading has historically used Python pickle-compatible deserialization. On versions or configurations where unrestricted deserialization is active, specially constructed checkpoint objects can execute Python code during loading. This occurs before the subsequent `load_state_dict()` call can validate that the checkpoint contains the expected tensor dictionary. Automatic selection of the newest checkpoint increases the risk: an attacker who can place or replace a file in the model directory does not need to control the c ...[truncated 1500 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Explicitly request restricted loading on supported PyTorch versions: ```python checkpoint = torch.load( path, map_location=self.device, weights_only=True, ) ``` 2. Prefer a non-executable weight format such as `safetensors`. 3. Restrict checkpoints to a dedicated trusted directory and resolve the path before use: ```python trusted_dir = (Path(SRC_DIR) / "exports" / "models").resolve() checkpoint_path = Path(path).resolve() if trusted_dir not in checkpoint_path.parents: raise ValueError("Checkpoint is outside the trusted model directory") if checkpoint_path.is_symlink(): raise ValueError("Symbolic-link checkpoints are not permitted") ``` 4. Verify every checkpoint against a trusted SHA-256 digest or digital signature before loading. 5. Validate file ownership and permissions, and ensure the runtime account cannot be tricked into loading files written by untrusted users. 6. Validate the checkpoint structure and tensor shapes after safe parsing. 7. Pin a minimum PyTorch version whose restricted loading behavior has been reviewed, while still specifying `weights_only=True` explicitly. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/utils/predictor/kline_generate.py:25
Finding
SQL Injection Through Direct Ticker Interpolation<![CDATA[ ## Vulnerability Details **File Location**: `scripts/utils/predictor/kline_generate.py:25-30` **Vulnerability Type**: SQL injection **Risk Level**: Medium ### Vulnerable Code ```python def load_data(ticker="002111", db_path="AlphaEar/data/signal_flux.db"): with sqlite3.connect(db_path) as conn: df = pd.read_sql_query(f"SELECT * FROM stock_prices WHERE ticker = '{ticker}'", conn) df['date'] = pd.to_datetime(df['date']) df = df.sort_values('date').reset_index(drop=True) return df ``` ### Technical Analysis The `ticker` argument is interpolated directly into an SQL statement using an f-string. No parameter binding or strict ticker validation is applied. A value containing quotes and SQL syntax can therefore alter the meaning of the query. Although the SQLite/Pandas execution path commonly rejects multiple stacked statements, that restriction does not prevent all exploitation. An attacker may still modify the `WHERE` condition or construct a compatible `UNION SELECT` query to access data outside the intended ticker record set. The function also accepts an arbitrary `db_path`. If both arguments are exposed to an untrusted caller, the caller can select another SQLite database accessible to the process and then execute an attacker-shaped query against it. ### Attack Path 1. An application, script, or future tool wrapper passes an untrusted ticker value to `load_data()`. 2. The value closes the quoted ticker literal and injects additional SQL syntax. 3. The f-string constructs the modified SQL statement. 4. `pd.read_sql_query()` executes the resulting statement against the selected database. 5. Query results are returned to the caller or processed by the forecasting workflow. A conceptual malicious input can change the filter from one ticker to all records: ```text ' OR '1'='1 ``` More advanced inputs may use a schema-compatible `UNION SELECT` to retrieve data from other tables. The exact columns required depend on the local ...[truncated 643 chars]
Remediation
<![CDATA[ ## Remediation Suggestions Use parameterized SQL instead of string interpolation: ```python def load_data(ticker="002111", db_path="AlphaEar/data/signal_flux.db"): if not isinstance(ticker, str) or not ticker.isdigit() or len(ticker) not in (5, 6): raise ValueError("Invalid ticker format") with sqlite3.connect(db_path) as conn: df = pd.read_sql_query( "SELECT * FROM stock_prices WHERE ticker = ?", conn, params=(ticker,), ) df["date"] = pd.to_datetime(df["date"]) return df.sort_values("date").reset_index(drop=True) ``` Additional hardening should include: 1. Restricting ticker values to the exact supported format. 2. Resolving `db_path` and requiring it to remain under an approved data directory. 3. Opening the database in read-only mode when forecasting does not require writes. 4. Running the process with filesystem permissions limited to the required database. 5. Adding tests containing quote characters, SQL comments, boolean expressions, and union expressions to verify that they are rejected. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/utils/llm/factory.py:82
Finding
API Credential and Prompt Data Can Be Forwarded to an Unrestricted Configurable Endpoint<![CDATA[ ## Vulnerability Details **File Location**: `scripts/utils/llm/factory.py:82-107` **Vulnerability Type**: Unvalidated credential-bearing remote endpoint **Risk Level**: Medium ### Vulnerable Code ```python elif model_provider == 'ust': api_key = os.getenv("UST_KEY_API") if not api_key: print('Warning: UST_KEY_API not set.') # Some UST-compatible endpoints expect the standard OpenAI role names # (e.g. "system", "user", "assistant") rather than Agno's default # mapping which maps "system" -> "developer". Provide an explicit # role_map to ensure compatibility. default_role_map = { "system": "system", "user": "user", "assistant": "assistant", "tool": "tool", "model": "assistant", } # Allow callers to override role_map via kwargs, otherwise use default role_map = kwargs.pop("role_map", default_role_map) return OpenAIChat( id=model_id, api_key=api_key, base_url=os.getenv("UST_URL"), role_map=role_map, extra_body={"enable_thinking": False}, # TODO: one more setting for thinking **kwargs ) ``` ### Technical Analysis The UST provider reads a secret from `UST_KEY_API` and supplies it to an OpenAI-compatible client whose destination is taken directly from `UST_URL`. The code does not validate: - Whether the URL uses HTTPS. - Whether the hostname is an approved provider. - Whether the URL contains embedded credentials. - Whether it resolves to a loopback, private, or link-local address. - Whether redirects remain within an approved trust boundary. When the client performs a request, it can send both the API credential and the financial prompt content to the configured destination. The project uses external LLM processing for financial research and causality verification, so transmitted content may include user theses, company identifiers, research context, and derived analysis. This is not evidence that the c ...[truncated 1495 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Require a valid HTTPS URL and reject plaintext HTTP. 2. Enforce an explicit allowlist of trusted UST hostnames. 3. Reject embedded URL credentials, IP-literal hosts, loopback addresses, private networks, link-local networks, and cloud metadata addresses unless a documented local deployment explicitly requires them. 4. Disable redirects or revalidate every redirect destination. 5. Bind each API key to one approved endpoint rather than allowing one secret to be paired with an arbitrary URL. 6. Use short-lived, narrowly scoped credentials with quota and billing limits. 7. Document that financial prompt content is externally processed and obtain user approval where appropriate. 8. Avoid including secrets, unnecessary personal information, or unrelated local context in LLM prompts. 9. Fail closed when `UST_URL` or `UST_KEY_API` is missing or invalid. An example minimum validation pattern is: ```python from urllib.parse import urlparse TRUSTED_UST_HOSTS = {"api.example-ust.com"} base_url = os.getenv("UST_URL", "") parsed = urlparse(base_url) if parsed.scheme != "https": raise ValueError("UST_URL must use HTTPS") if parsed.hostname not in TRUSTED_UST_HOSTS: raise ValueError("UST_URL host is not approved") if parsed.username or parsed.password: raise ValueError("Embedded URL credentials are not permitted") ``` ]]>

T08 · Insecure Dependencies

Warning
Location
scripts/utils/predictor/training.py:35
Finding
Automatic Retrieval of Unpinned Remote Machine-Learning Artifacts<![CDATA[ ## Vulnerability Details **File Location**: `scripts/utils/predictor/training.py:35-60`; additional occurrence at `scripts/utils/predictor/kline_generate.py:16-20` **Vulnerability Type**: Unpinned remote model dependency and automatic network fallback **Risk Level**: Medium ### Vulnerable Code From `scripts/utils/predictor/training.py`: ```python # Try loading from local cache first to avoid network timeouts model_name = os.getenv('EMBEDDING_MODEL', 'sentence-transformers/all-MiniLM-L6-v2') try: logger.info(f"🔄 Attempting to load {model_name} from local cache...") self.embedder = SentenceTransformer(model_name, device=self.device, local_files_only=True) logger.success("✅ Model loaded from local cache.") except Exception: logger.warning("⚠️ Local cache not found or incomplete. Attempting to download...") self.embedder = SentenceTransformer(model_name, device=self.device) self.news_dim = news_dim # Try loading from local cache first to avoid network timeouts try: logger.info("🔄 Attempting to load Kronos and Tokenizer from local cache...") self.tokenizer = KronosTokenizer.from_pretrained("NeoQuasar/Kronos-Tokenizer-base", local_files_only=True).to(self.device) base_model = Kronos.from_pretrained("NeoQuasar/Kronos-base", local_files_only=True) logger.success("✅ Kronos and Tokenizer loaded from local cache.") except Exception: logger.warning("⚠️ Local Kronos/Tokenizer not found or incomplete. Attempting to download...") self.tokenizer = KronosTokenizer.from_pretrained("NeoQuasar/Kronos-Tokenizer-base").to(self.device) base_model = Kronos.from_pretrained("NeoQuasar/Kronos-base") ``` From `scripts/utils/predictor/kline_generate.py`: ```python def load_predictor(): tokenizer = KronosTokenizer.from_pretrained("NeoQuasar/Kronos-Tokenizer-base") model = Kronos.from_pretrained("NeoQuasar/Kronos-base") device = get_device() tokenizer = tokenizer.to(device) model = model.to(device) retur ...[truncated 2412 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Pin every model and tokenizer to an immutable repository commit: ```python REVISION = "<reviewed-commit-hash>" self.tokenizer = KronosTokenizer.from_pretrained( "NeoQuasar/Kronos-Tokenizer-base", revision=REVISION, local_files_only=True, ) ``` 2. Provision reviewed artifacts during deployment and disable automatic network fallback in production. 3. Verify artifact SHA-256 hashes or digital signatures before loading. 4. Prefer `safetensors` or another non-executable serialization format. 5. Apply an allowlist to `EMBEDDING_MODEL`; do not permit arbitrary repository selection through an untrusted environment value. 6. Set explicit cache directories with restrictive permissions. 7. Enforce download size limits, timeouts, and available-disk checks. 8. Pin and audit the versions of Hugging Face, PyTorch, Sentence Transformers, and related parsing dependencies. 9. Record model repository, immutable revision, digest, and loader version in generated evaluation metadata. 10. Treat any requirement for remote custom code as a separate code-execution boundary and keep it disabled unless the code has been independently reviewed. ]]>
Vulnerability Patterns
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • 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
Findings (109)

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
The repeated description-behavior mismatches indicate the skill is advertised as a narrowly scoped signal-tracking tool but is associated with much broader behaviors including arbitrary web fetching, database access, report generation, forecasting, and shell/file operations. This is dangerous because users and orchestrators may grant trust and routing decisions based on the manifest, while the implementation can exercise materially different capabilities and access more data than expected.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
The repeated description-behavior mismatches indicate the skill is advertised as a narrowly scoped signal-tracking tool but is associated with much broader behaviors including arbitrary web fetching, database access, report generation, forecasting, and shell/file operations. This is dangerous because users and orchestrators may grant trust and routing decisions based on the manifest, while the implementation can exercise materially different capabilities and access more data than expected.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
The repeated description-behavior mismatches indicate the skill is advertised as a narrowly scoped signal-tracking tool but is associated with much broader behaviors including arbitrary web fetching, database access, report generation, forecasting, and shell/file operations. This is dangerous because users and orchestrators may grant trust and routing decisions based on the manifest, while the implementation can exercise materially different capabilities and access more data than expected.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The repeated description-behavior mismatches indicate the skill is advertised as a narrowly scoped signal-tracking tool but is associated with much broader behaviors including arbitrary web fetching, database access, report generation, forecasting, and shell/file operations. This is dangerous because users and orchestrators may grant trust and routing decisions based on the manifest, while the implementation can exercise materially different capabilities and access more data than expected.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The repeated description-behavior mismatches indicate the skill is advertised as a narrowly scoped signal-tracking tool but is associated with much broader behaviors including arbitrary web fetching, database access, report generation, forecasting, and shell/file operations. This is dangerous because users and orchestrators may grant trust and routing decisions based on the manifest, while the implementation can exercise materially different capabilities and access more data than expected.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The repeated description-behavior mismatches indicate the skill is advertised as a narrowly scoped signal-tracking tool but is associated with much broader behaviors including arbitrary web fetching, database access, report generation, forecasting, and shell/file operations. This is dangerous because users and orchestrators may grant trust and routing decisions based on the manifest, while the implementation can exercise materially different capabilities and access more data than expected.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
The repeated description-behavior mismatches indicate the skill is advertised as a narrowly scoped signal-tracking tool but is associated with much broader behaviors including arbitrary web fetching, database access, report generation, forecasting, and shell/file operations. This is dangerous because users and orchestrators may grant trust and routing decisions based on the manifest, while the implementation can exercise materially different capabilities and access more data than expected.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding
The repeated description-behavior mismatches indicate the skill is advertised as a narrowly scoped signal-tracking tool but is associated with much broader behaviors including arbitrary web fetching, database access, report generation, forecasting, and shell/file operations. This is dangerous because users and orchestrators may grant trust and routing decisions based on the manifest, while the implementation can exercise materially different capabilities and access more data than expected.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
The repeated description-behavior mismatches indicate the skill is advertised as a narrowly scoped signal-tracking tool but is associated with much broader behaviors including arbitrary web fetching, database access, report generation, forecasting, and shell/file operations. This is dangerous because users and orchestrators may grant trust and routing decisions based on the manifest, while the implementation can exercise materially different capabilities and access more data than expected.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
The repeated description-behavior mismatches indicate the skill is advertised as a narrowly scoped signal-tracking tool but is associated with much broader behaviors including arbitrary web fetching, database access, report generation, forecasting, and shell/file operations. This is dangerous because users and orchestrators may grant trust and routing decisions based on the manifest, while the implementation can exercise materially different capabilities and access more data than expected.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
The repeated description-behavior mismatches indicate the skill is advertised as a narrowly scoped signal-tracking tool but is associated with much broader behaviors including arbitrary web fetching, database access, report generation, forecasting, and shell/file operations. This is dangerous because users and orchestrators may grant trust and routing decisions based on the manifest, while the implementation can exercise materially different capabilities and access more data than expected.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding
The repeated description-behavior mismatches indicate the skill is advertised as a narrowly scoped signal-tracking tool but is associated with much broader behaviors including arbitrary web fetching, database access, report generation, forecasting, and shell/file operations. This is dangerous because users and orchestrators may grant trust and routing decisions based on the manifest, while the implementation can exercise materially different capabilities and access more data than expected.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding
The repeated description-behavior mismatches indicate the skill is advertised as a narrowly scoped signal-tracking tool but is associated with much broader behaviors including arbitrary web fetching, database access, report generation, forecasting, and shell/file operations. This is dangerous because users and orchestrators may grant trust and routing decisions based on the manifest, while the implementation can exercise materially different capabilities and access more data than expected.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The repeated description-behavior mismatches indicate the skill is advertised as a narrowly scoped signal-tracking tool but is associated with much broader behaviors including arbitrary web fetching, database access, report generation, forecasting, and shell/file operations. This is dangerous because users and orchestrators may grant trust and routing decisions based on the manifest, while the implementation can exercise materially different capabilities and access more data than expected.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
The repeated description-behavior mismatches indicate the skill is advertised as a narrowly scoped signal-tracking tool but is associated with much broader behaviors including arbitrary web fetching, database access, report generation, forecasting, and shell/file operations. This is dangerous because users and orchestrators may grant trust and routing decisions based on the manifest, while the implementation can exercise materially different capabilities and access more data than expected.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The repeated description-behavior mismatches indicate the skill is advertised as a narrowly scoped signal-tracking tool but is associated with much broader behaviors including arbitrary web fetching, database access, report generation, forecasting, and shell/file operations. This is dangerous because users and orchestrators may grant trust and routing decisions based on the manifest, while the implementation can exercise materially different capabilities and access more data than expected.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding
The repeated description-behavior mismatches indicate the skill is advertised as a narrowly scoped signal-tracking tool but is associated with much broader behaviors including arbitrary web fetching, database access, report generation, forecasting, and shell/file operations. This is dangerous because users and orchestrators may grant trust and routing decisions based on the manifest, while the implementation can exercise materially different capabilities and access more data than expected.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding
The repeated description-behavior mismatches indicate the skill is advertised as a narrowly scoped signal-tracking tool but is associated with much broader behaviors including arbitrary web fetching, database access, report generation, forecasting, and shell/file operations. This is dangerous because users and orchestrators may grant trust and routing decisions based on the manifest, while the implementation can exercise materially different capabilities and access more data than expected.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding
The repeated description-behavior mismatches indicate the skill is advertised as a narrowly scoped signal-tracking tool but is associated with much broader behaviors including arbitrary web fetching, database access, report generation, forecasting, and shell/file operations. This is dangerous because users and orchestrators may grant trust and routing decisions based on the manifest, while the implementation can exercise materially different capabilities and access more data than expected.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding
The repeated description-behavior mismatches indicate the skill is advertised as a narrowly scoped signal-tracking tool but is associated with much broader behaviors including arbitrary web fetching, database access, report generation, forecasting, and shell/file operations. This is dangerous because users and orchestrators may grant trust and routing decisions based on the manifest, while the implementation can exercise materially different capabilities and access more data than expected.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding
The repeated description-behavior mismatches indicate the skill is advertised as a narrowly scoped signal-tracking tool but is associated with much broader behaviors including arbitrary web fetching, database access, report generation, forecasting, and shell/file operations. This is dangerous because users and orchestrators may grant trust and routing decisions based on the manifest, while the implementation can exercise materially different capabilities and access more data than expected.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding
The repeated description-behavior mismatches indicate the skill is advertised as a narrowly scoped signal-tracking tool but is associated with much broader behaviors including arbitrary web fetching, database access, report generation, forecasting, and shell/file operations. This is dangerous because users and orchestrators may grant trust and routing decisions based on the manifest, while the implementation can exercise materially different capabilities and access more data than expected.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The repeated description-behavior mismatches indicate the skill is advertised as a narrowly scoped signal-tracking tool but is associated with much broader behaviors including arbitrary web fetching, database access, report generation, forecasting, and shell/file operations. This is dangerous because users and orchestrators may grant trust and routing decisions based on the manifest, while the implementation can exercise materially different capabilities and access more data than expected.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding
The repeated description-behavior mismatches indicate the skill is advertised as a narrowly scoped signal-tracking tool but is associated with much broader behaviors including arbitrary web fetching, database access, report generation, forecasting, and shell/file operations. This is dangerous because users and orchestrators may grant trust and routing decisions based on the manifest, while the implementation can exercise materially different capabilities and access more data than expected.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding
The repeated description-behavior mismatches indicate the skill is advertised as a narrowly scoped signal-tracking tool but is associated with much broader behaviors including arbitrary web fetching, database access, report generation, forecasting, and shell/file operations. This is dangerous because users and orchestrators may grant trust and routing decisions based on the manifest, while the implementation can exercise materially different capabilities and access more data than expected.

Static analysis

No suspicious patterns detected.