Skip to content

security(export): neutralize formula injection in revenue report CSV … - #981

Merged
thlpkee20-wq merged 2 commits into
RevoraOrg:masterfrom
CiiscoTech-Hub:fix/revenue-report-csv-formula-injection
Oct 22, 2026
Merged

thlpkee20-wq merged 2 commits into
RevoraOrg:masterfrom
CiiscoTech-Hub:fix/revenue-report-csv-formula-injection

Conversation

@CiiscoTech-Hub

Copy link
Copy Markdown

pr Closes #915

Pull Request Description
Title

security(export): neutralize formula injection in revenue report CSV export (CWE-1236)

Summary

Resolves spreadsheet formula injection (CSV injection, CWE-1236) in the revenue report exporter utility (src/utils/reportExport.ts). Previously, escapeCsvCell only quoted cells containing ", ,, \r, or \n. Free-text fields such as report notes were exported without prefix sanitization, allowing inputs starting with formula triggers (=, +, -, @, \t, \r) to execute when opened in spreadsheet software (Excel, Google Sheets).

Changes
Sanitize Dangerous Prefixes:
Hardened escapeCsvCell and exported sanitizeCsvCell: if a string field starts with =, +, -, @, \t (TAB), or \r (CR), it is prepended with a single quote ('), followed by RFC-4180 quoting rules.
Preserve Numeric Amount Columns:
Differentiated numeric amount columns generated by the exporter (such as "Gross revenue" and "Estimated payout") from user-provided string columns. Negative numbers emitted by code remain numeric and are not prefixed with ', while string/user-controlled fields starting with - or other dangerous prefixes are neutralised.
Added ToCsvOptions and EscapeCsvCellOptions interfaces so other CSV writers can configure and reuse escapeCsvCell and sanitizeCsvCell.
Automated & Regression Tests:
Added focused unit tests in src/utils/reportExport.test.ts:
Verified each dangerous prefix (=, +, -, @, \t, \r) is neutralized.
Verified plain text and quoted text behavior remain unchanged.
Verified numeric amount columns remain unchanged and retain valid negative numeric formatting.
Added regression test for CWE-1236 ensuring payload notes such as =HYPERLINK("http://example.invalid","click") are treated as literal text.
Verification
Ran Vitest suite on src/utils/reportExport.test.ts (17/17 tests passing).
Ran Vitest suite on src/components/RevenueReportForm.test.tsx (6/6 tests passing).
Ran ESLint on modified files with zero errors or warnings.

…export

- Harden escapeCsvCell and sanitizeCsvCell by prepending a single quote to cells beginning with '=', '+', '-', '@', TAB, or CR before applying RFC-4180 quoting rules
- Ensure numeric amount columns generated by the exporter remain numeric while user string fields are safely sanitized
- Export escapeCsvCell, sanitizeCsvCell, and associated types for reuse
- Add unit and regression tests in src/utils/reportExport.test.ts
@drips-wave

drips-wave Bot commented Oct 21, 2026

Copy link
Copy Markdown

@CiiscoTech-Hub Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@thlpkee20-wq
thlpkee20-wq merged commit 5ecf6c5 into RevoraOrg:master Oct 22, 2026
1 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

security(export): revenue report CSV export is vulnerable to spreadsheet formula injection

2 participants