Skip to content
Back to skills

Secure Csv Generation

ASecurity

Generate secure Comma Separated Values (CSV) generation code. Enforces secure generation of Comma Separated Values (CSV) content. Invoke when writing any Comma Separated Values (CSV) generation related code.

  • 7 stars
  • 0 votes
  • 0 copies
  • 5 views
  • Added October 24, 2026
ai-agentsgojavasecurity

Security analysis

A100/100

Scanned October 24, 2026

npx -y skills add righettod/code-assistant-skills-security-utils --skill secure-csv-generation --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Secure Csv Generation?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Secure Csv Generation
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/righettod-secure-csv-generation/badge)](https://www.skillsdirectory.com/skills/righettod-secure-csv-generation)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: secure-csv-generation
description: Generate secure Comma Separated Values (CSV) generation code. Enforces secure generation of Comma Separated Values (CSV) content. Invoke when writing any Comma Separated Values (CSV) generation related code.
allowed-tools: Read Grep Glob
metadata:
  category: security
---

# Secure Comma Separated Values (CSV) Code Generation Rules

Apply **all** rules below when generating or reviewing any code related to Comma Separated Values (CSV) content generation.

## 1. CSV injection Prevention (CRITICAL)

- ALWAYS ensure that if any field value start with one of the following character `=`, `+`, `-`, `@`, `\t`, `\r` then a single quote is added at the beginning of the value to disable the CSV injection.

```java
// BAD: Content of fields are not validated to detect and disable any CSV injection
String     filePath = "output.csv";
String[][] rows     = {{"Name", "=CMD|' /C calc'!A0"}, {"Bob", "+1234"}};
try (PrintWriter writer = new PrintWriter(new FileWriter(filePath))) {
    for (String[] row : rows) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < row.length; i++) {
            String field = row[i] == null ? "" : row[i];
            if (field.contains(",") || field.contains("\"") || field.contains("\n"))
                field = "\"" + field.replace("\"", "\"\"") + "\"";
            if (i > 0) sb.append(",");
            sb.append(field);
        }
        writer.println(sb);
    }
}

// GOOD: Dangerous characters used in CSV injection are prefixed to disable the injection
String     filePath = "output.csv";
String[][] rows     = {{"Name", "=CMD|' /C calc'!A0"}, {"Bob", "+1234"}};
try (PrintWriter writer = new PrintWriter(new FileWriter(filePath))) {
    for (String[] row : rows) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < row.length; i++) {
            String field = row[i] == null ? "" : row[i];

            // Prepend single quote to disable CSV injection
            if (!field.isEmpty() && "=+-@\t\r".indexOf(field.charAt(0)) >= 0)
                field = "'" + field;

            if (field.contains(",") || field.contains("\"") || field.contains("\n"))
                field = "\"" + field.replace("\"", "\"\"") + "\"";

            if (i > 0) sb.append(",");
            sb.append(field);
        }
        writer.println(sb);
    }
}
```

## 2. Output Checklist

Before finalizing generated code, verify:

- [ ] Dangerous characters used in CSV injection are detected and then prefixed to disable the injection.

## References

- [CSV injection information from WE45](https://www.we45.com/post/your-excel-sheets-are-not-safe-heres-how-to-beat-csv-injection).
- [CSV injection information from OWASP](https://owasp.org/www-community/attacks/CSV_Injection).

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.