Back to skill

Security audit

MegaSquirt Tuner

Security checks for vulnerabilities and agentic risk

Overview

The skill is coherent and not malicious, but it gives safety-critical ECU tuning advice with confirmed contradictory and incorrect fueling guidance that users should review carefully before installing.

Install only if you are comfortable treating this as educational reference material, not authoritative tuning guidance. Before using it on a real vehicle, verify all formulas and analyzer output against trusted Megasquirt/TunerStudio documentation or a qualified tuner, back up tunes, use controlled test conditions, and be especially cautious with AFR, VE, ignition timing, boost, autotune, and firmware update advice.

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

Error
Location
scripts/analyze_msq.py:211
Finding
Reversed AFR Safety Classification Can Produce Hazardous Tune Assessments<![CDATA[ ## Vulnerability Details **File Location**: `scripts/analyze_msq.py`, lines 211–217 **Vulnerability Type**: Incorrect safety-critical validation logic **Risk Level**: High ### Vulnerable Code ```python if min_afr < 10.0: issues.append(f"🚨 DANGER: AFR target goes as lean as {min_afr:.1f}:1 - risk of engine damage!") elif min_afr < 11.0: issues.append(f"⚠️ Very lean AFR target ({min_afr:.1f}:1) at high load - engine damage risk") if max_afr > 16.0: suggestions.append(f"ℹ️ AFR target reaches {max_afr:.1f}:1 - verify this is intentional (may be for decel)") ``` ### Technical Analysis For conventional gasoline air-fuel ratio values, a lower AFR number represents a richer mixture, while a higher number represents a leaner mixture. The analyzer reverses this relationship by describing AFR values below 10 or 11 as “lean.” The complementary check for AFR values above 16 is only recorded as an informational suggestion. Consequently, genuinely lean targets may not receive a warning of severity appropriate to the risk. A separate WOT heuristic may detect some unsafe targets, but it assumes that the bottom-right corner of the table represents high-load operation and does not reliably associate AFR values with their RPM and load axes. This is safety-critical validation logic: the analyzer is explicitly presented as suitable for reviewing a tune before engine startup or high-load testing. Incorrect classification may cause a user to misunderstand the direction of the fueling error. ### Attack Path 1. A user supplies an `.msq` file containing extremely rich or lean AFR target cells. 2. `parse_msq()` reads the AFR table and passes it to `analyze_afr_targets()`. 3. The function classifies very low AFR values as lean and treats globally high AFR values primarily as informational. 4. The generated report gives the user an incorrect or understated diagnosis. 5. The user relies on that report and changes the fuel map in the wrong direction, or proceed ...[truncated 1150 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Correct the AFR terminology and severity logic: - Low AFR values should be classified as rich. - High AFR values should be classified as lean. - Unsafe lean values under significant load should generate warnings or critical findings rather than informational notes. 2. Do not infer operating conditions solely from table position. Parse and use the AFR table's RPM and load-axis bins to classify each cell according to actual engine load and speed. 3. Distinguish operating contexts: - Idle and cruise. - Naturally aspirated high load. - Boosted high load. - Deceleration and fuel-cut regions. 4. Require engine and fuel context before making categorical safety claims. Relevant inputs include fuel type, forced-induction status, lambda/AFR representation, and sensor calibration. 5. Add unit tests covering: - AFR below 10 as very rich, not lean. - Safe WOT target ranges. - AFR above 14 under high load as potentially dangerous. - Lean deceleration cells that are intentional. - Tables whose axis ordering differs from the assumed orientation. 6. Clearly state when the analyzer cannot identify load context reliably and avoid presenting heuristic results as definitive safety approval. ]]>

T09 · Insecure Skill Coding Practices

Error
Location
references/megasquirt-tuning-guide.md:122
Finding
Reversed VE Correction Formula Can Amplify Fueling Errors<![CDATA[ ## Vulnerability Details **File Location**: `references/megasquirt-tuning-guide.md`, lines 122–129 **Vulnerability Type**: Incorrect safety-critical tuning formula **Risk Level**: High ### Vulnerable Documentation ```text ### AFR-Based Calculation ``` New VE = Current VE × (Target AFR / Measured AFR) ``` Example: - Target: 14.0 - Measured: 12.5 (rich) - Current VE: 70 - New VE: 70 × (14.0/12.5) = 78.4 ``` ### Technical Analysis The documented correction ratio is reversed. When measured AFR is lower than target AFR, the engine is richer than intended and the VE value should normally be reduced. The documented formula instead increases VE. In the supplied example, the measured mixture is rich at 12.5 AFR against a target of 14.0 AFR. Increasing VE from 70 to 78.4 commands additional fuel and worsens the rich condition. The expected correction using the relationship documented elsewhere in this project is: ```text New VE = Current VE × (Measured AFR / Target AFR) New VE = 70 × (12.5 / 14.0) = 62.5 ``` The defect is especially concerning because `SKILL.md` contains the opposite, correct ratio. The contradictory bundled instructions can cause inconsistent Agent responses depending on which document is consulted. ### Attack Path 1. A user asks the Agent how to correct a VE table based on measured and target AFR. 2. The Agent consults `references/megasquirt-tuning-guide.md`. 3. The Agent applies `Target AFR / Measured AFR` as instructed. 4. For a rich condition, the calculated VE value increases; for a lean condition, it decreases. 5. The user enters the recommended VE value into TunerStudio and loads it into the ECU. 6. The existing fueling error becomes more severe during engine operation. 7. Repeated use of the same correction method can progressively move the tune farther from the intended AFR. No operating-system privileges are gained, and the issue does not provide code execution or access to protected information. The affected authority is ...[truncated 776 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Replace the formula with: ```text New VE = Current VE × (Measured AFR / Target AFR) ``` 2. Correct the example: ```text Target AFR: 14.0 Measured AFR: 12.5 Current VE: 70 New VE = 70 × (12.5 / 14.0) = 62.5 ``` 3. Explain the expected direction explicitly: - Measured AFR below target means rich; reduce VE. - Measured AFR above target means lean; increase VE. 4. Reconcile all duplicated formulas across `SKILL.md`, `README.md`, and reference files so that only one authoritative formulation is presented. 5. Add automated documentation consistency tests or source formulas from a shared canonical document. 6. Add worked tests for both directions: - Rich measurement must produce a lower VE. - Lean measurement must produce a higher VE. 7. Retain safety caveats requiring small incremental changes, validated sensor calibration, datalog review, and professional or dyno verification before high-load operation. ]]>
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • 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
Findings (7)

Missing User Warnings

High
Confidence
98% confidence
Finding
This skill gives detailed ECU calibration and ignition/fueling guidance that can directly affect engine operation, but it does not prominently warn users about engine damage, knock, runaway boost, fire risk, or the need for controlled test conditions and qualified supervision. Because the content includes actionable parameter ranges and adjustment steps, omission of explicit safety constraints makes misuse substantially more dangerous in real-world tuning sessions.

Vague Triggers

Medium
Confidence
95% confidence
Finding
The invocation description is extremely broad, including 'Any Megasquirt/TunerStudio ECU tuning tasks,' which can cause the skill to trigger for a wide range of automotive/engine-management requests. In a safety-critical domain, overbroad routing increases the chance users receive specialized tuning guidance in contexts where the model lacks sufficient situational awareness, increasing risk of unsafe advice being applied to real hardware.

Missing User Warnings

Medium
Confidence
90% confidence
Finding
This finding is valid because the guide recommends ignition timing changes and testing methods including 'dyno or long straight road' without an explicit safety warning against public-road tuning or advising qualified supervision. In the context of engine tuning, these actions can cause detonation, loss of control, or engine damage, especially for inexperienced users following the instructions directly.

Missing User Warnings

Medium
Confidence
90% confidence
Finding
The VE Analyze section describes enabling live autotune, letting it adjust cells, and then saving the tune, but it does not clearly warn that incorrect AFR targets, bad sensor calibration, or poor filter settings can produce unsafe fueling changes that may damage an engine or make a vehicle unsafe to operate. In an ECU tuning context, users may treat the workflow as routine and apply changes directly to a running vehicle, so omission of explicit cautions materially increases operational risk.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The firmware update instructions describe downloading firmware and upgrading the controller with only a brief 'do not interrupt' note, but they lack explicit recovery/backup guidance for a potentially destructive flashing operation. If a user proceeds without backing up the tune, ensuring stable power, or understanding recovery steps, an interrupted or incorrect flash can leave the ECU inoperable or misconfigured, potentially immobilizing the vehicle or creating unsafe engine behavior.

Intent-Code Divergence

Medium
Confidence
97% confidence
Finding
The symlink protection is ineffective because Path.resolve() follows symlinks before the code checks is_symlink(), so a symlinked .msq path will be converted to its target and no longer appear as a symlink. This defeats the stated local file disclosure protection and can allow reading arbitrary readable files through a crafted symlink, especially if the script is run with higher privileges or against attacker-controlled directories.

Scope Creep

Low
Category
Excessive Agency
Content
- Having the technical knowledge to safely implement tuning changes

### No Warranty
This skill is provided **"AS IS"** without warranty of any kind, express or implied, including but not limited to:
- Accuracy of information
- Fitness for a particular purpose
- Non-infringement
Confidence
70% confidence
Finding
Skill's behavior or capabilities extend beyond its stated purpose. Scope creep allows an agent to perform actions unrelated to its documented functionality, increasing the attack surface.