security-test은(는) 무엇을 하나요?
Goal: find where data, secrets, or privileges leak by reading the code (white-box). It's safe to run anywhere: it only reads code and runs local scanners.
For the system around the code (infra, CI/CD, identity, monitoring, backups, incident readiness), use cybersecurity-test.
Follow references/core-rules.md, references/automation-workflow.md, references/severity-model.md. Write the report in the format of references/testcase-template.md. Prefix IDs with SEC-. For every detected language, also apply references/languages/<language>.md (index: references/languages/README.md).
Mandatory sweeps (do these first, every run)
These five sweeps catch the findings a long checklist most often lets slip. Run them before the layer checklist. Record each result in the report's Mandatory security sweeps table (template §2c), writing "none found" plus what you searched when nothing turns up. A blank sweep row means the audit is incomplete.
- List every file, dotfiles included.
git ls-files(orls -aper directory). Read.env*,.env.example,config/*,application*.properties|yml,settings*.py,appsettings*.json,wp-config.php,Info.plist,AndroidManifest.xml,docker-compose*, and CI files. Some search tools skip dotfiles by default. - Insecure fallbacks and defaults. Search for env reads with a literal fallback:
|| ',?? ",?: ",getenv("X", ",os.environ.get("X", ",ENV.fetch("X", ",env('X', ',System.getenv(...) ?:. Any secret, key, URL, or auth flag with a hard-coded fallback is a finding (at least High for secrets). - Debug and error exposure.
DEBUG = True,APP_DEBUG=true,display_errors,include-stacktrace,err.stack/traceback/stackTraceToString/err.Error()sent to clients, exposed actuator, pprof, or swagger. - Auth basics, one line each. Password hashing algorithm · token or session expiry · rate limit or lockout on login/OTP/reset · constant-time comparison of tokens/MACs · where the role/admin decision comes from (server session vs client header/body/localStorage).
- Language sinks. For each detected language, search for every API in its guide's Risky APIs table (e.g.
strcpy|sprintf|printf(for C/C++,pickle|yaml.loadfor Python,unserializefor PHP) and list each hit with a verdict.
Procedure
- Map the attack surface: entry points (routes, GraphQL resolvers, RPC, webhooks, jobs, deep links, admin routes), the auth middleware, and where data sinks (DB, shell, file system, HTML, logs, third parties).
- Trace untrusted input from source to sink for every entry point.
- Walk the checklist below per layer (after the mandatory sweeps).
- Run any scanners available locally. Use what is installed and skip what isn't:
npm audit --omit=dev,pnpm audit,pip-audit,osv-scanner,semgrep --config auto,gitleaks detect,trufflehog filesystem .,bandit -r,gosec ./...,snyk test/ Snyk MCP (vendorsnyk-fix), CodeQL. Zero scanner findings does not mean secure. - Verify each Critical or High finding before reporting it (vendor
fp-check). Then search for variants of each confirmed bug (vendorvariant-analysis). - For PRs, run a diff-focused review (vendor
differential-review).
OWASP Top 10:2025 quick map
A01 Broken Access Control · A02 Security Misconfiguration · A03 Software Supply Chain Failures · A04 Cryptographic Failures · A05 Injection · A06 Insecure Design · A07 Authentication Failures · A08 Software/Data Integrity Failures · A09 Logging & Alerting Failures · A10 Mishandling of Exceptional Conditions.
For depth, use vendor owasp-security (ASVS 5.0 L1–L3 plus language-specific quirks).
Checklist by layer
Backend / API (BE)
Access control (A01): most Critical findings live here
- Every route has an auth middleware. List routes without one and justify each.
- Object-level authorization: every
findById(req.params.id)also checks owner or tenant (stops IDOR/BOLA). - Function-level authorization: admin and staff endpoints check the role on the server, not only by hiding the UI.
- Multi-tenant: every query is scoped by
tenantId/orgId, including counts, exports, search, and file URLs. - Mass assignment: the update DTO allowlists fields, so
role,isVerified,balance,ownerIdcan't be set by the client. - CORS isn't
*together with credentials. Origins come from an allowlist.
Injection (A05)
- SQL/NoSQL: parameterised queries only. Look for string concatenation,
raw(,$where,{$ne:},query(\...${`. - Command: no
exec/spawnwith user input (shell: true), and noeval/Function()/vm. - Path traversal: user-supplied paths are normalised and confined to a base directory.
- SSRF: user-supplied URLs are allowlisted and private, link-local, and metadata IPs blocked (169.254.169.254).
- Template injection, XXE (XML parsers with external entities off), unsafe deserialization (
pickle,yaml.load, JavaObjectInputStream). - Log injection: user input that goes into logs is sanitised (CRLF).
Authentication and session (A07)
- Passwords hashed with argon2id, bcrypt, or scrypt. Never MD5, SHA1, or unsalted.
- JWT: algorithm pinned (no
none, no HS/RS confusion),expchecked, secret is strong and from env,aud/issvalidated. - Login, OTP, and reset are rate-limited, with lockout or backoff. OTP has an expiry and is single-use.
- Reset tokens are random, expiring, single-use, and not logged.
- Sessions rotate on login and privilege change. Logout invalidates the session on the server.
- No user enumeration through different messages or timing.
Secrets and config (A02, A04)
- No secrets in source, git history, Docker images, or client bundles (
gitleaks). - No fail-open fallbacks:
process.env.SECRET || 'dev-secret',if (!authEnabled) next(),rejectUnauthorized: false,DEBUG=Truein prod. - Strong crypto: AES-GCM, random IVs,
crypto.randomBytesorsecrets, notMath.random()for tokens. - TLS is enforced, and HSTS is set.
Errors and logging (A09, A10)
- No stack traces or SQL errors returned to clients in prod.
- Security events (login fail, permission denied, admin actions) are logged, without passwords, tokens, OTPs, card data, or full PII.
- Exceptions in auth or authorization code fail closed.
Frontend web (FE)
- XSS: no
dangerouslySetInnerHTML,innerHTML,v-html, or[innerHTML]with untrusted data unless sanitised (DOMPurify). -
href/srcbuilt from user data are checked againstjavascript:URLs. - Security headers: CSP,
X-Content-Type-Options,frame-ancestors/X-Frame-Options,Referrer-Policy,Permissions-Policy. - Tokens: prefer httpOnly + Secure + SameSite cookies. If a token is in
localStorage, record it as a Medium finding with an XSS dependency. - CSRF protection for cookie-auth state-changing requests.
- No secrets in the bundle: grep the build output for
sk_,secret,private_key,AKIA, service-role keys (e.g. Supabaseservice_role), Firebase admin keys. - Source maps aren't public in prod, and no debug routes are shipped.
- Open redirect:
?next=/?redirect=validated against an allowlist. - Third-party scripts pinned with SRI where possible.
Mobile (MOB)
- Tokens kept in Keychain/Keystore (
expo-secure-store,react-native-keychain), not AsyncStorage or plain SharedPreferences. - No API secrets embedded in the app binary. Anything shipped in an app is public.
-
android:allowBackup,debuggable, cleartext traffic (usesCleartextTraffic, ATS exceptions) off in release. - Deep-link handlers validate parameters and don't perform privileged actions without auth.
- WebViews:
javaScriptEnabledonly if needed, nofile://access,originWhitelistrestricted, and bridges (postMessage) validated. - Logs (
console.log) stripped in release and contain no tokens or PII. - Screenshots or app-switcher snapshots of sensitive screens are protected if required.
- Certificate pinning where the threat model needs it.
Admin panel (ADM)
- Admin is on a separate auth realm or role. MFA is required. Sessions are short.
- Every admin API checks the role on the server. Test with a normal user's token (expect 403).
- Role hierarchy: support can't escalate to super-admin or edit their own role.
- Impersonation ("login as user") is audited, time-boxed, and visibly flagged.
- Exports apply the same tenant scoping and redact sensitive columns. CSV formula injection is escaped.
- An immutable audit log records actor, action, target, before/after, IP, and time.
- Admin URL is not guessable-only security (
/adminhidden ≠ protected).
Database (DB)
- App DB user has least privilege: no superuser, no DDL at runtime.
- Row-level security, or tenant-scoped views, where multi-tenant (e.g. Supabase RLS enabled on every table with correct policies).
- PII and sensitive columns are encrypted at rest or tokenised where required. Passwords are hashed, never encrypted.
- Backups are encrypted and access-controlled.
- DB isn't reachable from the public internet. Credentials are rotated.
- Migrations don't seed default admin credentials.
- Data retention and deletion support GDPR/DPDP (right to erasure and export).
Infra / CI / supply chain (INF)
- Lockfile committed. Dependencies have no known critical CVEs (vendor
supply-chain-risk-auditor). - No
curl | shin build steps. Docker images pinned by digest, running as non-root. - GitHub Actions: third-party actions pinned by SHA, least-privilege
permissions:, nopull_request_targetcombined with checkout of PR code, secrets not echoed. - Cloud storage buckets aren't public unless intended. Presigned URLs are short-lived.
- AI/LLM features: prompt-injection handling, tool and permission scoping, output treated as untrusted (OWASP LLM Top 10). See vendor
owasp-security.
Output
Add SEC-* findings to testcase.md with the OWASP category, an optional CVSS score, evidence (file:line), exploit scenario, and fix. Record security Good Points too, e.g. "RLS enabled on all tables".
Scope, prerequisites, and missing tools
Don't use it for infrastructure, CI/CD, or operational security posture (cybersecurity-test) or for functional bugs without a security impact (negative-test, logical-test). It reads code and runs local scanners only.
Prerequisites: read access to the repository. Optional: the project's own test runner and the scanners listed in the language guides. Nothing extra needs to be installed; every check also works by reading the code.
If something is missing: if a tool, the test runner, or a running app isn't available, or a step is blocked, record it as NOT RUN: <reason> and continue statically. Always finish by writing the report.
Example finding row
| ID | Layer | Type | Finding | Location / Evidence | Failure scenario | Fix | Status |
|---|---|---|---|---|---|---|---|
| SEC-BE-001 | BE | SECURITY | IDOR on order read (OWASP A01) | orders_controller.rb:12 Order.find(params[:id]) | User B reads user A's order by changing the id | current_user.orders.find(params[:id]) | Open |