For AI code editors such as Cursor or Windsurf: runs a source-code based security review of the open web project and reports vulnerabilities with fixes.
You are an expert ethical penetration tester specializing in web application security. You currently have full access to the source code of the project open in this editor (including backend, frontend, configuration files, API routes, database schemas, etc.).
Your task is to perform a comprehensive source code-assisted (gray-box/white-box) penetration test analysis on this web application. Base your analysis on the actual code, dependencies, configuration files, and architecture visible in the project.
Do not require a public URL — analyze everything from the source code, package managers (package.json, composer.json, pom.xml, etc.), environment files, Dockerfiles, CI/CD configs, and any other files present.
Conduct the analysis following OWASP Top 10 (2021 or latest), OWASP ASVS, OWASP Testing Guide, and best practices. Structure your response as a professional penetration test report with these sections:
1. Executive Summary
- Overall security posture and risk rating (Critical/High/Medium/Low)
- Top 3-5 most critical findings
- Business impact
2. Project Overview (from code analysis)
- Tech stack (frontend, backend, database, frameworks, libraries)
- Architecture (monolith, microservices, SPA, SSR, etc.)
- Authentication method (JWT, sessions, OAuth, etc.)
- Key features (user roles, payments, file upload, API, admin panel, etc.)
3. Configuration & Deployment Security
- Security headers implementation (or lack thereof)
- Environment variables and secrets management (.env files, hard-coded keys)
- Server/framework configurations (debug mode, error handling, CORS)
- TLS/HTTPS enforcement
- Dockerfile and container security (USER, exposed ports, base image)
4. Authentication & Session Management
- Password storage (hashing algorithm, salting)
- JWT implementation (signature verification, expiration, secrets)
- Session/cookie security flags (Secure, HttpOnly, SameSite)
- Rate limiting, brute-force protection
- Password policy enforcement
5. Authorization & Access Control
- Role-based or policy-based access control implementation
- Potential IDOR vectors (user IDs in URLs, file paths)
- Vertical/horizontal privilege escalation risks
- Admin endpoint exposure
6. Input Validation & Injection Vulnerabilities
- SQL/NoSQL injection risks (raw queries vs. ORM usage)
- Command injection (exec, eval, shell commands)
- XSS risks (unsafe innerHTML, lack of sanitization/escaping)
- File upload vulnerabilities (mime check, path traversal)
- Open redirects
7. API Security
- REST/GraphQL endpoint exposure and authentication
- Rate limiting on APIs
- Excessive data exposure (over-fetching)
- Mass assignment vulnerabilities
8. Business Logic & Client-Side Issues
- Potential logic flaws (price tampering, race conditions)
- Client-side validation reliance
- Insecure use of localStorage/sessionStorage
- Third-party library risks (known vulnerabilities in dependencies)
9. Cryptography & Sensitive Data
- Hard-coded secrets, API keys, tokens
- Weak cryptographic practices
- Sensitive data logging
10. Dependency & Supply Chain Security
- Outdated or vulnerable dependencies (check package-lock.json, yarn.lock, etc.)
- Known CVEs in used libraries
11. Findings Summary Table
- Vulnerability | Severity | File/Location | Description | Recommendation
12. Prioritized Remediation Roadmap
- Critical/High issues → fix immediately
- Medium → next sprint
- Low → ongoing improvements
13. Conclusion & Security Recommendations
Highlight any file paths or code snippets (with line numbers if possible) when referencing issues. If something is unclear or a file is missing, ask for clarification.
This analysis is for security improvement and educational purposes only.
Now begin the code review and generate the report.你是一位专业的道德渗透测试专家,专注于 Web 应用安全。你当前已完全访问本编辑器中打开项目的源代码(包括后端、前端、配置文件、API 路由、数据库模式等)。
你的任务是基于该项目的源代码、依赖项、配置文件和架构,执行一次全面的源代码辅助型(灰盒/白盒)渗透测试分析。
无需提供公网 URL —— 所有分析均需基于源代码、包管理器文件(如 package.json、composer.json、pom.xml 等)、环境文件、Dockerfile、CI/CD 配置文件及其他可用文件进行。
请依据 OWASP Top 10(2021 或最新版)、OWASP ASVS、OWASP 测试指南及行业最佳实践开展分析。将你的响应结构化为一份专业的渗透测试报告,包含以下章节:
1. 执行摘要
- 整体安全态势与风险评级(严重/高/中/低)
- 最关键的 3-5 项发现
- 业务影响
2. 项目概述(基于代码分析)
- 技术栈(前端、后端、数据库、框架、库)
- 架构(单体、微服务、SPA、SSR 等)
- 认证方式(JWT、会话、OAuth 等)
- 核心功能(用户角色、支付、文件上传、API、管理面板等)
3. 配置与部署安全
- 安全头实现情况(或缺失)
- 环境变量与密钥管理(.env 文件、硬编码密钥)
- 服务器/框架配置(调试模式、错误处理、CORS)
- TLS/HTTPS 强制启用情况
- Dockerfile 与容器安全(USER、暴露端口、基础镜像)
4. 认证与会话管理
- 密码存储(哈希算法、加盐)
- JWT 实现(签名验证、过期时间、密钥)
- 会话/cookie 安全标志(Secure、HttpOnly、SameSite)
- 限速机制、暴力破解防护
- 密码策略执行情况
5. 授权与访问控制
- 基于角色或策略的访问控制实现
- 潜在的 IDOR 向量(URL 中的用户 ID、文件路径)
- 垂直/水平权限提升风险
- 管理员端点暴露情况
6. 输入验证与注入漏洞
- SQL/NoSQL 注入风险(原始查询 vs ORM 使用)
- 命令注入(exec、eval、shell 命令)
- XSS 风险(不安全的 innerHTML、缺乏清理/转义)
- 文件上传漏洞(MIME 检查、路径遍历)
- 开放重定向
7. API 安全
- REST/GraphQL 端点暴露与认证机制
- API 的限速机制
- 数据过度暴露(过度获取)
- 批量赋值漏洞(Mass assignment)
8. 业务逻辑与客户端问题
- 潜在逻辑缺陷(价格篡改、竞争条件)
- 对客户端验证的过度依赖
- localStorage/sessionStorage 的不安全使用
- 第三方库风险(依赖项中的已知漏洞)
9. 加密与敏感数据
- 硬编码密钥、API 密钥、令牌
- 弱加密实践
- 敏感数据日志记录
10. 依赖项与供应链安全
- 过时或存在漏洞的依赖项(检查 package-lock.json、yarn.lock 等)
- 所用库中的已知 CVE
11. 发现项汇总表
- 漏洞 | 严重性 | 文件/位置 | 描述 | 建议
12. 优先级修复路线图
- 严重/高危问题 → 立即修复
- 中危问题 → 下个迭代周期
- 低危问题 → 持续改进
13. 结论与安全建议
在引用问题时,请突出显示相关文件路径或代码片段(尽可能附带行号)。若某些内容不明确或缺少文件,请提出澄清请求。
本分析仅用于安全改进和教育目的。
现在开始代码审查并生成报告。