| name | arch-security-review |
| description | [Architecture] Use when reviewing code for security vulnerabilities, implementing authorization, or ensuring data protection. Use when this capability is needed. |
[IMPORTANT] Use TaskCreate to break ALL work into small tasks BEFORE starting — including tasks for each file read. This prevents context loss from long files. For simple tasks, AI MUST ATTENTION ask user whether to skip.
Evidence-Based Reasoning — Speculation is FORBIDDEN. Every claim needs proof.
- Cite
file:line, grep results, or framework docs for EVERY claim
- Declare confidence: >80% act freely, 60-80% verify first, <60% DO NOT recommend
- Cross-service validation required for architectural changes
- "I don't have enough evidence" is valid and expected output
BLOCKED until: - [ ] Evidence file path (file:line) - [ ] Grep search performed - [ ] 3+ similar patterns found - [ ] Confidence level stated
Forbidden without proof: "obviously", "I think", "should be", "probably", "this is because"
If incomplete → output: "Insufficient evidence. Verified: [...]. Not verified: [...]."
docs/project-reference/domain-entities-reference.md — Domain entity catalog, relationships, cross-service sync (read when task involves business entities/models) (content auto-injected by hook — check for [Injected: ...] header before reading)
Critical Purpose: Ensure quality — no flaws, no bugs, no missing updates, no stale content. Verify both code AND documentation.
Quick Summary
Goal: Review code for security vulnerabilities against OWASP Top 10 and enforce authorization, data protection, and secure coding patterns.
Workflow:
- Pre-Flight — Identify security-sensitive areas, check OWASP relevance, review existing patterns
- OWASP Audit — Evaluate code against all 10 categories (access control, injection, auth, etc.)
- Project Checks — Verify authorization attributes, entity access expressions, input validation
- Report — Document findings with severity, vulnerable vs secure code examples
Key Rules:
- Always check both backend and frontend attack surfaces
- Use project authorization attributes and entity-level access expressions, never rely on UI-only guards (see docs/project-reference/backend-patterns-reference.md)
- Validate all external data with project validation API, never trust client input (see docs/project-reference/backend-patterns-reference.md)
Be skeptical. Apply critical thinking, sequential thinking. Every claim needs traced proof, confidence percentages (Idea should be more than 80%).
Security Review Workflow
When to Use This Skill
- Security audit of code changes
- Implementing authentication/authorization
- Data protection review
- Vulnerability assessment
Pre-Flight Checklist
OWASP Top 10 Checklist
1. Broken Access Control
[HttpGet("{id}")]
public async Task<Employee> Get(string id)
=> await repo.GetByIdAsync(id);
[HttpGet("{id}")]
[Authorize(Roles.Manager, Roles.Admin)]
public async Task<Employee> Get(string id)
{
var employee = await repo.GetByIdAsync(id);
if (employee.CompanyId != RequestContext.CurrentCompanyId())
throw new UnauthorizedAccessException();
return employee;
}
2. Cryptographic Failures
var apiKey = config["ApiKey"];
await SaveToDatabase(apiKey);
var encryptedKey = encryptionService.Encrypt(apiKey);
await SaveToDatabase(encryptedKey);
var apiKey = config.GetValue<string>("ApiKey");
3. Injection
var sql = $"SELECT * FROM Users WHERE Name = '{name}'";
await context.Database.ExecuteSqlRawAsync(sql);
await context.Users.Where(u => u.Name == name).ToListAsync();
await context.Database.ExecuteSqlRawAsync(
"SELECT * FROM Users WHERE Name = @p0", name);
4. Insecure Design
[HttpPost("login")]
public async Task<IActionResult> Login(LoginRequest request)
=> await authService.Login(request);
[HttpPost("login")]
[RateLimit(MaxRequests = 5, WindowSeconds = 60)]
public async Task<IActionResult> Login(LoginRequest request)
=> await authService.Login(request);
5. Security Misconfiguration
app.UseDeveloperExceptionPage();
if (env.IsDevelopment())
app.UseDeveloperExceptionPage();
else
app.UseExceptionHandler("/Error");
6. Vulnerable Components
dotnet list package --vulnerable
dotnet outdated
7. Authentication Failures
if (password.Length >= 4) { }
public class PasswordPolicy
{
public bool Validate(string password)
{
return password.Length >= 12
&& password.Any(char.IsUpper)
&& password.Any(char.IsLower)
&& password.Any(char.IsDigit)
&& password.Any(c => !char.IsLetterOrDigit(c));
}
}
8. Data Integrity Failures
var userData = await externalApi.GetUserAsync(id);
await SaveToDatabase(userData);
var userData = await externalApi.GetUserAsync(id);
var validation = userData.Validate();
if (!validation.IsValid)
throw new ValidationException(validation.Errors);
await SaveToDatabase(userData);
9. Logging Failures
Logger.LogInformation("User login: {Email} {Password}", email, password);
Logger.LogInformation("User login: {Email}", email);
10. SSRF (Server-Side Request Forgery)
var url = request.WebhookUrl;
await httpClient.GetAsync(url);
if (!IsAllowedUrl(request.WebhookUrl))
throw new SecurityException("Invalid webhook URL");
private bool IsAllowedUrl(string url)
{
var uri = new Uri(url);
return AllowedDomains.Contains(uri.Host)
&& uri.Scheme == "https";
}
Authorization Patterns
⚠️ MUST ATTENTION READ: CLAUDE.md for authorization controller/handler patterns, RequestContext usage, and entity-level access filters (see docs/project-reference/backend-patterns-reference.md).
Data Protection
Sensitive Data Handling
public class SensitiveDataHandler
{
public string EncryptForStorage(string plainText)
=> encryptionService.Encrypt(plainText);
public string MaskEmail(string email)
{
var parts = email.Split('@');
return $"{parts[0][0]}***@{parts[1]}";
}
public void LogUserAction(User user)
{
Logger.LogInformation("User action: {UserId}", user.Id);
}
}
File Upload Security
public async Task<IActionResult> Upload(IFormFile file)
{
var allowedTypes = new[] { ".pdf", ".docx", ".xlsx" };
var extension = Path.GetExtension(file.FileName).ToLowerInvariant();
if (!allowedTypes.Contains(extension))
return BadRequest("Invalid file type");
if (file.Length > 10 * 1024 * 1024)
return BadRequest("File too large");
if (!await antivirusService.ScanAsync(file))
return BadRequest("File rejected by security scan");
var safeFileName = $"{Guid.NewGuid()}{extension}";
await fileService.SaveAsync(file, safeFileName);
return Ok();
}
Security Scanning Commands
dotnet list package --vulnerable
dotnet outdated
grep -r "password\|secret\|apikey" --include="*.cs" --include="*.json"
grep -r "Password=\"" --include="*.cs"
grep -r "connectionString.*password" --include="*.json"
Security Review Checklist
Authentication
Authorization
Input Validation
Data Protection
Dependencies
Anti-Patterns to AVOID
:x: Trusting client input
var isAdmin = request.IsAdmin;
:x: Exposing internal errors
catch (Exception ex) { return BadRequest(ex.ToString()); }
:x: Hardcoded secrets
var apiKey = "sk_live_xxxxx";
:x: Insufficient logging
await DeleteAllUsers();
Verification Checklist
Related
arch-performance-optimization
arch-cross-service-integration
code-review
Closing Reminders
- MANDATORY IMPORTANT MUST ATTENTION break work into small todo tasks using
TaskCreate BEFORE starting
- MANDATORY IMPORTANT MUST ATTENTION search codebase for 3+ similar patterns before creating new code
- MANDATORY IMPORTANT MUST ATTENTION cite
file:line evidence for every claim (confidence >80% to act)
- MANDATORY IMPORTANT MUST ATTENTION add a final review todo task to verify work quality
- MANDATORY IMPORTANT MUST ATTENTION execute two review rounds (Round 1: understand, Round 2: catch missed issues)
MANDATORY IMPORTANT MUST ATTENTION READ the following files before starting:
- MANDATORY IMPORTANT MUST ATTENTION cite
file:line evidence for every claim. Confidence >80% to act, <60% = do NOT recommend.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.