T09 · Insecure Skill Coding Practices
- 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: MediumVulnerable Code
python lambda_cl = lambda_factor * tau Kp = tau / (K * lambda_cl) Ki = Kp / tau Kd = 0.0Technical Analysis
The
calculate_imc_gainsimplementation usesK,tau, andlambda_factorin division operations without validating their type, range, sign, or finiteness.A value of zero for
K,tau, orlambda_factorcan lead to division by zero. Negative values can produce gains inconsistent with the documented first-order tuning assumptions, whileNaNor 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
- A caller supplies an invalid parameter, such as
K=0,tau=0, orlambda_factor=0. - The function calculates
lambda_cland performs division using the invalid value. - Python raises a
ZeroDivisionError, causing the tuning operation to fail. - Alternatively, a caller supplies negative, infinite, or
NaNvalues. - Invalid controller gains are returned and may be passed to a downstream PI controller.
- 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.
- A caller supplies an invalid parameter, such as
- Remediation
View remediation
Remediation Suggestions
Validate all tuning parameters before performing calculations:
- Require
K,tau, andlambda_factorto be numeric and finite. - Reject
K == 0. - Require
tau > 0andlambda_factor > 0. - Define application-specific upper and lower limits for gains and process parameters.
- Raise a clear
TypeErrororValueErrorwhen 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, }- Require
