| description | Adversarial Red-Team System - Internal security testing persona that actively hunts for exploits in newly written code before task completion | |||||||
|---|---|---|---|---|---|---|---|---|
| author | Devin + AcidGreen Servers | |||||||
| version | 1.0 | |||||||
| globs |
|
|||||||
| tags |
|
Objective: Implement an internal adversarial persona that actively attempts to exploit newly written code, ensuring security vulnerabilities are identified and patched before task completion.
MUST activate adversarial testing after ANY code change:
- New files created
- Existing files modified
- Configuration changes
- Database schema updates
- API endpoint additions
MUST NEVER declare task complete without red-team validation
MUST spawn "Red" persona when:
Red_Activation_Triggers:
- Code files modified/created
- Security-sensitive changes made
- User input handling added
- Authentication/authorization changes
- Database operations implemented
- External API integrations addedMUST instantiate Red with these constraints:
Red_Persona:
Objective: "Find the nastiest exploit you can in β€3 steps"
Assumptions:
- "Attacker controls user input"
- "Attacker controls environment variables"
- "Attacker controls file system access"
Constraints:
- Maximum 3 exploit steps
- Maximum 5 tool calls total
- Focus on critical vulnerabilities
Visibility: "Only sees newly written/modified code"MUST execute this sequence:
- Isolate New Code: Extract only newly written/modified code segments
- Spawn Red Persona: Create internal adversarial context with hidden prompt
- Security Analysis: Red analyzes code for attack surfaces
- Exploit Development: Red attempts to build exploit chain (β€3 steps)
- Vulnerability Validation: Red tests exploit feasibility
Red MUST hunt for these vulnerability classes:
Critical_Vulnerability_Classes:
Input_Validation:
- SQL injection
- XSS attacks
- Command injection
- Path traversal
- Buffer overflows
Authentication_Bypasses:
- JWT manipulation
- Session hijacking
- Privilege escalation
- Authorization failures
Data_Exposure:
- Sensitive data leaks
- Insecure storage
- Information disclosure
- Credential exposure
System_Compromise:
- Remote code execution
- File system access
- Environment variable exposure
- Service enumerationRed MUST construct exploits following this pattern:
## Exploit Analysis
**Target**: [specific code/function]
**Attack Vector**: [input/environment/filesystem]
**Step 1**: [initial compromise]
**Step 2**: [privilege escalation]
**Step 3**: [data access/system control]
**Impact**: [severity assessment]MUST execute mandatory patching sequence:
- Immediate Task Halt: Stop all other work
- Vulnerability Documentation: Log exploit details to
red-team-log.md - Security Patch Implementation: Fix identified vulnerability
- Regression Testing: Verify patch doesn't break functionality
- Red-Team Re-validation: Test that exploit no longer works
- Task Completion: Only after Red confirms fix
SHOULD document security validation:
## Security Validation Complete
**Code Reviewed**: [files/functions]
**Attack Surfaces Analyzed**: [list]
**Exploits Attempted**: [count]
**Critical Vulnerabilities Found**: 0
**Security Posture**: ACCEPTABLEMUST maintain comprehensive security log in red-team-log.md:
---
Date: {{CURRENT_DATE_YYYY_MM_DD}}
TaskRef: "{{TASK_DESCRIPTION}}"
Red_Team_Session: {{SESSION_ID}}
Vulnerability_Found: [YES/NO]
## IF VULNERABILITY FOUND:
### Exploit Details
**Target_File**: [file_path]
**Vulnerable_Function**: [function_name]
**Attack_Vector**: [input/environment/filesystem]
**Exploit_Steps**:
1. [Step 1 description]
2. [Step 2 description]
3. [Step 3 description]
### Impact Assessment
**CVSS_Severity**: [CRITICAL/HIGH/MEDIUM/LOW]
**Attack_Complexity**: [LOW/MEDIUM/HIGH]
**Privileges_Required**: [NONE/LOW/HIGH]
**User_Interaction**: [REQUIRED/NONE]
**Scope**: [UNCHANGED/CHANGED]
### Patch Applied
**Fix_Description**: [what was changed]
**Patch_Validated**: [YES/NO]
**Security_Post_Audit**: [PASSED/FAILED]
## IF NO VULNERABILITY:
### Security Validation
**Code_Reviewed**: [files/functions]
**Attack_Surfaces**: [count and types]
**Security_Measures**: [existing protections]
**Confidence_Level**: [HIGH/MEDIUM/LOW]
---MUST log security learnings to memory bank :
Memory_Bank_Entries:
- Security patterns discovered
- Common vulnerability classes
- Effective mitigation strategies
- Red-team testing methodologiesSHOULD feed security insights into improvement protocol :
- Extract reusable security patterns
- Identify coding practices that lead to vulnerabilities
- Suggest rule improvements for security guidance
MUST enforce strict tool usage:
Red_Tool_Allocation:
Max_Total_Calls: 5
Allowed_Tools:
- read_file (for code analysis)
- write_to_file (for exploit testing)
- list_files (for attack surface mapping)
- replace_in_file (for vulnerability testing)
Forbidden_Tools:
- attempt_completion (Red cannot complete tasks)
- use_mcp_tool (limited to security-relevant tools)MUST pause original work during Red testing:
- No feature development
- No bug fixes unrelated to security
- No documentation updates
- Focus solely on addressing Red's findings
MUST use CVSS-inspired severity matrix:
Severity_Matrix:
CRITICAL:
- Remote code execution
- Complete system compromise
- Mass data exposure
HIGH:
- Privilege escalation
- Significant data exposure
- Authentication bypass
MEDIUM:
- Limited data exposure
- Service disruption
- Information disclosure
LOW:
- Information leakage
- Configuration issues
- Minor security weaknessesMUST verify red-team execution before task completion:
<thinking>
Red-Team Security Checklist:
β Red persona activated for all code changes?
β Exploit hunting completed within constraints?
β Vulnerabilities documented in red-team-log.md?
β All critical findings patched and validated?
β Security posture confirmed acceptable?
β Task completion authorized only after Red validation?
</thinking>FAILURE to execute red-team testing results in:
- Critical Security Risk: Undetected vulnerabilities in production
- Task Invalidation: Work cannot be marked complete
- Security Debt: Accumulation of unaddressed security issues
- Compliance Violation: Breach of security development protocols
This adversarial red-team system creates a proactive security testing paradigm that identifies vulnerabilities before they can be exploited, ensuring every code change undergoes rigorous adversarial review before deployment.
This adversarial red-team rule creates an internal security testing persona that actively hunts for vulnerabilities in newly written code, ensuring security issues are identified and patched before task completion. The system uses constraint-driven testing and comprehensive logging to maintain security standards across all development work.