check-cors-security
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "check-cors-security":https://skillpi.com/zh/skills/deepskill-8c04381de1b6673a2cef02e51d82d598b41bb3c1b7716b39c73c45844c8b92bb。安装前核对上游来源和版本:https://github.com/dykyi-roman/awesome-claude-code。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
审计 CORS 配置安全性的工具与指南,用于检测通配符来源、带凭据的通配符、动态来源反射、缺少预检处理以及过于宽松的策略。
介绍来源: third_party · dykyi-roman · 0.0.1 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 输入和输出
- 减记
- 实测状态
- 未测试
文件浏览
Frontmatter
name: check-cors-security
description: Audits CORS configuration security. Detects wildcard origins, credentials with wildcards, dynamic origin reflection, missing preflight handling, and overly permissive policies.CORS Security Audit (A05:2021)
Analyze PHP code for CORS misconfiguration vulnerabilities.
Detection Patterns
1. Wildcard Origin
// CRITICAL: Allows any website to make requests
header('Access-Control-Allow-Origin: *');
// In framework config:
'allowed_origins' => ['*'], // Any origin!
2. Credentials with Wildcard
// CRITICAL: Browser ignores this (spec violation), but shows misconfiguration intent
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Credentials: true');
// Cannot use * with credentials — forces dynamic origin reflection
3. Dynamic Origin Reflection (Dangerous)
// CRITICAL: Reflects any Origin header — equivalent to wildcard with credentials
class CorsMiddleware
{
public function handle(Request $request, Response $response): Response
{
$origin = $request->headers->get('Origin');
$response->headers->set('Access-Control-Allow-Origin', $origin); // Reflects ANY origin!
$response->headers->set('Access-Control-Allow-Credentials', 'true');
return $response;
}
}
// CORRECT: Whitelist of allowed origins
class CorsMiddleware
{
private const array ALLOWED_ORIGINS = [
'https://app.example.com',
'https://admin.example.com',
];
public function handle(Request $request, Response $response): Response
{
$origin = $request->headers->get('Origin');
if (in_array($origin, self::ALLOWED_ORIGINS, true)) {
$response->headers->set('Access-Control-Allow-Origin', $origin);
$response->headers->set('Access-Control-Allow-Credentials', 'true');
$response->headers->set('Vary', 'Origin');
}
return $response;
}
}
4. Missing Vary: Origin Header
// VULNERABLE: Without Vary, CDN/proxy may cache wrong CORS headers
$response->headers->set('Access-Control-Allow-Origin', $dynamicOrigin);
// Missing: $response->headers->set('Vary', 'Origin');
// CDN caches response for origin A, serves to origin B
5. Overly Permissive Methods/Headers
// VULNERABLE: Allows all methods including DELETE, PATCH
header('Access-Control-Allow-Methods: *');
header('Access-Control-Allow-Headers: *');
// CORRECT: Minimal required methods
$response->headers->set('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
$response->headers->set('Access-Control-Allow-Headers', 'Content-Type, Authorization');
6. Missing Preflight Handling
// VULNERABLE: OPTIONS request not handled — browser blocks request
class ApiController
{
public function handle(Request $request): Response
{
// No OPTIONS handling — preflight fails
return $this->processRequest($request);
}
}
// CORRECT: Handle preflight
if ($request->getMethod() === 'OPTIONS') {
$response = new Response('', 204);
$response->headers->set('Access-Control-Allow-Origin', $allowedOrigin);
$response->headers->set('Access-Control-Allow-Methods', 'GET, POST');
$response->headers->set('Access-Control-Max-Age', '86400');
return $response;
}
7. Regex Origin Matching (Bypass Risk)
// VULNERABLE: Regex can be bypassed
$origin = $request->headers->get('Origin');
if (preg_match('/example\.com$/', $origin)) {
// Matches: evil-example.com, phishing-example.com
$response->headers->set('Access-Control-Allow-Origin', $origin);
}
// CORRECT: Exact match or proper regex
if (preg_match('/^https:\/\/([a-z]+\.)?example\.com$/', $origin)) {
$response->headers->set('Access-Control-Allow-Origin', $origin);
}
Grep Patterns
# CORS headers
Grep: "Access-Control-Allow-Origin|Access-Control-Allow-Credentials" --glob "**/*.php"
Grep: "Access-Control-Allow-Methods|Access-Control-Allow-Headers" --glob "**/*.php"
# Wildcard origin
Grep: "Allow-Origin.*\*|allowed_origins.*\*" --glob "**/*.php" --glob "**/*.yaml"
# Dynamic origin reflection
Grep: "Origin.*header|getHeader.*Origin" --glob "**/*.php"
# CORS framework config
Grep: "cors|CORS" --glob "**/*.yaml" --glob "**/*.yml" --glob "**/*.php"
# Missing Vary header
Grep: "Allow-Origin" --glob "**/*.php"
Grep: "Vary.*Origin" --glob "**/*.php"
# Preflight handling
Grep: "OPTIONS|preflight" --glob "**/*.php"
Severity Classification
| Pattern | Severity |
|---|---|
| Dynamic origin reflection + credentials | 🔴 Critical |
| Wildcard origin on authenticated API | 🔴 Critical |
| Weak regex origin matching | 🟠 Major |
| Missing Vary: Origin | 🟠 Major |
| Wildcard methods/headers | 🟡 Minor |
| Missing preflight handling | 🟡 Minor |
Output Format
### CORS Security: [Description]
**Severity:** 🔴/🟠/🟡
**Location:** `file.php:line`
**CWE:** CWE-942 (Overly Permissive CORS Policy)
**OWASP:** A05:2021 — Security Misconfiguration
**Issue:**
[Description of the CORS misconfiguration]
**Attack Scenario:**
[How attacker exploits this from malicious origin]
**Current Configuration:**
Access-Control-Allow-Origin: * Access-Control-Allow-Credentials: true
**Fix:**
```php
// Secure CORS configuration
当前收录版本
0.0.1
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
待提升项
-
缺少 When to Use 章节 原报告严重程度:轻微
文档未明确说明适用场景和使用时机,如开发阶段、代码审查或 CI/CD 集成。
改进建议:建议添加 'When to Use' 章节,说明该 Skill 适用于 PHP 项目安全审计、API 开发阶段或自动化安全扫描场景。
亮点
- 提供 CORS 安全审计功能,覆盖 OWASP A05:2021 安全风险
- 检测多种高危配置模式,包括动态来源反射、通配符凭据等
- 适用于 PHP 项目安全开发和代码审查
亮点
- 触发词精准完整,覆盖 CORS 安全审计核心功能
- description 清晰列出检测项,边界明确,不易误触
待提升项
-
文档较长,建议分节优化 原报告严重程度:轻微
文档内容详尽但篇幅较长,可能影响快速查阅体验。
改进建议:建议将检测模式、Grep 模式等拆分为独立子章节或文件,提升可读性。
亮点
- 结构清晰,Phase/步骤分明,包含端到端示例
- frontmatter 完整,输出格式规范,便于集成
待提升项
-
缺少误报处理与确认机制说明 原报告严重程度:轻微
未说明如何处理 Grep 匹配的误报,以及不可逆操作(如自动修复)的确认机制。
改进建议:建议补充误报过滤策略,并说明在自动修复前应进行人工确认。
亮点
- 工具来源明确,参数正确,覆盖主要异常场景
- 提供具体 Grep 命令,便于实际执行和集成
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
-
账号、密钥或授权
使用专用、最小权限账号,不把密钥粘贴到公开内容或命令日志;核对接收数据的服务与租户。
主文档提及 · 第 3, 22, 27, 28, 34 行
文档引用的域名或地址
这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。
- admin.example.com
- app.example.com
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。