Back to skill

Security audit

imc-tuning-rules

Security checks for vulnerabilities and agentic risk

Overview

This skill is a small instructional guide for IMC controller tuning, with some engineering safety caveats missing but no hidden execution, persistence, or data access.

Install only if you want educational IMC tuning guidance. Do not directly deploy the sample gains or controller code to physical equipment without engineering review, parameter validation, explicit output limits, anti-windup behavior, simulation, and supervised staged testing.

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
SKILL.md:63
Finding

Unvalidated Process Parameters Can Cause Denial of Service or Unsafe Controller Gains

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 63–67
Vulnerability Type: Missing numeric input validation
Risk Level: Medium

Vulnerable Code

python
lambda_cl = lambda_factor * tau

Kp = tau / (K * lambda_cl)
Ki = Kp / tau
Kd = 0.0

Technical Analysis

The calculate_imc_gains implementation uses K, tau, and lambda_factor in division operations without validating their type, range, sign, or finiteness.

A value of zero for K, tau, or lambda_factor can lead to division by zero. Negative values can produce gains inconsistent with the documented first-order tuning assumptions, while NaN or infinite floating-point values can propagate invalid gains into the controller.

Exploitation requires an attacker, untrusted caller, or malformed upstream process model to control the tuning parameters. This issue does not grant operating-system privileges, but it can compromise the availability and integrity of controller calculations.

Attack Path

  1. A caller supplies an invalid parameter, such as K=0, tau=0, or lambda_factor=0.
  2. The function calculates lambda_cl and performs division using the invalid value.
  3. Python raises a ZeroDivisionError, causing the tuning operation to fail.
  4. Alternatively, a caller supplies negative, infinite, or NaN values.
  5. Invalid controller gains are returned and may be passed to a downstream PI controller.
  6. The affected control process may become unstable, unavailable, or produce unintended output.

Impact Assessment

The direct impact is denial of service in the gain-calculation path or loss of integrity in generated controller parameters. If the generated gains are used to operate physical equipment, the scope may extend to unstable or unsafe actuator behavior. No privilege escalation, arbitrary code execution, persistence, or data disclosure is enabled by this flaw.

Remediation
View remediation

Remediation Suggestions

Validate all tuning parameters before performing calculations:

  • Require K, tau, and lambda_factor to be numeric and finite.
  • Reject K == 0.
  • Require tau > 0 and lambda_factor > 0.
  • Define application-specific upper and lower limits for gains and process parameters.
  • Raise a clear TypeError or ValueError when validation fails.
  • Validate the calculated gains before returning them.

Example hardening:

python
import math

def calculate_imc_gains(K, tau, lambda_factor=1.0):
    values = {
        "K": K,
        "tau": tau,
        "lambda_factor": lambda_factor,
    }

    for name, value in values.items():
        if not isinstance(value, (int, float)) or isinstance(value, bool):
            raise TypeError(f"{name} must be numeric")
        if not math.isfinite(value):
            raise ValueError(f"{name} must be finite")

    if K == 0:
        raise ValueError("K must not be zero")
    if tau <= 0:
        raise ValueError("tau must be greater than zero")
    if lambda_factor <= 0:
        raise ValueError("lambda_factor must be greater than zero")

    lambda_cl = lambda_factor * tau
    Kp = tau / (K * lambda_cl)
    Ki = Kp / tau

    return {
        "Kp": Kp,
        "Ki": Ki,
        "Kd": 0.0,
        "lambda": lambda_cl,
    }

T09 · Insecure Skill Coding Practices

Warning
Location
SKILL.md:79
Finding

Undefined Output Bounds Cause PI Controller Runtime Failure

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 79–99
Vulnerability Type: Undefined safety-critical configuration variables
Risk Level: Medium

Vulnerable Code

python
class PIController:
    def __init__(self, Kp, Ki, setpoint):
        self.Kp = Kp
        self.Ki = Ki
        self.setpoint = setpoint
        self.integral = 0.0

    def compute(self, measurement, dt):
        """Compute control output."""
        error = self.setpoint - measurement

        # Integral term
        self.integral += error * dt

        # PI control law
        output = self.Kp * error + self.Ki * self.integral

        # Clamp to valid range
        output = max(output_min, min(output_max, output))

        return output

Technical Analysis

The compute method references output_min and output_max, but neither variable is passed to the method, stored on the controller instance, nor defined elsewhere in the reviewed project.

In the documented standalone implementation, every execution that reaches the clamp statement raises a NameError. If a consuming application works around the failure by defining mutable global variables with those names, output safety limits become dependent on external global state. Code capable of modifying that state could weaken or reverse the intended limits.

Exploitation does not provide additional system privileges. The security impact concerns availability of the controller and integrity of safety-critical output constraints.

Attack Path

  1. An application instantiates PIController using the documented constructor.
  2. The application calls compute() with a measurement and time interval.
  3. The method updates its integral state and calculates the preliminary output.
  4. Evaluation of output_min or output_max raises a NameError because the names are undefined.
  5. No controller output is returned, disrupting the control loop.

...[truncated 674 chars]

Remediation
View remediation

Remediation Suggestions

Make output bounds explicit instance configuration and validate them during initialization:

  • Add output_min and output_max constructor parameters.
  • Require both bounds to be finite numeric values.
  • Enforce output_min < output_max.
  • Refer to bounds through self.output_min and self.output_max.
  • Validate Kp, Ki, setpoint, measurement, and dt; require a finite, positive dt.
  • Add anti-windup logic so the integral does not continue accumulating while the output is saturated.
  • Add tests covering missing, reversed, infinite, and NaN bounds.

Example hardening:

python
class PIController:
    def __init__(self, Kp, Ki, setpoint, output_min, output_max):
        if output_min >= output_max:
            raise ValueError("output_min must be less than output_max")

        self.Kp = Kp
        self.Ki = Ki
        self.setpoint = setpoint
        self.output_min = output_min
        self.output_max = output_max
        self.integral = 0.0

    def compute(self, measurement, dt):
        if dt <= 0:
            raise ValueError("dt must be greater than zero")

        error = self.setpoint - measurement
        candidate_integral = self.integral + error * dt
        raw_output = self.Kp * error + self.Ki * candidate_integral
        output = max(self.output_min, min(self.output_max, raw_output))

        # Conditional integration provides basic anti-windup behavior.
        if output == raw_output:
            self.integral = candidate_integral

        return output
Vulnerability Patterns
  • 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
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
Findings (1)

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The skill provides concrete PI tuning formulas and implementation guidance, including aggressive tuning options, without any explicit safety warning about deploying these gains to real physical processes. In an industrial or embedded control context, blindly applying underspecified or overly aggressive gains can cause oscillation, actuator saturation, equipment stress, or unsafe process transients, especially because the sample controller also omits anti-windup and complete output-bound definitions.

Content

No source excerpt is available for this finding.