loofah 2.2.0 → 2.3.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of loofah might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6656f9e5edc815b2c5ee676d1c4fb818b2dc03f4
4
- data.tar.gz: 7bea1d04f8af479fd825c7adf687f0ca0c624830
2
+ SHA256:
3
+ metadata.gz: 1196afab25d29644d1961e4516ac317a2c38dee3295f35354c468e6a9318fa55
4
+ data.tar.gz: 2e07ff641edb37d2b0dce2933288da4667d4b680a586912af9c171db7dfb0a63
5
5
  SHA512:
6
- metadata.gz: 42f030b7228867ebf322c9d8e286349e1288ef3d60f90fe404b0d9250cc626ea6fad84ff1325cd2754ea4a7fdf80802a4bdae5a9b7121ac312e56d96c280d1a3
7
- data.tar.gz: 8a67c56281a65b6e89d8623f40423ae41ed2628eeb0a90193196cfb87aeb4efccbe23c961b05ab26a247bac0117a55b68dea97ab6b67076e272ebad8471e33cb
6
+ metadata.gz: 37ac2cdb0d136da417cff62e3845c5b71769f044d8150c636a549dc9ca4cf98bcef4c6d2b6e653eff56922b95d812ed39310a406c49366c14791456ca905e8fe
7
+ data.tar.gz: 0fa3cdd75a3d2950801a1cfe7f8d4cad6bb73bbec67d24ba25980c09a565f6c95c5d664c1789ccd62486d1917c685a5b0f762cc073a054bbb0f02fb0222688f0
@@ -1,8 +1,81 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.3.1 / 2019-10-22
4
+
5
+ ### Security
6
+
7
+ Address CVE-2019-15587: Unsanitized JavaScript may occur in sanitized output when a crafted SVG element is republished.
8
+
9
+ This CVE's public notice is at https://github.com/flavorjones/loofah/issues/171
10
+
11
+
12
+ ## 2.3.0 / 2019-09-28
13
+
14
+ ### Features
15
+
16
+ * Expand set of allowed protocols to include `tel:` and `line:`. [#104, #147]
17
+ * Expand set of allowed CSS functions. [related to #122]
18
+ * Allow greater precision in shorthand CSS values. [#149] (Thanks, @danfstucky!)
19
+ * Allow CSS property `list-style` [#162] (Thanks, @jaredbeck!)
20
+ * Allow CSS keywords `thick` and `thin` [#168] (Thanks, @georgeclaghorn!)
21
+ * Allow HTML property `contenteditable` [#167] (Thanks, @andreynering!)
22
+
23
+
24
+ ### Bug fixes
25
+
26
+ * CSS hex values are no longer limited to lowercase hex. Previously uppercase hex were scrubbed. [#165] (Thanks, @asok!)
27
+
28
+
29
+ ### Deprecations / Name Changes
30
+
31
+ The following method and constants are hereby deprecated, and will be completely removed in a future release:
32
+
33
+ * Deprecate `Loofah::Helpers::ActionView.white_list_sanitizer`, please use `Loofah::Helpers::ActionView.safe_list_sanitizer` instead.
34
+ * Deprecate `Loofah::Helpers::ActionView::WhiteListSanitizer`, please use `Loofah::Helpers::ActionView::SafeListSanitizer` instead.
35
+ * Deprecate `Loofah::HTML5::WhiteList`, please use `Loofah::HTML5::SafeList` instead.
36
+
37
+ Thanks to @JuanitoFatas for submitting these changes in #164 and for making the language used in Loofah more inclusive.
38
+
39
+
40
+ ## 2.2.3 / 2018-10-30
41
+
42
+ ### Security
43
+
44
+ Address CVE-2018-16468: Unsanitized JavaScript may occur in sanitized output when a crafted SVG element is republished.
45
+
46
+ This CVE's public notice is at https://github.com/flavorjones/loofah/issues/154
47
+
48
+
49
+ ## Meta / 2018-10-27
50
+
51
+ The mailing list is now on Google Groups [#146](https://github.com/flavorjones/loofah/issues/146):
52
+
53
+ * Mail: loofah-talk@googlegroups.com
54
+ * Archive: https://groups.google.com/forum/#!forum/loofah-talk
55
+
56
+ This change was made because librelist no longer appears to be maintained.
57
+
58
+
59
+ ## 2.2.2 / 2018-03-22
60
+
61
+ Make public `Loofah::HTML5::Scrub.force_correct_attribute_escaping!`,
62
+ which was previously a private method. This is so that downstream gems
63
+ (like rails-html-sanitizer) can use this logic directly for their own
64
+ attribute scrubbers should they need to address CVE-2018-8048.
65
+
66
+
67
+ ## 2.2.1 / 2018-03-19
68
+
69
+ ### Security
70
+
71
+ Addresses CVE-2018-8048. Loofah allowed non-whitelisted attributes to be present in sanitized output when input with specially-crafted HTML fragments.
72
+
73
+ This CVE's public notice is at https://github.com/flavorjones/loofah/issues/144
74
+
75
+
3
76
  ## 2.2.0 / 2018-02-11
4
77
 
5
- Features:
78
+ ### Features:
6
79
 
7
80
  * Support HTML5 `<main>` tag. #133 (Thanks, @MothOnMars!)
8
81
  * Recognize HTML5 block elements. #136 (Thanks, @MothOnMars!)
@@ -10,32 +83,32 @@ Features:
10
83
  * Support for whitelisting CSS functions, initially just `calc` and `rgb`. #122/#123/#129 (Thanks, @NikoRoberts!)
11
84
  * Whitelist CSS property `list-style-type`. #68/#137/#142 (Thanks, @andela-ysanni and @NikoRoberts!)
12
85
 
13
- Bugfixes:
86
+ ### Bugfixes:
14
87
 
15
88
  * Properly handle nested `script` tags. #127.
16
89
 
17
90
 
18
91
  ## 2.1.1 / 2017-09-24
19
92
 
20
- Bugfixes:
93
+ ### Bugfixes:
21
94
 
22
95
  * Removed warning for unused variable. #124 (Thanks, @y-yagi!)
23
96
 
24
97
 
25
98
  ## 2.1.0 / 2017-09-24
26
99
 
27
- Notes:
100
+ ### Notes:
28
101
 
29
102
  * Re-implemented CSS parsing and sanitization using the [crass](https://github.com/rgrove/crass) library. #91
30
103
 
31
104
 
32
- Features:
105
+ ### Features:
33
106
 
34
107
  * Added :noopener HTML scrubber (Thanks, @tastycode!)
35
108
  * Support `data` URIs with the following media types: text/plain, text/css, image/png, image/gif, image/jpeg, image/svg+xml. #101, #120. (Thanks, @mrpasquini!)
36
109
 
37
110
 
38
- Bugfixes:
111
+ ### Bugfixes:
39
112
 
40
113
  * The :unprintable scrubber now scrubs unprintable characters in CDATA nodes (like `<script>`). #124
41
114
  * Allow negative values in CSS properties. Restores functionality that was reverted in v2.0.3. #91
@@ -43,14 +116,14 @@ Bugfixes:
43
116
 
44
117
  ## 2.0.3 / 2015-08-17
45
118
 
46
- Bug fixes:
119
+ ### Bug fixes:
47
120
 
48
121
  * Revert support for negative values in CSS properties due to slow performance. #90 (Related to #85.)
49
122
 
50
123
 
51
124
  ## 2.0.2 / 2015-05-05
52
125
 
53
- Bug fixes:
126
+ ### Bug fixes:
54
127
 
55
128
  * Fix error with `#to_text` when Loofah::Helpers hadn't been required. #75
56
129
  * Allow multi-word data attributes. #84 (Thanks, @jstorimer!)
@@ -59,24 +132,24 @@ Bug fixes:
59
132
 
60
133
  ## 2.0.1 / 2014-08-21
61
134
 
62
- Bug fixes:
135
+ ### Bug fixes:
63
136
 
64
137
  * Load RR correctly when running test files directly. (Thanks, @ktdreyer!)
65
138
 
66
139
 
67
- Notes:
140
+ ### Notes:
68
141
 
69
142
  * Extracted HTML5::Scrub#scrub_css_attribute to accommodate the Rails integration work. (Thanks, @kaspth!)
70
143
 
71
144
 
72
145
  ## 2.0.0 / 2014-05-09
73
146
 
74
- Compatibility notes:
147
+ ### Compatibility notes:
75
148
 
76
149
  * ActionView helpers now must be required explicitly: `require "loofah/helpers"`
77
150
  * Support for Ruby 1.8.7 and prior has been dropped
78
151
 
79
- Enhancements:
152
+ ### Enhancements:
80
153
 
81
154
  * HTML5 whitelist allows the following ...
82
155
  * tags: `article`, `aside`, `bdi`, `bdo`, `canvas`, `command`, `datalist`, `details`, `figcaption`, `figure`, `footer`, `header`, `mark`, `meter`, `nav`, `output`, `section`, `summary`, `time`
@@ -86,7 +159,7 @@ Enhancements:
86
159
  * `Loofah.fragment` accepts an optional encoding argument, compatible with `Nokogiri::HTML::DocumentFragment.parse`. #62 (Thanks, Ben Atkins!)
87
160
  * HTML5 sanitizers now remove attributes without values. (Thanks, Kasper Timm Hansen!)
88
161
 
89
- Bug fixes:
162
+ ### Bug fixes:
90
163
 
91
164
  * HTML5 sanitizers' CSS keyword check now actually works (broken in v2.0). Additional regression tests added. (Thanks, Kasper Timm Hansen!)
92
165
  * HTML5 sanitizers now allow negative arguments to CSS. #64 (Thanks, Jon Calhoun!)
@@ -99,7 +172,7 @@ Bug fixes:
99
172
 
100
173
  ## 1.2.0 (2011-08-08)
101
174
 
102
- Enhancements:
175
+ ### Enhancements:
103
176
 
104
177
  * Loofah::Helpers.sanitize_css is a replacement for Rails's built-in sanitize_css helper.
105
178
  * Improving ActionView integration.
@@ -107,7 +180,7 @@ Enhancements:
107
180
 
108
181
  ## 1.1.0 (2011-08-08)
109
182
 
110
- Enhancements:
183
+ ### Enhancements:
111
184
 
112
185
  * Additional HTML5lib whitelist elements (from html5lib 1524:80b5efe26230).
113
186
  Up to date with HTML5lib ruby code as of 1723:7ee6a0331856.
@@ -117,7 +190,7 @@ Enhancements:
117
190
 
118
191
  ## 1.0.0 (2010-10-26)
119
192
 
120
- Notes:
193
+ ### Notes:
121
194
 
122
195
  * Moved ActiveRecord functionality into `loofah-activerecord` gem.
123
196
  * Removed DEPRECATIONS.rdoc documenting 0.3.0 API changes.
@@ -125,7 +198,7 @@ Notes:
125
198
 
126
199
  ## 0.4.7 (2010-03-09)
127
200
 
128
- Enhancements:
201
+ ### Enhancements:
129
202
 
130
203
  * New methods Loofah::HTML::Document#to_text and
131
204
  Loofah::HTML::DocumentFragment#to_text do the right thing with
@@ -138,23 +211,23 @@ Enhancements:
138
211
 
139
212
  ## 0.4.4, 0.4.5, 0.4.6 (2010-02-01)
140
213
 
141
- Enhancements:
214
+ ### Enhancements:
142
215
 
143
216
  * Loofah::HTML::Document#text and Loofah::HTML::DocumentFragment#text now escape HTML entities.
144
217
 
145
- Bug fixes:
218
+ ### Bug fixes:
146
219
 
147
220
  * Loofah::XssFoliate was not properly escaping HTML entities when implicitly scrubbing a string attribute. GH #17
148
221
 
149
222
 
150
223
  ## 0.4.3 (2010-01-29)
151
224
 
152
- Enhancements:
225
+ ### Enhancements:
153
226
 
154
227
  * All built-in scrubbers are accepted by ActiveRecord::Base.xss_foliate
155
228
  * Loofah::XssFoliate.xss_foliate_all_models replaces use of the constant LOOFAH_XSS_FOLIATE_ALL_MODELS
156
229
 
157
- Miscellaneous:
230
+ ### Miscellaneous:
158
231
 
159
232
  * Modified documentation for bootstrapping XssFoliate in a Rails app,
160
233
  since the use of Bundler breaks the previously-documented method. To
@@ -163,18 +236,18 @@ Miscellaneous:
163
236
 
164
237
  ## 0.4.2 (2010-01-22)
165
238
 
166
- Enhancements:
239
+ ### Enhancements:
167
240
 
168
241
  * Implemented Node#scrub! for scrubbing subtrees.
169
242
  * Implemented NodeSet#scrub! for scrubbing a set of subtrees.
170
243
  * Document.text now only serializes <body> contents (ignores <head>)
171
244
  * <head>, <html> and <body> added to the HTML5lib whitelist.
172
245
 
173
- Bug fixes:
246
+ ### Bug fixes:
174
247
 
175
248
  * Supporting Rails apps that aren't loading ActiveRecord. GH #10
176
249
 
177
- Miscellaneous:
250
+ ### Miscellaneous:
178
251
 
179
252
  * Mailing list is now loofah@librelist.com / http://librelist.com
180
253
  * IRC channel is now \#loofah on freenode.
@@ -182,14 +255,14 @@ Miscellaneous:
182
255
 
183
256
  ## 0.4.1 (2009-11-23)
184
257
 
185
- Bugfix:
258
+ ### Bugfix:
186
259
 
187
260
  * Manifest fixed. Whoops.
188
261
 
189
262
 
190
263
  ## 0.4.0 (2009-11-21)
191
264
 
192
- Enhancements:
265
+ ### Enhancements:
193
266
 
194
267
  * Scrubber class introduced, allowing development of custom scrubbers.
195
268
  * Added support for XML documents and fragments.
@@ -200,20 +273,20 @@ Enhancements:
200
273
 
201
274
  ## 0.3.1 (2009-10-12)
202
275
 
203
- Bug fixes:
276
+ ### Bug fixes:
204
277
 
205
278
  * Scrubbed Documents properly render html, head and body tags when serialized.
206
279
 
207
280
 
208
281
  ## 0.3.0 (2009-10-06)
209
282
 
210
- Enhancements:
283
+ ### Enhancements:
211
284
 
212
285
  * New ActiveRecord extension `xss_foliate`, a drop-in replacement for xss_terminate[http://github.com/look/xss_terminate/tree/master].
213
286
  * Replacement methods for Rails's helpers, Loofah::Rails.sanitize and Loofah::Rails.strip_tags.
214
287
  * Official support (and test coverage) for Rails versions 2.3, 2.2, 2.1, 2.0 and 1.2.
215
288
 
216
- Deprecations:
289
+ ### Deprecations:
217
290
 
218
291
  * The methods strip_tags, whitewash, whitewash_document, sanitize, and
219
292
  sanitize_document have been deprecated. See DEPRECATED.rdoc for
@@ -222,7 +295,7 @@ Deprecations:
222
295
 
223
296
  ## 0.2.2 (2009-09-30)
224
297
 
225
- Enhancements:
298
+ ### Enhancements:
226
299
 
227
300
  * ActiveRecord extension scrubs fields in a before_validation callback
228
301
  (was previously in a before_save)
@@ -230,12 +303,12 @@ Enhancements:
230
303
 
231
304
  ## 0.2.1 (2009-09-19)
232
305
 
233
- Enhancements:
306
+ ### Enhancements:
234
307
 
235
308
  * when loaded in a Rails app, automatically extend ActiveRecord::Base
236
309
  with html_fragment and html_document. GH #6 (Thanks Josh Nichols!)
237
310
 
238
- Bugfixes:
311
+ ### Bugfixes:
239
312
 
240
313
  * ActiveRecord scrubbing should generate strings instead of Document or
241
314
  DocumentFragment objects. GH #5
data/Gemfile CHANGED
@@ -15,8 +15,8 @@ gem "hoe-gemspec", ">=0", :group => [:development, :test]
15
15
  gem "hoe-debugging", ">=0", :group => [:development, :test]
16
16
  gem "hoe-bundler", ">=0", :group => [:development, :test]
17
17
  gem "hoe-git", ">=0", :group => [:development, :test]
18
- gem "concourse", ">=0.15.0", :group => [:development, :test]
19
- gem "rdoc", "~>4.0", :group => [:development, :test]
20
- gem "hoe", "~>3.16", :group => [:development, :test]
18
+ gem "concourse", ">=0.26.0", :group => [:development, :test]
19
+ gem "rdoc", ">=4.0", "<7", :group => [:development, :test]
20
+ gem "hoe", "~>3.17", :group => [:development, :test]
21
21
 
22
22
  # vim: syntax=ruby
@@ -5,6 +5,7 @@ MIT-LICENSE.txt
5
5
  Manifest.txt
6
6
  README.md
7
7
  Rakefile
8
+ SECURITY.md
8
9
  benchmark/benchmark.rb
9
10
  benchmark/fragment.html
10
11
  benchmark/helper.rb
@@ -14,17 +15,20 @@ lib/loofah/elements.rb
14
15
  lib/loofah/helpers.rb
15
16
  lib/loofah/html/document.rb
16
17
  lib/loofah/html/document_fragment.rb
18
+ lib/loofah/html5/libxml2_workarounds.rb
19
+ lib/loofah/html5/safelist.rb
17
20
  lib/loofah/html5/scrub.rb
18
- lib/loofah/html5/whitelist.rb
19
21
  lib/loofah/instance_methods.rb
20
22
  lib/loofah/metahelpers.rb
21
23
  lib/loofah/scrubber.rb
22
24
  lib/loofah/scrubbers.rb
23
25
  lib/loofah/xml/document.rb
24
26
  lib/loofah/xml/document_fragment.rb
27
+ test/assets/msword.html
25
28
  test/assets/testdata_sanitizer_tests1.dat
26
29
  test/helper.rb
27
30
  test/html5/test_sanitizer.rb
31
+ test/html5/test_scrub.rb
28
32
  test/integration/test_ad_hoc.rb
29
33
  test/integration/test_helpers.rb
30
34
  test/integration/test_html.rb
data/README.md CHANGED
@@ -1,36 +1,29 @@
1
1
  # Loofah
2
2
 
3
3
  * https://github.com/flavorjones/loofah
4
- * http://rubydoc.info/github/flavorjones/loofah/master/frames
5
- * http://librelist.com/browser/loofah
4
+ * Docs: http://rubydoc.info/github/flavorjones/loofah/master/frames
5
+ * Mailing list: [loofah-talk@googlegroups.com](https://groups.google.com/forum/#!forum/loofah-talk)
6
6
 
7
7
  ## Status
8
8
 
9
9
  |System|Status|
10
10
  |--|--|
11
- | Concourse | [![Concourse CI](https://ci.nokogiri.org/api/v1/teams/nokogiri-core/pipelines/loofah/jobs/ruby-2.5/badge)](https://ci.nokogiri.org/teams/nokogiri-core/pipelines/loofah?groups=master) |
11
+ | Concourse CI | [![Concourse CI](https://ci.nokogiri.org/api/v1/teams/nokogiri-core/pipelines/loofah/jobs/ruby-2.5/badge)](https://ci.nokogiri.org/teams/nokogiri-core/pipelines/loofah?groups=master) |
12
12
  | Code Climate | [![Code Climate](https://codeclimate.com/github/flavorjones/loofah.svg)](https://codeclimate.com/github/flavorjones/loofah) |
13
- | Version Eye | [![Version Eye](https://www.versioneye.com/ruby/loofah/badge.png)](https://www.versioneye.com/ruby/loofah) |
14
13
 
15
14
 
16
15
  ## Description
17
16
 
18
- Loofah is a general library for manipulating and transforming HTML/XML
19
- documents and fragments. It's built on top of Nokogiri and libxml2, so
20
- it's fast and has a nice API.
17
+ Loofah is a general library for manipulating and transforming HTML/XML documents and fragments, built on top of Nokogiri.
21
18
 
22
- Loofah excels at HTML sanitization (XSS prevention). It includes some
23
- nice HTML sanitizers, which are based on HTML5lib's whitelist, so it
24
- most likely won't make your codes less secure. (These statements have
25
- not been evaluated by Netexperts.)
19
+ Loofah excels at HTML sanitization (XSS prevention). It includes some nice HTML sanitizers, which are based on HTML5lib's safelist, so it most likely won't make your codes less secure. (These statements have not been evaluated by Netexperts.)
26
20
 
27
- ActiveRecord extensions for sanitization are available in the
28
- [`loofah-activerecord` gem](https://github.com/flavorjones/loofah-activerecord).
21
+ ActiveRecord extensions for sanitization are available in the [`loofah-activerecord` gem](https://github.com/flavorjones/loofah-activerecord).
29
22
 
30
23
 
31
24
  ## Features
32
25
 
33
- * Easily write custom scrubbers for HTML/XML leveraging the sweetness of Nokogiri (and HTML5lib's whitelists).
26
+ * Easily write custom scrubbers for HTML/XML leveraging the sweetness of Nokogiri (and HTML5lib's safelists).
34
27
  * Common HTML sanitizing tasks are built-in:
35
28
  * _Strip_ unsafe tags, leaving behind only the inner text.
36
29
  * _Prune_ unsafe tags and their subtrees, removing all traces that they ever existed.
@@ -222,7 +215,7 @@ Loofah.xml_document(File.read('plague.xml')).scrub!(bring_out_your_dead)
222
215
  === Built-In HTML Scrubbers
223
216
 
224
217
  Loofah comes with a set of sanitizing scrubbers that use HTML5lib's
225
- whitelist algorithm:
218
+ safelist algorithm:
226
219
 
227
220
  ``` ruby
228
221
  doc.scrub!(:strip) # replaces unknown/unsafe tags with their inner text
@@ -301,23 +294,32 @@ The bug tracker is available here:
301
294
 
302
295
  * https://github.com/flavorjones/loofah/issues
303
296
 
304
- And the mailing list is on librelist:
297
+ And the mailing list is on Google Groups:
305
298
 
306
- * loofah@librelist.com / http://librelist.com
299
+ * Mail: loofah-talk@googlegroups.com
300
+ * Archive: https://groups.google.com/forum/#!forum/loofah-talk
307
301
 
308
302
  And the IRC channel is \#loofah on freenode.
309
303
 
310
304
 
311
305
  ## Security
312
306
 
313
- Some tools may incorrectly report loofah is a potential security
314
- vulnerability. Loofah depends on Nokogiri, and it's possible to use
315
- Nokogiri in a dangerous way (by enabling its DTDLOAD option and
316
- disabling its NONET option). This dangerous Nokogiri configuration,
317
- which is sometimes used by other components, can create an XML
318
- External Entity (XXE) vulnerability if the XML data is not trusted.
319
- However, loofah never enables this dangerous Nokogiri configuration;
320
- loofah never enables DTDLOAD, and it never disables NONET.
307
+ See [`SECURITY.md`](SECURITY.md) for vulnerability reporting details.
308
+
309
+
310
+ ### "Secure by Default"
311
+
312
+ Some tools may incorrectly report Loofah as a potential security
313
+ vulnerability.
314
+
315
+ Loofah depends on Nokogiri, and it's _possible_ to use Nokogiri in a
316
+ dangerous way (by enabling its DTDLOAD option and disabling its NONET
317
+ option). This specifically allows the opportunity for an XML External
318
+ Entity (XXE) vulnerability if the XML data is untrusted.
319
+
320
+ However, Loofah __never enables this Nokogiri configuration__; Loofah
321
+ never enables DTDLOAD, and it never disables NONET, thereby protecting
322
+ you by default from this XXE vulnerability.
321
323
 
322
324
 
323
325
  ## Related Links
@@ -345,7 +347,7 @@ And a big shout-out to Corey Innis for the name, and feedback on the API.
345
347
 
346
348
  ## Thank You
347
349
 
348
- The following people have generously donated via the Pledgie[http://pledgie.com] badge on the {Loofah github page}[https://github.com/flavorjones/loofah]:
350
+ The following people have generously donated via the [Pledgie](http://pledgie.com) badge on the [Loofah github page](https://github.com/flavorjones/loofah):
349
351
 
350
352
  * Bill Harding
351
353