10 Prompts for Security and DevSecOps: Audit, Scanning, and Policies

Why You Need a Prompt Library for DevSecOps

Security in software development is no longer optional – it's a fundamental requirement. According to the 2025 OWASP Top 10, injection flaws and broken access control remain the most critical risks, yet many teams struggle to integrate security checks early. Traditional security audits are manual, slow, and often miss context. AI-powered prompts can automate SAST, DAST, and policy validation, giving you consistent, explainable results in minutes.

This collection of 10 prompts covers real-world DevSecOps scenarios: from scanning code for vulnerabilities to crafting least-privilege policies. Each prompt includes a task, the exact prompt text, and a concrete example output. Use them as templates in your CI/CD pipeline, security reviews, or compliance audits.

Prompts for Security Audits and Scanning

1. Static Application Security Testing (SAST) – Code Review

Task: Identify injection vulnerabilities in Python code.
Prompt:

You are a senior security engineer. Review the following Python function for SQL injection, command injection, and path traversal vulnerabilities. For each issue found, provide:
- Line number
- Vulnerability type (CWE ID)
- Severity (Critical/High/Medium/Low)
- Remediation code

Code:
import sqlite3
def get_user(user_id):
    conn = sqlite3.connect('users.db')
    query = f"SELECT * FROM users WHERE id = {user_id}"
    return conn.execute(query).fetchall()

Example result:

Line Vulnerability CWE Severity Fix
4 SQL Injection CWE-89 Critical Use parameterized query: conn.execute("SELECT * FROM users WHERE id = ?", (user_id,))

2. Dynamic Application Security Testing (DAST) – API Scan

Task: Generate test payloads for API endpoint fuzzing.
Prompt:

Generate 10 test payloads for DAST on a REST API endpoint `POST /api/login`. Include payloads for:
- SQL injection (e.g., `' OR 1=1--`)
- XSS (e.g., `<script>alert(1)</script>`)
- NoSQL injection (e.g., `{"$ne": null}`)
- Path traversal (e.g., `../../../etc/passwd`)
- Command injection (e.g., `; ls -la`)

Format as a JSON array of objects with fields: "payload", "attack_type", "expected_behavior".

Example result:

[
  {"payload": "' OR '1'='1", "attack_type": "SQLi", "expected_behavior": "HTTP 200 with all users returned"},
  {"payload": "<script>alert('xss')</script>", "attack_type": "XSS", "expected_behavior": "Script reflected in response"}
]

3. Dependency Vulnerability Scanning

Task: Audit a package.json for known vulnerabilities.
Prompt:

Analyze this package.json dependencies for known vulnerabilities. Use NVD and Snyk advisory databases (as of July 2026). For each vulnerable package, list:
- Package name and version
- CVE ID and CVSS score
- Fixed version
- Impact

Dependencies:
{
  "express": "4.17.1",
  "lodash": "4.17.20",
  "axios": "0.21.1"
}

Example result:

Package Version CVE CVSS Fixed in
lodash 4.17.20 CVE-2021-23337 7.5 4.17.21
axios 0.21.1 CVE-2021-3749 6.1 0.21.2

4. Infrastructure-as-Code (IaC) Security Scan

Task: Review Terraform for misconfigurations.
Prompt:

You are a cloud security expert. Review this Terraform snippet for security misconfigurations following the CIS AWS Foundations Benchmark v2.0. Check for: open security groups, unencrypted S3 buckets, and public access to RDS.

resource "aws_s3_bucket" "data" {
  bucket = "my-data-bucket"
  acl    = "public-read"
}

resource "aws_security_group" "web" {
  ingress {
    from_port = 22
    to_port   = 22
    protocol  = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }
}

Example result:
- S3 Bucket: ACL set to public-read – risk of data exposure (CIS 2.1.1). Fix: set acl = "private" or use bucket policy.
- Security Group: SSH open to 0.0.0.0/0 (CIS 4.1.1). Fix: restrict to specific IPs.

Prompts for Access Policies and Compliance

5. Least-Privilege AWS IAM Policy Generator

Task: Generate minimal IAM policy for a CI/CD role.
Prompt:

Create an AWS IAM policy with least-privilege permissions for a CI/CD role that needs to:
- Deploy EC2 instances (RunInstances, TerminateInstances)
- Push images to ECR (PutImage, BatchCheckLayerAvailability)
- Describe CloudFormation stacks

Use explicit deny for all other actions. Format as a JSON policy document.

Example result:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": ["ec2:RunInstances", "ec2:TerminateInstances"],
      "Resource": "*"
    },
    {
      "Effect": "Allow",
      "Action": ["ecr:PutImage", "ecr:BatchCheckLayerAvailability"],
      "Resource": "*"
    },
    {
      "Effect": "Allow",
      "Action": ["cloudformation:DescribeStacks"],
      "Resource": "*"
    },
    {
      "Effect": "Deny",
      "NotAction": ["ec2:*", "ecr:*", "cloudformation:DescribeStacks"],
      "Resource": "*"
    }
  ]
}

6. Kubernetes RBAC Policy Reviewer

Task: Audit a Kubernetes Role for over-permissive rules.
Prompt:

Review this Kubernetes Role for security best practices. Identify any permissions that violate the principle of least privilege. Suggest a restricted version.

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  namespace: production
rules:
- apiGroups: [""]
  resources: ["pods", "secrets"]
  verbs: ["get", "list", "watch", "create", "delete"]

Example result:
- Issue: delete on secrets is dangerous. If the pod only needs to read secrets, remove create and delete.
- Fix: Change verbs to ["get", "list"] for secrets.

7. GDPR Compliance Checklist Generator

Task: Generate compliance checks for a web app.
Prompt:

Generate a 10-item GDPR compliance checklist for a web application that processes user email addresses and browsing history. Include: data minimization, consent management, right to erasure, and breach notification. For each item, provide a description and a test command (e.g., curl or SQL query) to verify compliance.

Example result:

# Check Verification
1 User consent recorded before processing Query: SELECT * FROM consent_log WHERE user_id = ? AND consent = TRUE
2 Data retention policy enforced Check cron job deletes records older than 12 months

8. Incident Response Playbook Prompt

Task: Create a step-by-step playbook for a data breach.
Prompt:

Write a concise incident response playbook for a suspected database breach in a production environment. Cover:
1. Immediate containment (isolate server)
2. Evidence collection (logs, database dumps)
3. Communication plan (who to notify)
4. Remediation steps (rotate credentials, patch vulnerability)
5. Post-mortem analysis

Use the NIST Incident Response Framework (SP 800-61 Rev 2).

Example result:
- Containment: Run iptables -A INPUT -s 10.0.0.0/8 -j DROP to isolate the database server.
- Evidence: Use pg_dump to create a snapshot of the database before any changes.

9. Threat Modeling for Microservices

Task: Identify threats in a microservice architecture using STRIDE.
Prompt:

Perform a STRIDE threat model on a microservice that handles payment transactions. The service:
- Accepts credit card data via REST API
- Stores tokenized data in a vault
- Communicates with a fraud detection service via gRPC

For each threat type (Spoofing, Tampering, Repudiation, Information Disclosure, Denial of Service, Elevation of Privilege), provide one concrete example and a mitigation.

Example result:
- Spoofing: An attacker impersonates the fraud detection service. Mitigation: mutual TLS (mTLS) between services.
- Information Disclosure: Credit card data in API logs. Mitigation: strip sensitive fields before logging.

10. Secure Code Review Checklist

Task: Generate a checklist for code review sessions.
Prompt:

Create a checklist of 15 security checks for a peer code review. Cover OWASP Top 10 categories: injection, broken authentication, sensitive data exposure, XML external entities, broken access control, security misconfiguration, cross-site scripting, insecure deserialization, using components with known vulnerabilities, insufficient logging. For each check, provide a one-sentence question the reviewer should ask.

Example result:

# Check Question
1 Are all database queries parameterized?
2 Is user input validated and sanitized?
3 Are passwords hashed (bcrypt/argon2)?
4 Are error messages generic (no stack traces)?
5 Are dependencies pinned to secure versions?

Conclusion

Integrating these prompts into your daily DevSecOps workflow can reduce manual audit time by up to 80% while increasing coverage. Start by picking one prompt – for example, the SAST code review – and run it on your most critical codebase. Then gradually add DAST payloads, IaC scans, and policy generators. The goal is not to replace human judgment but to augment it with fast, consistent automation.

Remember: security is a continuous process. Revisit your prompts every quarter, update them with new attack patterns, and share your findings with the team. Now go scan something.

← All posts

Comments