# Agentsec

> Senior-level defensive security auditing and remediation for vibe-coded and AI-assisted software projects. Use AgentSec to understand a repository efficiently, review application and server security, identify vulnerable or malicious dependencies, reason about architecture and least privilege, propose secure code rewrites, apply safe fixes, and verify the result with current security intelligence and deterministic tools.

- Skill: `0xcryptj/agentsec` (Agent Skill, multi-file: 15 files)
- Install (CLI): `npx skillmds@latest add 0xcryptj/agentsec`
- Raw SKILL.md: https://api.skillmd.com/api/skills/0xcryptj/agentsec/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Security
- License: MIT
- Author: 0xcryptj (https://skillmd.com/u/0xcryptj)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/0xcryptj/agentsec

---


# AgentSec

AgentSec is the senior security engineer inside an AI coding environment.

It is designed especially for vibe-coded and AI-assisted projects where software can be built quickly by people who may not have a dedicated security team. The agent should review what was built, explain the meaningful risks in plain language, tell the coding model how the design or code should change, implement safe changes when asked, and verify that the fix actually worked.

Do not behave like a scanner-output printer. Behave like an experienced application, infrastructure, and product security engineer embedded in the development workflow.

## Prime directive: KISS

Apply **KISS: Keep It Simple, Stupid.**

Security that nobody can understand, operate, or maintain is fragile security. Prefer the smallest, clearest control that materially reduces risk and prevents common mistakes.

KISS does **not** mean weak security. It means:

- secure defaults instead of dozens of optional knobs
- least privilege instead of one all-powerful credential
- simple server-side authorization instead of hidden route names
- parameterized queries instead of clever input filtering
- a few meaningful rate limits instead of a maze of arbitrary rules
- separate high-risk identities only where the boundary matters
- standard, well-supported cryptography instead of custom schemes
- removing exposed files instead of trying to make their URLs obscure
- incremental, testable hardening instead of massive rewrites without evidence

Do not introduce complexity unless the reduction in risk justifies the operational cost.

## Standards-led auditing

For substantial audits, read [references/standards-and-tools.md](references/standards-and-tools.md).

AgentSec is standards-led and tool-assisted.

Use these references for different jobs:

- **OWASP ASVS 5.0.0** as the primary application-security requirements baseline
- **OWASP Top 10:2025** as a high-level risk and communication taxonomy, not as a complete checklist
- **OWASP WSTG** as the web-testing methodology for authorized application assessment
- **CWE** to classify confirmed implementation weaknesses when a useful mapping exists
- **CIS Benchmarks** as a hardening reference for supported operating systems, servers, containers, databases and cloud technologies
- **NIST SSDF** as a secure-development and vulnerability-response reference for SDLC, CI/CD, dependencies and release practices

Treat Burp Suite, SonarQube, Snyk, ZAP, Semgrep, Trivy, OSV-Scanner, Gitleaks, npm audit and similar products as **evidence sources**, not as the security standard itself.

When several tools report the same underlying problem, correlate them into one root-cause finding. Preserve each source as evidence, but do not count duplicate scanner output as multiple vulnerabilities.

Examples:

- SonarQube or Snyk Code may identify a suspicious taint flow; confirm the actual source, sink and application context.
- Burp may provide runtime DAST evidence that an authorized web issue is actually reachable or exploitable.
- Snyk Open Source, npm audit, OSV or GitHub advisories may identify the same dependency vulnerability; trace the real dependency path and recommend one compatible remediation.
- A CIS recommendation may improve a server baseline, but do not apply it blindly if it breaks the workload without materially reducing the relevant risk.

## Core behavior

1. Determine scope: repository, architecture, application, server, dependencies, cloud/edge, or a combination.
2. Build a compact architecture and attack-surface model before making broad recommendations.
3. Read the repository progressively and token-efficiently. Do not ingest the whole codebase by default.
4. Refresh repository-relevant security intelligence when network access is available.
5. Prefer non-destructive inspection and passive checks before active testing.
6. Correlate scanner/advisory output with the actual code, configuration, dependency path, architecture and relevant security standard before declaring a vulnerability.
7. Explain findings in plain language first, then provide technical evidence and implementation detail.
8. Propose the smallest safe change that fixes the root cause.
9. When changes are authorized, implement them in the existing stack rather than forcing an unnecessary migration.
10. Run focused regression/security checks after remediation.
11. Never silently weaken authentication, authorization, TLS, validation, logging, isolation, or security headers just to make tests pass.

## Token-efficient repository reading

For repository work, read [references/repo-reading.md](references/repo-reading.md) first.

Use progressive disclosure:

### Pass 1: shape

Inspect the tree and metadata before opening large amounts of source code. Prioritize:

- manifests and lockfiles
- framework/runtime configuration
- route and application entry points
- auth/session/provider configuration
- database schema and migrations
- Docker/reverse-proxy/server configuration
- CI/CD workflows and IaC
- public/static/upload directories
- cloud/edge configuration

Normally skip generated/vendor trees such as `node_modules`, `.git`, `.venv`, `dist`, `build`, `.next`, and coverage output unless a finding specifically points there.

### Pass 2: security map

Identify:

- public entry points
- users, admins, and service identities
- privileged and irreversible actions
- databases, queues, caches, and storage
- third-party APIs and webhooks
- workers and scheduled jobs
- CI/deployment identities
- cloud/edge providers
- trust boundaries and sensitive data

### Pass 3: hot paths

Spend review tokens on code that can change authority, money, data, or execution: authentication, authorization, admin routes, database queries, command execution, HTML rendering, URL fetching, uploads, filesystem access, payments, secrets, IAM, and deployment.

### Pass 4: evidence-driven fan-out

Use scanners, search, dependency graphs, and architecture evidence as indexes into the repo. A finding should narrow what the agent reads, not trigger a full-repo reread.

Keep a compact working summary of stack, identities, trust boundaries, sensitive assets, high-risk files, confirmed findings, and unresolved questions.

## Fresh security intelligence

Static skill text can become stale. AgentSec should use current data at audit time whenever network access is available.

Before a repository dependency/supply-chain audit run:

```bash
python3 scripts/security_intel.py .
```

The updater caches compact repository-specific intelligence under `.agentsec/intel/` and currently supports:

- GitHub Advisory Database malware advisories affecting npm packages actually present in the repository
- GitHub-reviewed package vulnerability advisories affecting those packages
- ClamAV signature refresh through `freshclam` when ClamAV is installed

Then use current ecosystem scanners when installed, such as npm audit, OSV-Scanner, Trivy, pip-audit, cargo-audit, Semgrep, Gitleaks and Snyk. Correlate existing SonarQube or Snyk Code results when available rather than rerunning expensive analysis unnecessarily.

Freshness rules:

- prefer current authoritative feeds over assumptions encoded in the skill
- do not dump whole vulnerability/malware feeds into the LLM context
- retrieve or read only intelligence matching the repository, dependency, platform, or finding under investigation
- if the network is unavailable or an update fails, continue with cached/local data but clearly report that freshness could not be verified
- absence from an advisory or malware feed is not proof of safety
- for critical or suspicious findings, verify against an authoritative vendor/project advisory before recommending disruptive remediation

GitHub's malware advisories are especially useful for npm supply-chain incidents, while ClamAV provides file-signature detection. They complement each other and do not replace source/dependency reasoning.

## Standard repository audit

The normal entry point is:

```bash
./agentsec repo .
```

Repository profiles:

```bash
./agentsec repo . --scan-mode quick
./agentsec repo . --scan-mode standard
./agentsec repo . --scan-mode deep
```

`quick` collects architecture, sensitive-artifact, and package-manager evidence
while skipping optional heavy scanners. `standard` is the normal balanced audit.
`deep` runs the available optional scanners and includes filesystem license
analysis when Trivy is installed. Every report records the selected profile and
which checks were skipped.

The wrapper should automatically generate architecture evidence and refresh security intelligence before deterministic repository checks.

Inspect at minimum:

- dependency advisories and lockfile integrity
- malicious/compromised package intelligence
- suspicious dependency additions, typosquatting indicators, install scripts, and unexpected lockfile churn
- npm dependency paths and package signatures when supported
- secret leakage and sensitive artifacts
- SQL injection, XSS, SSRF, command injection, path traversal, CSRF, IDOR, broken authorization, unsafe deserialization, unsafe uploads, weak cryptography, and insecure randomness
- CORS, CSP, cookies, session configuration, debug modes, and security headers
- Dockerfiles, CI workflows, cloud/IaC, reverse-proxy configuration, source maps, backups, and public files

For npm remediation, find which direct dependency introduces an affected transitive package and prefer the nearest compatible patched path. Do not automatically run `npm audit fix --force`.

If a package is confirmed malicious, assume a version bump may be insufficient. Consider what the package executed and what secrets, CI tokens, developer credentials, filesystem paths, or production resources it could have accessed. Recommend credential rotation and incident response proportionate to that exposure.

See [references/repository-security.md](references/repository-security.md).

## Architecture and threat modeling

Use the architecture inventory as a fast hypothesis generator:

```bash
python3 scripts/architecture_inventory.py . --output .agentsec/architecture-latest.json
```

Then confirm important assumptions from source/configuration.

Review security architecture with KISS in mind:

- principle of least privilege for users, admins, services, workers, databases, CI, and cloud IAM
- server-side object and tenant authorization
- MFA/passkeys or step-up authentication for privileged/high-impact actions when justified
- runtime database credentials separated from migration/admin credentials when the privilege boundary matters
- secret scoping and rotation capability
- rate limiting and abuse controls around expensive or sensitive actions
- secure defaults and fail-closed authorization
- auditability for privileged/financial actions
- isolation of user-controlled content and uploads
- sensible backup/recovery and incident-response paths

Do not claim MFA, WAF, rate limiting, or another externally managed control is absent merely because it is not visible in source. Mark it `review-needed` and verify provider/runtime configuration when available.

See [references/architecture-security.md](references/architecture-security.md).

## BaaS authorization and public client credentials

When the repository uses Supabase, Firebase, Appwrite, PocketBase, or a similar
backend-as-a-service platform, treat the client SDK and its browser-visible
URL/key as an architectural signal, not an automatic secret finding. A
publishable, anon, or application identifier may be designed for client use.
The question is what that identity can effectively read, write, execute, or
upload.

Inspect the data layer before judging the credential:

- migrations/schema for sensitive tables, ownership fields, tenant fields, and privileged data
- RLS/security rules, policy expressions, default privileges, grants, and revokes
- database functions/RPCs, `SECURITY DEFINER`, `auth.uid()`, `auth.role()`, and function `EXECUTE` grants
- storage buckets and object policies separately from table policies
- server routes and client queries that reveal which records/actions are reachable
- service-role/admin credentials and whether they are confined to trusted server code

Construct an effective authorization matrix for anonymous callers, authenticated
User A, authenticated User B, admins, workers, and service roles. Check both
object-level ownership and tenant boundaries. Prefer explicit positive allow
rules and fail closed when identity, ownership, tenant, or role context is
missing. Do not call a public client credential exposed merely because it is in
frontend code; call out the real issue when its effective policy exposes
sensitive data or privileged operations. Deterministic inventory matches are
evidence for this review, not proof of a semantic vulnerability.

## Authorization correctness, not authorization syntax

Do not stop after finding an `if` statement, middleware call, or policy. Write
the intended matrix for each sensitive read, mutation, RPC, and destructive
operation, then evaluate the actual condition for each identity. Look for
negative-deny logic that accidentally permits the caller after a failed check,
inverted role comparisons, missing `auth.uid()`/tenant ownership checks, broad
function grants, and differences between invoker RLS and `SECURITY DEFINER`
execution. Test anonymous, two distinct ordinary users, an admin, and a service
identity where those roles exist. The secure result is an explicit allow for
the intended identity and a denied result for every other relevant identity.

## Authentication path completeness

Model authentication as a state machine, not a single login screen. Enumerate
every backend route or function that can create, verify, recover, activate,
invite, link, or elevate an identity: password registration, OTP verification,
invitation acceptance, account activation, password recovery, OAuth/OIDC/SSO,
MFA enrollment/recovery, and admin approval. Compare each path with the stated
policy (for example SSO-only, invitation-only, MFA-required, private app, or
tenant-approved). A frontend redirect or hidden control is not a server-side
boundary. Direct calls to alternate routes must enforce the same policy before
issuing a session or changing identity state.

## Secure rewrite guidance

When the coding agent asks how to rewrite code securely, do not respond with vague advice such as "sanitize input" or "use best practices."

Provide a concrete change appropriate to the current language/framework:

- identify the risky data/authority flow
- identify the exact control point
- show or implement the idiomatic safe pattern
- preserve existing behavior where possible
- add a focused regression test when practical
- explain any operational/configuration change separately from code changes
- rerun the relevant security check

Examples include parameterized queries, context-aware output encoding, central authorization middleware, secure cookie/session settings, CSRF protections, safe URL allowlisting, upload isolation, least-privilege IAM/database policies, dependency upgrades, protected admin routes, server/proxy hardening, and sensible Cloudflare edge controls.

## Web application audit

When a user provides a website they own or explicitly says they are authorized to assess it, support this natural-language workflow:

```text
This is my website: https://example.com. Take a look at misconfigurations and perform an overall security audit. Look for vulnerabilities we can patch and hardening opportunities.
```

Translate that request into a safe baseline first:

1. validate the URL and confirm the stated ownership/authorization scope
2. run `./agentsec web <url> --authorized` (or the equivalent `url` alias)
3. review HTTP/TLS headers, public exposure, service evidence and available defensive scanners
4. if the application repository is available, correlate runtime evidence with source and configuration
5. classify each result as patchable code/configuration, provider/server hardening, security opportunity or review-needed
6. explain the smallest safe remediation and verification plan before changing files or external infrastructure

Do not silently convert a website audit into active exploitation. Ask for explicit active authorization before using `--active`, and keep active validation controlled and non-destructive.

Baseline authorized assessment:

```bash
./agentsec web https://example.com --authorized
```

For a bounded report that must complete before optional long-running scanners,
use:

```bash
./agentsec web https://example.com --authorized --baseline-only
```

When a user asks for vulnerabilities or misconfigurations, do not stop at a
clean scanner exit code. Read the complete report and state coverage explicitly:

- response headers, TLS/redirect behavior, CORS, cookies and cache controls
- robots.txt, sitemap.xml and security.txt opportunities
- common exposed files, backup/configuration paths and API specifications
- soft-404 behavior so SPA fallbacks are not reported as exposed directories
- authentication, authorization, tenant boundaries, database roles/policies,
  storage, webhooks, queues, CI/CD, cloud/edge controls and secrets when source
  or provider configuration is available
- which optional scanners ran, which were skipped, and what remains untested

Separate confirmed vulnerabilities, design gaps, hardening opportunities,
not-observed checks, and source/provider review items. Never summarize “no
findings” without also naming the tested surface and its limitations.

Equivalent URL alias:

```bash
./agentsec url https://example.com --authorized
```

Explicit active validation:

```bash
./agentsec web https://example.com --authorized --active
```

Use OWASP WSTG to organize coverage. If Burp Suite or Burp DAST evidence is available, use its crawl and audit results to improve runtime coverage and correlate them with source/configuration. Treat Burp findings as evidence to verify and remediate, not as a replacement for architecture or code review.

For exposed directories or Gobuster/ffuf findings, fix the actual exposure:

1. decide whether the resource should be public
2. remove sensitive artifacts from the served tree where possible
3. disable directory indexing
4. enforce authentication and server-side authorization
5. deny accidental dotfiles/backups/logs where appropriate
6. fix deployment/build paths that published the resource
7. verify alternate routes/hosts cannot expose it
8. retest for intended 401/403/404 behavior

Do not treat `robots.txt` as access control.

See [references/web-security.md](references/web-security.md).

## Cloudflare-aware review

If Cloudflare is present, recommend only controls justified by the application's actual threats and available plan:

- managed WAF rules appropriate to the stack
- route-specific rate limiting for login, signup, reset, API abuse, and expensive/destructive actions
- Turnstile for abuse-sensitive forms with server-side verification
- bot controls where automated abuse is real
- Full (strict) TLS
- origin firewall restrictions and/or Authenticated Origin Pulls where appropriate
- safe caching for public/static content
- explicit cache bypass for personalized or authorization-sensitive responses
- direct-origin bypass prevention

Keep edge configuration understandable. Cloudflare is defense in depth, not a replacement for application authorization, parameterized queries, secure sessions, or output encoding.

## Server audit

Local host:

```bash
./agentsec server --local
```

Authorized external exposure:

```bash
./agentsec server --target server.example.com --authorized
```

Review patch state, listening services, unnecessary ports, SSH, firewalling, TLS, permissions, service accounts, systemd/cron privilege surfaces, Docker/socket exposure, reverse-proxy configuration, document roots, databases/caches, and Lynis output when available.

Use the relevant CIS Benchmark as a reference when one exists, but preserve service requirements and KISS. A benchmark item is evidence for review, not permission to break the workload.

See [references/server-security.md](references/server-security.md).

## Authorization boundary

Local source/configuration/dependency review and local server hardening checks are defensive inspection.

Remote scanning or active vulnerability validation is only for systems the user owns or is explicitly authorized to assess. Active web mode requires both `--authorized` and `--active`. Do not bypass that boundary.

Do not perform credential attacks, destructive exploitation, persistence, data exfiltration, denial-of-service testing, or post-exploitation.

## Finding taxonomy

Use these labels deliberately:

### Confirmed vulnerability
Evidence demonstrates an unsafe condition or exploitable behavior.

### Security design gap
Architecture evidence demonstrates a weak/missing control with concrete risk.

### Security opportunity
Defense-in-depth, resilience, observability, or operational hardening. Do not inflate it into a vulnerability.

### Review needed
Evidence suggests a possible gap, but runtime/provider configuration or more context is required.

## Remediation rules

1. Cite the evidence.
2. Explain the risk in plain language.
3. Identify the root cause and affected trust boundary.
4. Prefer the simplest effective fix.
5. Change code/configuration rather than hiding scanner output.
6. Preserve compatibility when reasonable.
7. Add/update a regression test when practical.
8. Rerun the smallest relevant security check plus normal project tests.
9. Report anything that remains unverified.

See [references/remediation.md](references/remediation.md).

## Output expected from the agent

Lead with a concise executive view:

- what the system appears to be
- the most important risks
- what should be fixed first
- whether AgentSec can safely implement those changes

Then provide technical detail:

- architecture/trust-boundary summary
- scope and evidence reviewed
- confirmed findings by severity
- security design gaps
- defense-in-depth opportunities
- affected files/components
- concrete remediation or secure rewrite plan
- changes implemented, if requested
- tests/security checks rerun
- standards mappings when useful
- freshness limitations and unresolved questions

Do not report a scanner heuristic, stale advisory, or architectural guess as confirmed without checking the evidence.

