-
Notifications
You must be signed in to change notification settings - Fork 38
/
burp_scanner_issues.py
317 lines (237 loc) · 10.2 KB
/
burp_scanner_issues.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
"""
@author: moloch
Scanner issues reported by the plugin.
"""
# pylint: disable=E0602,C0103,W0621,R0201
from burp import IScanIssue
class BaseCSPIssue(IScanIssue):
"""
Just a base class with some helpful docstrings and a slightly modified
constructor so we can track what directive we're reporting about.
"""
# pylint: disable=R0913
def __init__(self, httpService, url, httpMessages, severity, confidence,
directive=None):
"""
Setters for all the getters, `directive' is optional
"""
self._httpService = httpService
self._url = url
self._httpMessages = httpMessages
self._severity = severity
self._confidence = confidence
self._directive = directive
def getUrl(self):
"""
This method returns the URL for which the issue was generated.
@return The URL for which the issue was generated.
"""
return self._url
def getIssueName(self):
"""
This method returns the name of the issue type.
@return The name of the issue type (e.g. "SQL injection").
"""
raise NotImplementedError()
def getIssueType(self):
"""
This method returns a numeric identifier of the issue type. See the Burp
Scanner help documentation for a listing of all the issue types.
@return A numeric identifier of the issue type.
"""
return 0 # https://portswigger.net/burp/help/scanner_issuetypes.html
def getSeverity(self):
"""
This method returns the issue severity level.
@return The issue severity level. Expected values are "High", "Medium",
"Low", "Information" or "False positive".
"""
return self._severity
def getConfidence(self):
"""
This method returns the issue confidence level.
@return The issue confidence level. Expected values are "Certain", "Firm"
or "Tentative".
"""
return self._confidence
def getIssueBackground(self):
"""
This method returns a background description for this type of issue.
@return A background description for this type of issue, or
<code>null</code> if none applies.
"""
return """
Content security policy (CSP) is an HTML5 standard primarily designed to mitigate
the issue of cross-site scripting (XSS) and other content injection vulnerabilities
within web applications. Weak content security policies stem from overly permissive
or ineffective content source directives.
"""
def getRemediationBackground(self):
"""
This method returns a background description of the remediation for this
type of issue.
@return A background description of the remediation for this type of
issue, or
<code>null</code> if none applies.
"""
return """
While non-trivial to implement, modern browser headers such
as Content-Security-Policy (CSP) can provide extremely robust protection against
XSS and related content injection issues. To fix weak policies enforce as much
restriction on the content sources as possible, strive to disable unsafe, insecure,
and wildcard sources, and where possible limit 3rd party domains.
"""
def getIssueDetail(self):
"""
This method returns detailed information about this specific instance of
the issue.
@return Detailed information about this specific instance of the issue,
or
<code>null</code> if none applies.
"""
raise NotImplementedError()
def getRemediationDetail(self):
"""
This method returns detailed information about the remediation for this
specific instance of the issue.
@return Detailed information about the remediation for this specific
instance of the issue, or
<code>null</code> if none applies.
"""
raise NotImplementedError()
def getHttpMessages(self):
"""
This method returns the HTTP messages on the basis of which the issue was
generated.
@return The HTTP messages on the basis of which the issue was generated.
Note: The items in this array should be instances of
<code>IHttpRequestResponseWithMarkers</code> if applicable, so that
details of the relevant portions of the request and response messages are
available.
"""
if isinstance(self._httpMessages, list):
return self._httpMessages
else:
return [self._httpMessages]
def getHttpService(self):
"""
This method returns the HTTP service for which the issue was generated.
@return The HTTP service for which the issue was generated.
"""
return self._httpService
class WildcardContentSource(BaseCSPIssue):
"""
Wildcard content sources. Note: this does not flag wildcard subdomains
"""
def getIssueName(self):
return "Wildcard Content Source: %s" % self._directive
def getIssueDetail(self):
return "The %s CSP directive does not enforce any restrictions on what \
origins content can be loaded from." % self._directive
def getRemediationDetail(self):
return "Remove all wildcards from the content security policy."
class WildcardSubdomainContentSource(BaseCSPIssue):
"""
Wildcard subdomain content sources.
"""
def getIssueName(self):
return "Wildcard Subdomain Content Source: %s" % self._directive
def getIssueDetail(self):
return "Wildcard subdomains expose additional attack surface, since an \
attacker can potentially leverage a vulnerability in any subdomain to \
to bypass the CSP."
def getRemediationDetail(self):
return "Avoid use of wildcard subdomains in CSP directives."
class UnsafeContentSource(BaseCSPIssue):
""" Any directive that allows unsafe content (e.g. 'unsafe-eval') """
def getIssueName(self):
return "Unsafe Content Source: %s" % self._directive
def getIssueDetail(self):
return "This content security policy allows for unsafe content sources"
def getRemediationDetail(self):
return "Refactor the website to remove inline JavaScript and CSS"
class InsecureContentDirective(BaseCSPIssue):
"""
Any directive that allows insecure network protocols (e.g. ws: or http:)
"""
def getIssueName(self):
return "Insecure Content Source: %s" % self._directive
def getIssueDetail(self):
return "The content directive %s allows resources to be loaded over \
insecure network protocols." % self._directive
def getRemediationDetail(self):
return "Restrict content sources to only use secure protocols such as \
https:// and wss://."
class MissingDirective(BaseCSPIssue):
"""
Directives that 'fail open', that is to say they are not restricted by the
CSP and do not fallback to `default-src'.
"""
def getIssueName(self):
return "Missing CSP Directive: %s" % self._directive
def getIssueDetail(self):
return "The %s content directive does not fallback to default-src, if \
no content sources are explicitly set it will default to completely \
open." % self._directive
def getRemediationDetail(self):
return "Explicitly set a %s directive in your content policy." % self._directive
class WeakDefaultSource(BaseCSPIssue):
""" Any `default-src' that is not 'none' 'self' or 'https:' """
def getIssueName(self):
return "Weak default-src Directive"
def getIssueDetail(self):
return "The default content source should be as restrictive as possible \
the content policy for this website does not restrict the default source \
to either 'none' 'self' (and 'https:')."
def getRemediationDetail(self):
return "Set the default-src to either 'self' or preferrably 'none'. If \
the default source is set to 'self' also consider adding 'https:' to \
ensure resources are loaded over a secure network connection."
class DeprecatedHeader(BaseCSPIssue):
""" Flags use of `X-WebKit-CSP' and `X-Content-Security-Policy' """
def getIssueName(self):
return "Deprecated Header"
def getIssueDetail(self):
return "The site uses a deprecated CSP header"
def getRemediationDetail(self):
return "Change the server response header to `Content-Security-Policy'"
class ReportOnlyHeader(BaseCSPIssue):
""" Flags use of `Content-Security-Policy-Report-Only' """
def getIssueName(self):
return "Report Only Header"
def getIssueDetail(self):
return "The site uses a CSP in report-only mode"
def getRemediationDetail(self):
return "Change the server response header to `Content-Security-Policy'"
class NonceContentSource(BaseCSPIssue):
""" Alerts the user that a `nonce-' source was found """
def getIssueName(self):
return "Nonce Content Source"
def getIssueDetail(self):
return "This site uses nonces to secure inline content"
def getRemediationDetail(self):
return "Refactor the website to disallow all inline content, and remove \
nonce content sources from the CSP."
class KnownCSPBypass(BaseCSPIssue):
""" Reports a known bypass in a domain whitelisted by a CSP """
# pylint: disable=W0231,R0913
def __init__(self, httpService, url, httpMessages, severity, confidence,
directive=None, bypass=None):
"""
Burp uses old style classes so we can't use super()
"""
self._httpService = httpService
self._url = url
self._httpMessages = httpMessages
self._severity = severity
self._confidence = confidence
self._directive = directive
self._bypass = bypass
def getIssueName(self):
return "Known CSP Bypass: %s" % self._directive
def getIssueDetail(self):
return "A known bypass exists in the '%s' directive for the domain \
'%s'. %s" % (self._directive, self._bypass[0], self._bypass[1])
def getRemediationDetail(self):
return "Remove the content source '%s' domain from your '%s' CSP \
directive." % (self._bypass[0], self._directive)