T09 · Insecure Skill Coding Practices
- Location
SKILL.md:429- Finding
Unvalidated Numeric Inputs Permit Invalid Refund Calculations
- Content
View full analysis
= 0 quantity_ordered >= 0 0 <= quantity_acceptable <= quantity_received <= quantity_ordered ``` If `quantity_received` or `quantity_acceptable` exceeds `quantity_ordered`, the subtraction produces a negative quantity and therefore a negative refund. Negative prices or quantities can also produce invalid totals. Conversely, inconsistent values may result in excessive or otherwise incorrect refund recommendations. The interactive wrapper catches only conversion errors. It does not reject successfully parsed but invalid values. The function itself also exposes no validation boundary, so direct callers can supply arbitrary numeric arguments. Using binary floating-point values for currency additionally creates a risk of rounding discrepancies, although the primary vulnerability is the absence of range and consistency validation. ### Attack Path 1. An attacker or malformed upstream record supplies inconsistent values, such as: ```python calculate_refund( product_price=25.0, quantity_ordered=2, quantity_received=5, quantity_acceptable=0, problem_type="shortage", is_platform_fault=False, ) ``` 2. The function calculates: ```text 25 × (2 - 5) = -75 ``` 3. The negative amount is returned as the recommend ...[truncated 944 chars]- Remediation
View remediation
