Skip to content

fix: sanitize CSV export to prevent spreadsheet formula injection#888

Open
Pcmhacker-piro wants to merge 1 commit into
SdSarthak:mainfrom
Pcmhacker-piro:fix/csv-formula-sanitization
Open

fix: sanitize CSV export to prevent spreadsheet formula injection#888
Pcmhacker-piro wants to merge 1 commit into
SdSarthak:mainfrom
Pcmhacker-piro:fix/csv-formula-sanitization

Conversation

@Pcmhacker-piro
Copy link
Copy Markdown

Summary

Closes #793

Sanitize CSV export fields starting with =, +, -, or @ by prepending a single quote (') to prevent formula injection when the exported CSV is opened in Excel or LibreOffice. Adds a shared sanitize_csv_field() helper in app/core/csv_utils.py for reuse across future export endpoints.

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactor
  • Tests
  • Infra / CI

Checklist

  • I have read CONTRIBUTING.md
  • My code follows the project style (PEP 8 for Python, ESLint for TS)
  • I have added/updated tests where relevant
  • pytest backend/tests/ passes locally
  • I have not committed .env or any secrets
  • I have updated documentation if needed

Escape fields starting with =, +, -, or @ by prepending a single quote
to prevent formula execution when CSV is opened in Excel/LibreOffice.

- Add shared sanitize_csv_field() helper in app/core/csv_utils.py
- Apply sanitization to all string fields in export_ai_systems()
- Add tests for =HYPERLINK, +, -, and @ prefix injection vectors
@Pcmhacker-piro
Copy link
Copy Markdown
Author

hii @SdSarthak

the checks have passed. Could you please review and approve the pending workflows when you have a chance? Thank you!

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.

CSV export is vulnerable to spreadsheet formula injection

1 participant