Back to skill

Security audit

STM32 AI Assistant

Security checks for vulnerabilities and agentic risk

Overview

The skill is a coherent STM32 helper, but its MCP server has an under-disclosed path traversal bug that can read files outside its bundled templates under constrained names.

Install only if you are comfortable reviewing the MCP server code or waiting for a fix that restricts chip/peripheral names to an allowlist. Treat generated STM32 templates as starting points, especially FLASH, CAN, relay, buzzer, watchdog, power, and interrupt examples; validate against your board schematic, clock tree, memory map, and safety requirements before flashing hardware.

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
src/mcp_server.py:31
Finding

Path Traversal Enables Constrained Local File Disclosure

Content
View full analysis
dict: """加载知识库""" kb_path = KNOWLEDGE_DIR / f'{chip.lower()}_kb.json' if not kb_path.exists(): raise FileNotFoundError(f"知识库不存在: {kb_path}") with open(kb_path, 'r', encoding='utf-8') as f: return json.load(f) ``` ```python periph_upper = peripheral.upper() template_file = TEMPLATE_MAP.get( periph_upper, f'{peripheral.lower()}_init.c' ) template_path = TEMPLATES_DIR / template_file if template_path.exists(): template = template_path.read_text() ``` ### Technical Analysis The MCP client controls the `chip` and `peripheral` parameters. These values are incorporated directly into filesystem paths without an identifier allowlist, separator rejection, canonicalization, or verification that the resolved path remains under `knowledge/` or `templates/`. Python's `pathlib` does not automatically confine paths to the directory represented by the left operand. Inputs containing `../` components can therefore escape the intended directories. The generated suffixes constrain exploitation: - Knowledge-base targets must end in `_kb.json` and contain valid JSON. Subsequent operations may additionally require the expected knowledge-base structure. - Template targets must end in `_init.c`. The template path is the more direct disclosure route because the selected file is read as text and returned by `generate_code`. The flaw does not permit unrestricted arbitrary-file reading, but it can disclose readable files whose paths satisfy the generated naming convention. Raw exception messages may also expose server filesystem paths. ### Attack Path 1. An attacker obtains permission to call the exposed MCP tools. 2. The attacker calls `generate_code` with an unrecognize ...[truncated 1150 chars]
Remediation
View remediation
dict: key = chip.upper() if key not in KB_FILES: raise ValueError("Unsupported chip") with KB_FILES[key].open("r", encoding="utf-8") as file: return json.load(file) ``` 2. Do not derive fallback template paths from untrusted peripheral names. Require the requested peripheral to exist in `TEMPLATE_MAP`. 3. If dynamic paths are necessary, reject absolute paths, path separators, null bytes, and `..` components. 4. Resolve and enforce directory containment before reading: ```python base = TEMPLATES_DIR.resolve() candidate = (base / template_file).resolve() if not candidate.is_relative_to(base): raise ValueError("Invalid template path") ``` 5. Return generic client-facing errors and log detailed exceptions locally rather than exposing absolute filesystem paths. 6. Add regression tests covering `../`, absolute paths, nested traversal, mixed separators, encoded traversal strings, and unsupported identifiers. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
templates/flash_init.c:11
Finding

Generated Flash-Write Template Can Erase or Corrupt Unintended MCU Memory

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • YARA SignaturesMalware Match, Webshell Match, Cryptominer Match
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (39)

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

A description-behavior mismatch is security-relevant because users and orchestrators may trust the declared purpose while the underlying implementation performs materially different actions. If the package actually behaves like a code linter/checker rather than an STM32 MCP server, that deception can bypass review expectations, trigger in unrelated contexts, and process files or code the user did not intend to expose.

Content

No source excerpt is available for this finding.

YARA rule 'agent_skill_mcp_tool_poisoning_metadata': MCP/tool metadata poisoning indicators in tool schemas or skill manifests [agent_skills]

High
Category
YARA Match
Confidence
80% confidence
Finding

YARA rule matched a hack tool or exploit indicator (offensive tools, reconnaissance, privilege escalation, or exploit frameworks).

Content

Scanner excerpt · knowledge/stm32f103_kb.json (reported line 5)May include surrounding context.

json
{
 "chip": "STM32F407",
 "peripherals": {
  "ADC": {
   "description": "Analog to Digital Converter",
   "registers": [
    {
     "name": "SR",
     "access": "RW",
     "comment": "ADC status register,                         Address offset: 0x00",
     "bits": {
      "AWD": {
       "pos": 0,
       "mask": "0x1",
       "width": 1,
       "desc": "Analog watchdog flag"
      },
      "EOC": {
       "pos": 1,
       "mask": "0x1",
       "width": 1,
       "desc": "End of conversion"
      },
      "JEOC": {
       "pos": 2,
       "mask": "0x1",
       "width": 1,
       "desc": "Injected channel end of conversion"
      },
      "JSTRT": {

YARA rule 'agent_skill_mcp_tool_poisoning_metadata': MCP/tool metadata poisoning indicators in tool schemas or skill manifests [agent_skills]

High
Category
YARA Match
Confidence
80% confidence
Finding

YARA rule matched a hack tool or exploit indicator (offensive tools, reconnaissance, privilege escalation, or exploit frameworks).

Content

Scanner excerpt · knowledge/stm32f407_kb.json (reported line 5)May include surrounding context.

json
{
 "chip": "STM32F407",
 "peripherals": {
  "ADC": {
   "description": "Analog to Digital Converter",
   "registers": [
    {
     "name": "SR",
     "access": "RW",
     "comment": "ADC status register,                         Address offset: 0x00",
     "bits": {
      "AWD": {
       "pos": 0,
       "mask": "0x1",
       "width": 1,
       "desc": "Analog watchdog flag"
      },
      "EOC": {
       "pos": 1,
       "mask": "0x1",
       "width": 1,
       "desc": "End of conversion"
      },
      "JEOC": {
       "pos": 2,
       "mask": "0x1",
       "width": 1,
       "desc": "Injected channel end of conversion"
      },
      "JSTRT": {

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

SQP-3 applies to all file types and includes language or locale policy violations. The visible user-facing instructions and descriptions are entirely in Chinese, with no indication that users may choose another language or that the skill is intentionally limited to a Chinese-speaking audience.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
79% confidence
Finding

The skill advertises an MCP server launched via a local Python command but does not declare any tool scope or permissions boundaries. When a skill can read local files yet omits explicit restrictions, an invoking agent may grant broader access than users expect, increasing the chance of unintended local data exposure.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

Overly broad trigger keywords such as STM32, embedded, register, or HAL code generation can cause the skill to activate in many ordinary technical conversations. Unintended activation increases the chance that the skill runs on unrelated prompts or codebases, exposing context and enabling any hidden or misdeclared behavior more often.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The manifest says the assistant supports GPIO/USART/SPI/I2C/ADC/TIM/EXTI and related register/HAL help, but this knowledge file also defines CAN, DAC, DBGMCU, DCMI, DMA, ETH, FLASH, FSMC, PWR, RCC, RTC, SDIO, watchdogs, RNG, and more. That means the actual knowledge scope materially exceeds the concrete peripheral list presented to users, creating a description-to-behavior mismatch about what hardware domains the skill can answer about.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The module docstring is written as a Chinese-only description, and all user-facing result strings in this file are also hardcoded in Chinese. This indicates the skill is designed to operate in a fixed language without offering user opt-in or documenting a justified locale restriction, which matches the language/locale policy violation criteria.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This code file contains the primary module docstring in Chinese, and later tool descriptions are also presented only in Chinese. Under the policy, forcing a specific language without offering user choice or documenting a justified locale constraint is a natural-language policy violation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The MCP tool metadata shown to users is entirely in Chinese, which fixes the interaction language for all users. There is no mechanism to choose locale, no fallback language, and no documented justification for a Chinese-only interface.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

SQP-3 applies to all file types and covers language or locale policy violations. This Python file uses Chinese-only natural-language descriptions in the module docstring and function docstring, with no indication that the skill is region-specific or that users may choose another language.

Content

No source excerpt is available for this finding.

Ae4

Medium
Category
analysis-evasion
Confidence
80% confidence
Finding

Suspicious Unicode normalization or mixed-script content

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

The configured CAN timing does not match the comment: with APB1 at 42 MHz and Prescaler=6, BS1=13TQ, BS2=2TQ, the nominal bitrate is about 42 MHz / (6 * (1+13+2)) = 437.5 kbps, not 500 kbps. In an embedded assistant/template context, incorrect timing guidance can cause deployment of non-communicating or unstable CAN nodes, leading to integration failures or unsafe system behavior if operators trust the generated code.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

This code performs destructive flash operations, including erasing a sector and programming words, but provides no confirmation prompt, logging, or explanatory comment warning that existing data in the sector will be overwritten. In a skill context, this is a safety-critical operation affecting device state and user data persistence, so some visible disclosure is expected.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

This code file directly switches a relay, buzzer, or LED by asserting PB0, which can immediately affect attached hardware. Although comments describe the electrical behavior, there is no user-facing warning, confirmation, or safety notice that invoking these functions may actuate external equipment.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The file's user-facing comments and descriptive text are written entirely in Chinese, including the top-level template description and operational notes. Under the stated policy, forcing a specific language without user opt-in or a documented regional justification is a natural-language policy violation.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

This is a markdown file, so SQP-2 applies to omissions in user-facing safety warnings. The section presents automatic generation of HAL configuration code as producing 'correct' or complete output, but gives no caution about validating generated code against target hardware, pin muxing, or board-level safety constraints.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
87% confidence
Finding

The manifest description and usage guidance are presented in Chinese, which effectively constrains interaction to a specific language. The file does not state that this is optional, user-selectable, or justified as a region-specific skill.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
94% confidence
Finding

The instances section declares a USB instance with "type": "USB", but there is no corresponding "USB" peripheral definition under the top-level peripherals object. This mismatch can cause downstream tooling or agents to mis-handle USB-related requests because the file claims support for a type that is not actually described.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Low
Category
Not specified by scanner
Confidence
78% confidence
Finding

The stated purpose emphasizes querying register definitions and generating HAL initialization code for common peripherals, but this file also exposes low-level system-control domains such as DBGMCU, FLASH, RCC, FSMC, and backup/RTC-related configuration. Those capabilities are not obviously part of the declared user-facing scope and broaden the assistant into sensitive platform-control areas beyond the examples given in the manifest.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
89% confidence
Finding

The module docstring declares the skill content entirely in Chinese ('快速参考 — 常用操作速查表'), and the data labels/messages throughout the file are also Chinese-only. This creates a language/locale constraint without any opt-in, fallback, or justification that the skill is intentionally limited to Chinese-speaking users.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
86% confidence
Finding

The natural-language comments and function description are entirely in Chinese, such as the file header and the send-message comment. For a general template file, this imposes a specific language on readers without any opt-in or documented region-specific justification, which matches the locale-policy concern in scope.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
92% confidence
Finding

This code file contains natural-language comments and header text entirely in Chinese, including the skill description and operational notes. Under the stated policy, forcing a specific language without user opt-in or a documented regional justification is a language/locale policy violation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

All descriptive natural-language content in the file is written in Chinese, with no indication that another language is supported or that the locale is intentionally restricted. Under the policy, language constraints should be opt-in or clearly justified when they limit accessibility.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
90% confidence
Finding

The file's human-facing description and comments are written in Chinese, which imposes a specific language on users and maintainers without any indication of opt-in or locale-specific scope. This matches the language/locale policy violation category because the file provides no alternative language choice or justification that it is intended only for a Chinese-speaking or region-specific audience.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.