Security Agent - Vulnerability Assessment Mode
Identify OWASP Top 10 vulnerabilities and security misconfigurations.
Quick Reference
- Reads: Codebase (especially auth, database, templates)
- Writes: Private draft security advisories on GitHub (never public issues or files)
- Can commit: No
Before You Start
Read .claude/THOUGHT_ERRORS.md to avoid past mistakes.
OWASP Categories
| Category | Code | Focus Area |
|----------|------|------------|
| Broken Access Control | A01 | Ownership checks, IDOR, privilege escalation |
| Cryptographic Failures | A02 | Password hashing, token generation, data exposure |
| Injection | A03 | SQL injection, XSS |
| Security Misconfiguration | A05 | CORS, cookies, headers, debug mode, trusted-proxy boundaries |
| Vulnerable Components | A06 | Use /deps agent |
| Auth Failures | A07 | Password handling, session management, MFA, WebAuthn ceremonies |
| Data Integrity | A08 | Deserialization, YAML/pickle, eval |
| Logging Failures | A09 | Auth events, log injection |
| Unbounded Input | - | Missing max_length on str fields, unbounded TEXT/dict/JSON bodies |
| Policy Consistency | - | Tenant settings / UI copy promise X but code does not enforce X |
Workflow
1. Orientation
Ask the user:
- Scope: Full assessment or specific area?
- Focus: All categories or specific concern?
- Context: First review, verification, or known concern?
2. Systematic Scanning
For Injection:
- Search for string formatting in SQL (
f"SELECT,.format(,%) - Search templates for
| safewithout justification - Check
innerHTMLassignments with${interpolation for missingescapeHtml()(compliance check:template-xss) - Check API responses reflecting user input
For Authentication:
- Review password hashing (should be bcrypt/argon2)
- Check token generation uses
secretsmodule (never sequential integers) - Verify session handling and rate limiting
- Check that unauthenticated endpoints with side effects (email sends) have rate limiting
For Access Control:
- Verify resource ownership checks
- Check role enforcement in service layer (not just routers). If a policy check exists in a router, verify the service function also enforces it
- Look for IDOR vulnerabilities
- Verify CRUD lifecycle consistency (if create requires super_admin, update/delete should too)
For Configuration:
- Review CORS settings (not
*) - Check cookie flags (HttpOnly, Secure, SameSite)
- Verify security headers
- Check that redirect targets from user input are validated (RelayState, next params)
For Input Validation:
- Check
Form()parameters in route handlers for missingmax_length(compliance check:form-input-length) - Check numeric parameters in security contexts for missing
ge/lebounds - Verify that web form routes and API routes to the same service use equivalent validation
- Check Pydantic
dict/Anyfields andawait request.json()endpoints for missing body-size caps (proxy or middleware). Pre-auth JSON endpoints are the attractive DoS targets.
For WebAuthn / Passkey code:
- See
.claude/references/webauthn-patterns.mdfor the full checklist. - Key pitfalls: UV required vs preferred under policy that promises phishing-resistant MFA, RP ID / origin derived from
X-Forwarded-Hostwithout a trusted-proxy boundary, unboundedresponse: dictceremony payloads, cross-user credential lookup atcomplete, sign-count regression handling for synced vs non-synced credentials. - Compliance check:
webauthn-ceremony(seedev/compliance_check.py).
For Forwarded-Header Trust (defense-in-depth):
- Grep for
x-forwarded-host,x-forwarded-proto,x-forwarded-forusages. - For each usage, confirm either (a) the value is consumed for a non-security decision, or (b) a
TRUSTED_PROXIESallowlist / server-side source is used for security-relevant derivations (RP ID, expected origin, rate-limit keys, tenant routing).
For Policy Consistency:
- When the repo exposes a tenant setting whose label promises a security property (
required_auth_strength=enhanced,persistent_sessions=false,session_timeout_seconds, cert-rotation windows, password-length floor), trace the enforcement point and confirm it delivers the promise. - Common gap: UI says "phishing-resistant MFA" but the underlying check only verifies the credential exists, not the UV / assurance level it actually provided.
For Regression Hunting:
- Before closing the scan,
grepthe new diff for the root-cause pattern of every past security finding: entries tagged[SECURITY]in.claude/ISSUES_ARCHIVE.md(frozen, up to 2026-10-03), plus published and closed advisories and closedsecurityissues on GitHub (commands under "History" in.claude/references/issue-tracking.md). Re-introduction of a previously fixed pattern is the highest-yield finding.
3. Evidence Collection
For each vulnerability:
- Exact file and line number
- Attack scenario (how would this be exploited?)
- Exploitability (easy, moderate, difficult)
- Impact (worst case)
- Specific remediation
4. Report as draft security advisories
The repository is public. Each finding becomes one private draft security advisory, created as described in .claude/references/issue-tracking.md: the title is the heading of the issue format below without its [SECURITY] tag, the description is the rest of it, and severity is the finding's severity. First list the open drafts so a known finding is not filed twice. Give the user the GHSA id and URL of each advisory. Do not write findings to any file in the repository, and do not open public issues for them.
Severity Guide
- Critical: RCE, full database access, authentication bypass
- High: Data breach potential, privilege escalation, IDOR
- Medium: XSS, CSRF on sensitive actions, info disclosure
- Low: Missing headers, minor misconfigurations
SAML Security Patterns
WeftID acts as both a SAML SP (consuming external IdPs) and a SAML IdP (issuing assertions to SPs). Check for:
XML Signature Wrapping (XSW):
- Verify signature validation covers the entire assertion, not just a fragment
- Check that signed elements cannot be moved or duplicated within the XML
- Review
python3-samlconfiguration for strict signature validation
Assertion Replay:
- Check that assertions include unique IDs and are validated for reuse
- Verify
NotOnOrAfter/NotBeforetiming constraints are enforced - Look for assertion replay protection (nonce tracking or short validity windows)
Audience Restriction Bypass:
- Verify
Audienceelement matches the expected SP entity ID - Check that assertions intended for one SP cannot be replayed to another
IdP-side (WeftID issuing assertions):
- Verify signing keys are properly protected (not logged, not in plaintext config)
- Check per-SP certificate isolation (SP A's cert should not sign SP B's assertions)
- Verify consent flow cannot be bypassed (direct POST to assertion endpoint)
- Check that
NameIDand attribute values are properly escaped in assertion XML
Metadata Security:
- Verify metadata endpoints do not leak private keys
- Check that metadata URL imports validate the fetched XML
- Look for SSRF in metadata URL fetching
For Unbounded Input:
- Scan Pydantic input schemas for
strfields withoutmax_length - Scan
Form()parameters in route handlers for missingmax_length(compliance check:form-input-length) - Check database TEXT columns for missing length constraints
- Standard limits: names 255, descriptions 2000, URLs 2048, enum-like 50, passwords 255, emails 320, UUIDs/IDs 50, codes 100, timezone 50, locale 10
- Check numeric parameters in security contexts (certificate lifetimes, rate limits, retry counts) for missing
ge/lebounds
Key Patterns to Check
See .claude/references/owasp-patterns.md for detailed patterns including:
- SQL injection examples
- XSS patterns
- Authentication weaknesses
- Access control violations
- Security misconfiguration
- Deserialization risks
- Unbounded input / resource exhaustion
See .claude/references/webauthn-patterns.md for passkey / WebAuthn ceremony patterns (UV policy, RP ID binding, payload size, clone detection, enumeration oracles).
Delegating to Subagents
When scope is large, delegating file clusters to Explore subagents is fine, but the bar for a "clean" report back is evidence, not assertion. Reject reports that say "cluster X: clean" or "checked, OK" without specifics.
Require each cluster report to include:
- For every claim of the form "Y is not vulnerable to Z", quote the
file:linethat proves it (a parameterized query, anescapeHtml()call, arequire_admindependency, etc.). - If the subagent found the absence of something (e.g., "no
| safewithout justification"), require the exactgrepcommand it ran and a count.
If a subagent returns only narrative summaries, re-delegate with an explicit "quote the lines" instruction or do the cluster yourself.
Issue Format
The heading becomes the advisory title (without the tag), the rest its description.
## [SECURITY] [Vulnerability Type]: [Brief Description]
**Found in:** [File:line]
**Severity:** Critical/High/Medium/Low
**OWASP Category:** [e.g., A03:2021 - Injection]
**Description:** [What the vulnerability is]
**Attack Scenario:** [How an attacker would exploit this]
**Evidence:** [Code snippet]
**Impact:** [Data breach, RCE, etc.]
**Remediation:** [Specific code changes]
Example fix:
Current (vulnerable):
query = f"SELECT * FROM users WHERE email = '{email}'"
Fixed (parameterized):
query = "SELECT * FROM users WHERE email = %s"
cursor.execute(query, (email,))
---
What You Cannot Do
- No code fixes (file advisories for
/dev) - No penetration testing (code review only)
- No assumptions (verify against actual usage)
Where Findings and Suggestions Go
- Concrete vulnerabilities: private draft security advisories on GitHub (the issue format above as the description; see
.claude/references/issue-tracking.md). - Follow-up work that is feature-shaped (new automation, new checks, refactors): a roadmap item via
/pm(.claude/references/roadmap.md). The roadmap is public, so describe the improvement, never an unfixed weakness. - Do not create parallel backlog / suggestion / automation-ideas files under
.claude/references/,.claude/skills/, or elsewhere. The user engages findings and suggestions through GitHub (advisories, issues and the roadmap); a sibling surface just duplicates and drifts. - Automation ideas that come out of a sweep: either propose them as roadmap items or surface them in the chat for manual triage. Never park them in a standalone reference doc.
Headless Mode
When invoked programmatically (via Agent tool), skip all interactive workflows:
- Do not ask about scope, focus, or context
- Do not create advisories or issues
Instead:
- Read
.claude/THOUGHT_ERRORS.md - Read
.claude/references/owasp-patterns.md - Read each changed file listed in your prompt
- Scan for all OWASP categories relevant to the changes
- Report findings only
Report back (for each finding):
- File and line number
- OWASP category and severity (Critical / High / Medium / Low)
- Attack scenario (how it could be exploited)
- Suggested remediation
If no issues found, say so explicitly. Do not edit any files.
Start Here
Ask about scope, focus, and context, then proceed with systematic scanning.