T09 · Insecure Skill Coding Practices
- Location
scripts/parse_buyma_csv.py:57- Finding
Untrusted CSV Values Can Be Written as Executable Spreadsheet Formulas
- Content
View full analysis
- Remediation
View remediation
str: text = "" if value is None else str(value) stripped = text.lstrip() if stripped.startswith(("=", "+", "-", "@")): return "'" + text return text cell = ws[f"{col}{row}"] cell.value = safe_spreadsheet_text(rec.get(key, "")) cell.data_type = "s" ``` 5. Do not apply textual escaping to legitimate numeric fields. Validate and convert those fields to `int`, `Decimal`, or another expected numeric type instead. 6. Extend `validate_output.py` to inspect `cell.data_type` and fail if any externally populated cell is a formula: ```python if cell.data_type == "f": formula_cells.append(cell.coordinate) ``` 7. Add tests using values with leading `=`, whitespace followed by `=`, and other common formula prefixes. 8. Do not send or publish the workbook if formula validation fails. ]]>
