[critical] fix: [export_mod] sanitize CSV values against formula injection - #891
Open
elhoim wants to merge 1 commit into
Open
[critical] fix: [export_mod] sanitize CSV values against formula injection#891elhoim wants to merge 1 commit into
elhoim wants to merge 1 commit into
Conversation
threat_connect_export.py and threatStream_misp_export.py write attacker-controlled attribute values and comments directly into CSV cells. A MISP attribute whose value or comment starts with =, +, -, or @ is interpreted as a formula by Excel, Google Sheets, and LibreOffice Calc when the exported CSV is opened, letting a malicious event trigger arbitrary formula execution (including calls out to external resources or, with legacy DDE support, command execution) on the analyst's machine. Both modules now prefix any such value with a leading single quote before writing it, neutralizing the formula interpretation while leaving normal values unchanged. Verified with flake8 (clean) and the full pytest suite against a live modules server on port 6783: 161 passed, 4 skipped, 5 subtests passed, matching baseline. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018dfYpyaSZd1nxSRLr8suj8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BLUF — Raw MISP values in exported CSVs execute as spreadsheet formulas; both export modules now sanitize.
threat_connect_export.pyandthreatStream_misp_export.pywrite MISP attribute values, comments and tags straight into CSV cells, so any value beginning with=,+,-or@is interpreted as a formula by Excel, Sheets or LibreOffice — the classic formula-injection path, and these values are attacker-influenced via ingested intel and event contributors.sanitize_csv_value()helper in each module that prefixes such values with a single quote, applied at all fourwriterowsites.Both
threat_connect_export.pyandthreatStream_misp_export.pywrite MISP attribute values and comments directly into CSV cells with no sanitization:If a MISP attribute value or comment begins with
=,+,-, or@, the exported CSV cell is interpreted as a formula by Excel, Google Sheets, or LibreOffice Calc when opened. This is the classic CSV/formula-injection pattern: since attribute values and comments are attacker-influenced (e.g. sourced from ingested threat intel or event contributors), an analyst who exports via one of these modules and opens the resulting CSV can have arbitrary spreadsheet formulas execute — including formulas that exfiltrate data or shell out viaDDE/WEBSERVICEstyle payloads.Fix
Added a small
sanitize_csv_value()helper in each module that prefixes any cell value starting with=,+,-, or@with a leading single quote, and applied it to theValue/Descriptionfields (threat_connect) andvalue/tagsfields (threatStream) at all fourwriterowsites. This is the standard OWASP-recommended mitigation for CSV/formula injection.Behaviour change
Exported cell content changes only for values that already begin with
=,+,-, or@: those cells now carry a leading single quote so spreadsheet applications treat them as literal text instead of a formula. All other values are unaffected.Verification
flake8clean (exit 0) on both changed files.161 passed, 4 skipped, 5 subtests passed in 41.40s.Found during a review of the repository; other findings are being submitted as separate PRs.
🤖 Generated with Claude Code