T09 · Insecure Skill Coding Practices
- Location
SKILL.md:213- Finding
Spreadsheet Formula Injection in Excel Exports
- Content
View full analysis
str: """Export estimate to Excel.""" result = self.generate_estimate() with pd.ExcelWriter(output_path, engine='openpyxl') as writer: # Summary summary_df = pd.DataFrame([{ 'Project': self.project_name, 'Total QTO Items': result['total_qto_items'], 'Mapped Items': result['mapped_items'], 'Unmapped Items': result['unmapped_items'], 'Mapping Rate %': result['mapping_rate'], 'Total Cost': result['total_cost'] }]) summary_df.to_excel(writer, sheet_name='Summary', index=False) # Estimate items items_df = pd.DataFrame([{ 'Element ID': item.qto_element_id, 'Description': item.description, 'Quantity': item.quantity, 'Unit': item.unit, 'Unit Cost': item.unit_cost, 'Total Cost': item.total_cost, 'WBS': item.wbs_code, 'Rule': item.rule_applied } for item in self.estimate_items]) items_df.to_excel(writer, sheet_name='Estimate', index=False) # By element type by_type_df = pd.DataFrame([ {'Element Type': k, 'Cost': v} for k, v in self.get_cost_by_element_type().items() ]) by_type_df.to_excel(writer, sheet_name='By Type', index=False) # Unmapped items unmapped_df = self.get_unmapped_summary() if not unmapped_df.empty: unmapped_df.to_excel(writer, sheet_name='Unmapped', index=False) return output_path ``` ### Technical Analysis The export routine writes values derived from user-provided QTO and pricing-rule data directly into an XLSX workbook through Pandas and `openpyxl`. Re ...[truncated 2216 chars]- Remediation
View remediation
pd.DataFrame: return df.map(sanitize_excel_value) items_df = sanitize_dataframe(items_df) items_df.to_excel(writer, sheet_name="Estimate", index=False) ``` Where supported, explicitly forcing untrusted cells to the spreadsheet text type is preferable to relying solely on prefix escaping. ]]>
