Back to skill

Security audit

STM32 CubeMX

Security checks for vulnerabilities and agentic risk

Overview

This skill is a coherent STM32CubeMX helper, with one unsafe build-cleanup example users should treat carefully.

Before installing or using this skill, review shell snippets before running them. In particular, replace or guard rm -rf build/Debug, confirm PROJECT_DIR points to the intended STM32 project, and prefer a safer clean/build workflow when possible.

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

T09 · Insecure Skill Coding Practices

Warning
Location
SKILL.md:57
Finding

Unchecked Directory Change Before Recursive Deletion

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 57–58
Vulnerability Type: Unsafe shell command sequence
Risk Level: Medium

Vulnerable Code

bash
cd $PROJECT_DIR
rm -rf build/Debug

Technical Analysis

The documented build workflow changes into $PROJECT_DIR and then recursively deletes build/Debug. The variable is not quoted, so shell word splitting and pathname expansion can cause cd to receive an unintended path when the project directory contains spaces or wildcard characters.

More importantly, the deletion is not conditional on a successful directory change. If cd fails because the directory is invalid, inaccessible, or parsed incorrectly, shell execution continues and rm -rf build/Debug operates relative to the process's original working directory.

This is an insecure coding pattern in shell instructions. Although the affected path is relative rather than an arbitrary absolute path, it can still remove an unrelated build/Debug tree when the workflow is run from another project or sensitive working directory.

Attack Path

  1. A user or automation process sets $PROJECT_DIR to an invalid, inaccessible, or whitespace-containing path.
  2. The user executes the documented commands from a directory that already contains a build/Debug tree.
  3. The unquoted cd $PROJECT_DIR fails or resolves incorrectly.
  4. Because the command sequence does not stop after the failure, rm -rf build/Debug executes in the original working directory.
  5. The unrelated build/Debug directory and all files beneath it are recursively deleted.

Exploitation requires control or influence over the project path and a useful deletion target at build/Debug under the caller's current directory.

Impact Assessment

The command runs with the invoking user's existing privileges and does not provide privilege escalation, persistence, or code execution. Its impact is limited to destructive fi ...[truncated 339 chars]

Remediation
View remediation

Remediation Suggestions

Quote the directory variable, prevent option interpretation, and make deletion conditional on a successful directory change:

bash
cd -- "$PROJECT_DIR" && rm -rf -- build/Debug

For a complete shell script, also enable fail-fast behavior and validate the destination before deleting files:

bash
set -euo pipefail

if [ -z "${PROJECT_DIR:-}" ] || [ ! -d "$PROJECT_DIR" ]; then
    printf 'Invalid project directory: %s\n' "${PROJECT_DIR:-}" >&2
    exit 1
fi

cd -- "$PROJECT_DIR"
test -f CMakeLists.txt || {
    printf 'Refusing cleanup outside a recognized CMake project\n' >&2
    exit 1
}

rm -rf -- build/Debug

Run the workflow with an unprivileged account and avoid executing destructive build-cleanup commands from shared or sensitive parent directories.

Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (2)

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
98% confidence
Finding

rm -rf build/Debug is a classic dangerous shell pattern because it performs irreversible recursive deletion and relies on ambient shell state and variables. In a skill intended for agent use, this is more dangerous because agents may execute commands mechanically; if the working directory or project path is wrong, the deletion can damage unrelated files or repositories.

Content

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

bash
cd $PROJECT_DIR
rm -rf build/Debug
cmake --preset Debug
cmake --build build/Debug

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill instructs users to run rm -rf build/Debug as part of the normal workflow without any safety note, validation, or confinement beyond a prior cd $PROJECT_DIR. If $PROJECT_DIR is unset, mis-set, or attacker-influenced, this destructive command could delete unintended paths, and the lack of warning makes accidental misuse more likely.

Content

No source excerpt is available for this finding.