-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
319 lines (303 loc) · 15.2 KB
/
index.html
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
318
319
<!DOCTYPE html>
<html>
<head>
<title>Am I Secure?</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<script src="bootstrap/js/bootstrap-fileupload.min.js"></script>
<style>
.vulnerable {background-color: red;}
.safe {background-color: green;}
</style>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="bootstrap/css/bootstrap-fileupload.min.css" rel="stylesheet" media="screen">
</head>
<body>
<div class='container'>
<div class='hero-unit'>
<h1>Am I Secure?</h1>
<p>After all the recent Rails security problems recently this page tries to keep track
of which vulnerabilities you may or may not be vulnerable to by checking your Gemfile.lock.</p>
<p>Any vulnerabilities that are common to a fairly normal Rails stack have a good chance
of appearing on here. If you think there is an importantant vulnerability that I'm missing
please <a href='mailto:harry+amisecure@haeg.in'>email me</a>.</p>
<p>This tool currently only supports 2013 vulnerabilities.</p>
<p>Your Gemfile.lock will not be uploaded. All the analysis is done in
your own browser using JavaScript. A modern browser is required.</p>
</div>
<div class="fileupload fileupload-new span12" style='text-align: center' data-provides="fileupload">
<div class="input-append" style='text-align: left'>
<div class="uneditable-input span3">
<i class="icon-file fileupload-exists"></i>
<span class="fileupload-preview"></span>
</div>
<span class="btn btn-file">
<span class="fileupload-new">Select file</span>
<span class="fileupload-exists">Change</span>
<input type="file" id='file-input' />
</span>
<a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Remove</a>
</div>
</div>
<div style='clear: both' />
<div class='alert alert-error'>
<button type='button' class='close' data-dismiss='alert'>×</button>
<strong>Warning!</strong> <span id='error_text' />
</div>
<table class='table'>
<tr><th>Vulnerability</th><th>At Risk?</th><th>More Info</th></tr>
<tr>
<td>Rails CVE-2013-1854</td>
<td class='exploit' data_exploit='rails_1854'></td>
<td><a href='https://groups.google.com/forum/#!topic/rubyonrails-security/jgJ4cjjS8FE/discussion' target='_blank'>Click here</a></td>
</tr>
<tr>
<td>Rails CVE-2013-1855</td>
<td class='exploit' data_exploit='rails_1855'></td>
<td><a href='https://groups.google.com/forum/#!topic/rubyonrails-security/4_QHo4BqnN8/discussion' target='_blank'>Click here</a></td>
</tr>
<tr>
<td>Rails CVE-2013-1856</td>
<td class='exploit' data_exploit='rails_1856'></td>
<td><a href='https://groups.google.com/d/topic/rubyonrails-security/KZwsQbYsOiI/discussion' target='_blank'>Click here</a></td>
</tr>
<tr>
<td>Rails CVE-2013-1857</td>
<td class='exploit' data_exploit='rails_1857'></td>
<td><a href='https://groups.google.com/d/topic/rubyonrails-security/4_QHo4BqnN8/discussion' target='_blank'>Click here</a></td>
</tr>
<tr>
<td>Rack CVE-2013-0263/0262</td>
<td class='exploit' data_exploit='rack'></td>
<td><a href='https://support.cloud.engineyard.com/entries/23128893-February-8-2013-Rack-Vulnerabilities-CVE-2013-0263-CVE-2013-0262' target='_blank'>Click here</a></td>
</tr>
<tr>
<td>JSON gem CVE-2013-0269</td>
<td class='exploit' data_exploit='json'></td>
<td><a href='https://groups.google.com/forum/?fromgroups=#!topic/rubyonrails-security/4_YvCpLzL58' target='_blank'>Click here</a></td>
</tr>
<tr>
<td>Rails CVE-2013-0156</td>
<td class='exploit' data_exploit='rails_0156'></td>
<td><a href='https://groups.google.com/forum/?fromgroups=#!topic/rubyonrails-security/61bkgvnSGTQ' target='_blank'>Click here</a></td>
</tr>
<tr>
<td>Rails CVE-2013-0333</td>
<td class='exploit' data_exploit='rails_0333'></td>
<td><a href='https://groups.google.com/forum/?fromgroups=#!topic/rubyonrails-security/1h2DR63ViGo' target='_blank'>Click here</a></td>
</tr>
<tr>
<td>Rails CVE-2013-0277</td>
<td class='exploit' data_exploit='rails_0277'></td>
<td><a href='https://groups.google.com/forum/?fromgroups=#!topic/rubyonrails-security/KtmwSbEpzrU' target='_blank'>Click here</a></td>
</tr>
<tr>
<td>Rails CVE-2012-5664</td>
<td class='exploit' data_exploit='rails_5664'></td>
<td><a href='https://groups.google.com/forum/?fromgroups=#!topic/rubyonrails-security/DCNTNp_qjFM' target='_blank'>Click here</a></td>
</tr>
</table>
</div>
<script>
function setError(text) {
if (text == null) {
$('.alert').hide();
} else {
$('#error_text').html(text);
$('.alert').show();
}
}
function reset() {
console.log('Calling reset');
setError(null);
$('tr').removeClass('success error');
}
function handleFileUpload(evt) {
reset();
var f = evt.target.files[0];
if (f.name === 'Gemfile.lock') {
var reader = new FileReader();
reader.readAsText(f);
reader.onload = function(evt) {
var file = evt.target.result;
checkExploits(file);
};
} else {
setError('You need to provide a Gemfile.lock.');
}
}
function checkExploits(file) {
$('.exploit').each(function(idx, exploit) {
var exploit = $(exploit);
var name = exploit.attr('data_exploit');
console.log("Checking exploit: " + name);
var vulnerable = vulnerabilities[name](file);
if (vulnerable) {
exploit.parent().removeClass('success').addClass('error');
exploit.html('BAD');
} else {
exploit.parent().removeClass('error').addClass('success');
exploit.html('OK');
}
});
}
vulnerabilities = {
rack: function(file){
var match_rack_version = /\srack\s*\(([0-9\.]+)\)/;
var matches = file.match(match_rack_version);
var vulnerable = null;
if (matches != null) {
var v = matches[1].split('.');
if ((v[1] == 4 && v[2] < 5) || (v[1] == 5 && v[2] < 5) || (v[1] == 1 && v[2] < 6) || (v[1] == 2 && v[2] < 8) || (v[1] == 3 && v[2] < 10)) {
vulnerable = true;
} else {
vulnerable = false;
}
}
return vulnerable;
},
json: function(file){
// fixed in 1.7.7, 1.6.8, 1.5.5
var match_json_version = /\sjson\s*\(([0-9\.]+)\)/;
var matches = file.match(match_json_version);
var vulnerable = false;
if (matches != null) {
var v = matches[1].split('.');
if ((v[1] == 7 && v[2] < 7) || (v[1] == 6 && v[2] < 8) || (v[1] == 5 && v[2] < 5) || v[1] <= 4) {
vulnerable = true;
}
}
return vulnerable;
},
rails_0156: function(file){
var match_version = /\srails\s*\(([0-9\.]+)\)/;
var matches = file.match(match_version);
var vulnerable = true;
if (matches != null) {
var v = matches[1].split('.');
if (v[0] == 3) {
if ((v[1] == 2 && v[2] >= 11) || (v[1] == 1 && v[2] >= 10) || (v[1] == 0 && v[2] >= 15)) {
vulnerable = false;
}
} else if ((v[0] == 2 && v[1] == 3 && v[2] >= 15) || (v[0] == 2 && v[1] > 3)) {
vulnerable = false;
}
}
return vulnerable;
},
rails_0333: function(file){
var match_version = /\srails\s*\(([0-9\.]+)\)/;
var has_yajl = /\syajl-ruby\s*\(([0-9\.]+)\)/.test(file);
var matches = file.match(match_version);
var vulnerable = true;
if (matches != null) {
var v = matches[1].split('.');
if ((v[0] == 3 && v[1] >= 0) || (v[0] == 3 && v[1] == 0 && v[2] >= 20) || (v[0] == 2 && (v[1] >= 3 || v[2] >= 16))) {
vulnerable = false;
}
}
return (vulnerable && !has_yajl);
},
rails_0277: function(file){
var match_version = /\srails\s*\(([0-9\.]+)\)/;
var matches = file.match(match_version);
var vulnerable = true;
if (matches != null) {
var v = matches[1].split('.');
if ((v[0] == 3 && v[1] >= 0) || (v[0] == 2 && (v[1] >= 0 || v[2] >= 17))) {
vulnerable = false;
}
}
return vulnerable;
},
rails_5664: function(file){
var match_version = /\srails\s*\(([0-9\.]+)\)/;
var matches = file.match(match_version);
var vulnerable = true;
if (matches != null) {
var v = matches[1].split('.');
if (v[0] == 3 && ((v[1] == 1 && v[2] >= 9) || (v[1] == 0 && v[2] >= 18) || (v[1] == 2 && v[2] >= 10))) {
vulnerable = false;
}
}
return vulnerable;
},
rails_1854: function(file){
var match_version = /\srails\s*\(([0-9\.]+)\)/;
var matches = file.match(match_version);
var vulnerable = true;
if (matches != null) {
var v = matches[1].split('.');
if (v[0] == 3 && ((v[1] == 2 && v[2] >= 13) || (v[1] == 1 && v[2] >= 12) || (v[1] == 0))) {
vulnerable = false;
} else if (v[0] == 2 && v[1] == 3 && v[2] >= 18) {
vulnerable = false;
}
}
return vulnerable;
},
rails_1855: function(file){
var match_version = /\srails\s*\(([0-9\.]+)\)/;
var matches = file.match(match_version);
var vulnerable = true;
if (matches != null) {
var v = matches[1].split('.');
if (v[0] == 3 && ((v[1] == 2 && v[2] >= 13) || (v[1] == 1 && v[2] >= 12))) {
vulnerable = false;
} else if (v[0] == 2 && v[1] == 3 && v[2] >= 18) {
vulnerable = false;
}
}
return vulnerable;
},
rails_1856: function(file){
var match_version = /\srails\s*\(([0-9\.]+)\)/;
var matches = file.match(match_version);
var vulnerable = true;
if (matches != null) {
var v = matches[1].split('.');
if (v[0] == 3 && ((v[1] == 2 && v[2] >= 13) || (v[1] == 1 && v[2] >= 12))) {
vulnerable = false;
} else if (v[0] == 2) {
vulnerable = false;
}
}
return vulnerable;
},
rails_1857: function(file){
var match_version = /\srails\s*\(([0-9\.]+)\)/;
var matches = file.match(match_version);
var vulnerable = true;
if (matches != null) {
var v = matches[1].split('.');
if (v[0] == 3 && ((v[1] == 2 && v[2] >= 13) || (v[1] == 1 && v[2] >= 12))) {
vulnerable = false;
} else if (v[0] == 2 && v[1] == 3 && v[2] >= 18) {
vulnerable = false;
}
}
return vulnerable;
}
}
reset();
if (window.File && window.FileReader && window.FileList) {
// should work
document.getElementById('file-input').addEventListener('change', handleFileUpload, false);
} else {
setError("Sorry, your browser isn't modern enough.");
}
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-8294302-6']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>