File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed
Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change 1+ id: 46cae4a9-45ff-406a-80bc-c9a0fe630535
2+ name: CORS misconfiguration
3+ function: SCAN_CHECK_ACTIVE_PER_REQUEST
4+ location: SCANNER
5+ source: |
6+ /**
7+ * Identifies CORS misconfiguration.
8+ * @author PortSwigger
9+ **/
10+
11+ if (!requestResponse.hasResponse())
12+ {
13+ return null;
14+ }
15+
16+ var evilHttps = "https://" + api().utilities().randomUtils().randomString(6) + "." + api().utilities().randomUtils().randomString(3);
17+ var evilHttp = "http://" + api().utilities().randomUtils().randomString(6) + "." + api().utilities().randomUtils().randomString(3);
18+
19+ for (var origin : new String[]{evilHttps, evilHttp})
20+ {
21+ var rr = http.sendRequest(requestResponse.request().withAddedHeader("Origin", origin));
22+ if (!rr.hasResponse())
23+ {
24+ continue;
25+ }
26+
27+ var headers = rr.response().headers().toString().toLowerCase();
28+ var creds = headers.contains("access-control-allow-credentials: true");
29+ var reflect = headers.contains("access-control-allow-origin: " + origin.toLowerCase());
30+ var vary = headers.contains("vary: origin");
31+
32+ if (reflect)
33+ {
34+ var severity = creds ? AuditIssueSeverity.HIGH : AuditIssueSeverity.MEDIUM;
35+ var note = vary ? "" : " (missing Vary: Origin)";
36+ return AuditResult.auditResult(
37+ AuditIssue.auditIssue(
38+ "CORS: arbitrary origin reflection" + note,
39+ "Reflected Origin: " + origin + "; credentials=" + creds,
40+ "Use strict allowlist; include Vary: Origin.",
41+ rr.request().url(),
42+ severity,
43+ AuditIssueConfidence.FIRM,
44+ "",
45+ "",
46+ severity,
47+ rr
48+ )
49+ );
50+ }
51+ }
52+
53+ return AuditResult.auditResult();
You can’t perform that action at this time.
0 commit comments