T09 · Insecure Skill Coding Practices
- Location
SKILL.md:64- Finding
Incorrect Normal CDF Implementation Corrupts Financial Pricing and Risk Calculations
- Content
View full analysis
6: return 1.0 a1, a2, a3, a4, a5 = 0.254829592, -0.284496736, 1.421413741, -1.453152027, 1.061405429 p = 0.3275911 sign = 1.0 if x >= 0 else -1.0 x_abs = abs(x) t = 1.0 / (1.0 + p * x_abs) y = 1.0 - (((((a5 * t + a4) * t) + a3) * t + a2) * t + a1) * t * math.exp(-x_abs * x_abs / 2) return y if sign > 0 else 1.0 - y ``` ### Technical Analysis The coefficients in this implementation are intended for an approximation of the error function, `erf(x)`, rather than direct evaluation of the standard normal cumulative distribution function. The standard relationship is: ```text N(x) = 0.5 × (1 + erf(x / sqrt(2))) ``` The implementation does not apply the required `x / sqrt(2)` transformation or the final `0.5 × (1 + ...)` conversion. Consequently, it produces fundamentally incorrect results. For example, the standard normal CDF must satisfy `N(0) = 0.5`, whereas this implementation returns a value approximately equal to zero. This function is subsequently used by the documented Black–Scholes pricing, implied-volatility, and Greek calculations. The defect therefore propagates into option prices, Delta, Theta, Rho, and iterative implied-volatility results. Because the Skill presents those outputs as actionable financial analysis, this is a material integrity flaw. ### Attack Path 1. A user asks the agent to price an option, calculate implied volatility, or calculate Greeks. 2. The agent uses or reproduces the documented `norm_cdf` implementation. 3. The malformed CDF returns incorrect probabilities. 4. Those values are consumed by the Black–Scholes and risk calculations. 5. ...[truncated 1014 chars]- Remediation
View remediation
