Enterprise-grade security constraints for AI-assisted development. Enforces secure coding practices, prevents common vulnerabilities, and blocks unsafe operations across backend, frontend, and DevOps workflows.
Enterprise-grade security constraints for AI-assisted development across all technology stacks.
This skill enforces strict security policies during code generation, preventing common vulnerabilities and ensuring secure-by-default practices. It blocks unsafe operations, enforces input validation, prevents secret leakage, and mandates security reasoning for sensitive operations.
**Secrets Management:**
**Code Execution:**
- JavaScript/Node: `eval()`, `Function()`, `vm.runInContext()`
- Shell: `exec()`, `spawn("sh", [userInput])`, piped shell commands with user input
- Python: `exec()`, `eval()`, `__import__(userInput)`
**Database Security:**
**Logging Security:**
- Passwords, tokens, API keys
- Authorization headers
- PII (emails, SSNs, phone numbers unless explicitly masked)
- Credit card numbers, session IDs
**Authentication:**
**Network Security:**
**Input Validation:**
- TypeScript: Zod, Joi, Yup
- Python: Pydantic, Marshmallow
- Go: validator, ozzo-validation
**Security Headers:**
- `Content-Security-Policy` (CSP)
- `Strict-Transport-Security` (HSTS)
- `X-Frame-Options: DENY`
- `X-Content-Type-Options: nosniff`
- `Referrer-Policy: strict-origin-when-cross-origin`
**Path Security:**
**Constants & Clarity:**
**Error Handling:**
**CORS & Cookies:**
**HTTP Headers:**
**File Access:**
**Web Contexts:**
**Docker/Bash:**
**`.cursorignore` Rules:**
```
.env
.env.*
*.pem
*.key
secrets.*
credentials.json
private/
.ssh/
```
**Rule-Check Marker:**
Add to generated files:
```
// RULE-CHECK: Secure rules active
```
**Security Intent Comments:**
For validation, auth, crypto, database, or network code, add:
```
// [SECURITY INTENT]: [What this protects and why it's necessary]
```
Example:
```javascript
// [SECURITY INTENT]: Rate limiting prevents brute-force attacks on login endpoint
const limiter = rateLimit({ windowMs: 15 * 60 * 1000, max: 5 });
```
**For Sensitive Operations:**
Add reasoning comment:
```
// [SECURITY REASONING]: [Why this approach is safe and what threats it mitigates]
```
**Confirmation Protocol:**
**Backend Development:**
**Frontend Development:**
**DevOps/Infrastructure:**
- Docker: `secrets:` mounts
- Kubernetes: Secret resources
- CI/CD: Environment variable injection
**Rule Violation:**
If a request requires violating any security constraint, respond with:
```
โ ๏ธ This violates hardened security constraints. Action blocked.
Reason: [Specific rule violated]
Safe alternative: [Suggest secure approach]
```
**Uncertainty:**
If unsure whether an action is secure:
```
โ ๏ธ Unclear if this action is secure. Please clarify intent or constraints.
Concerns: [List potential security issues]
```
**Override Protocol:**
If user explicitly requests override, require:
1. Explicit confirmation with reasoning
2. Documentation of security trade-off
3. Mitigation plan
Tag all generated secure code with:
```
// [AI GENERATED SECURE CODE]
```
For security-critical sections, add both intent and reasoning:
```javascript
// [AI GENERATED SECURE CODE]
// [SECURITY INTENT]: Validates JWT token to authenticate API requests
// [SECURITY REASONING]: Uses standard library verification with RS256 to prevent token forgery
const decoded = jwt.verify(token, publicKey, { algorithms: ['RS256'] });
```
```javascript
// BLOCKED: Hardcoded credentials
const apiKey = "sk_live_abc123";
// BLOCKED: SQL injection risk
db.query(`SELECT * FROM users WHERE id = ${userId}`);
// BLOCKED: Dangerous HTML injection
<div dangerouslySetInnerHTML={{__html: userComment}} />
```
```javascript
// [AI GENERATED SECURE CODE]
// [SECURITY INTENT]: API key loaded from secure environment variables
const apiKey = process.env.STRIPE_API_KEY;
// [SECURITY INTENT]: Parameterized query prevents SQL injection
const user = await db.query('SELECT * FROM users WHERE id = $1', [userId]);
// [SECURITY INTENT]: Sanitized HTML prevents XSS attacks
import DOMPurify from 'dompurify';
const clean = DOMPurify.sanitize(userComment);
<div dangerouslySetInnerHTML={{__html: clean}} />
```
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/hardened-security-cursor-rules/raw