Skip to content

Commit b9bec13

Browse files
committed
Merge pull request #20 from tpo/master
please include fix for CVE-2012-6684
2 parents 5b28e07 + 39700cb commit b9bec13

File tree

5 files changed

+36
-2
lines changed

5 files changed

+36
-2
lines changed

CHANGELOG

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
== Head
22

3+
* include CVE-2012-6684 fix [Tomas Pospisek]
4+
* fix by [Antonio Terceiro]
5+
* see http://sources.debian.net/src/ruby-redcloth/4.2.9-4/debian/patches/0001-Filter-out-javascript-links-when-using-filter_html-o.patch/
6+
* vulnerability reported by [Kousuke Ebihara]
7+
* see http://co3k.org/blog/redcloth-unfixed-xss-en
8+
9+
== 4.2.9.1 / February 24, 2015
10+
311
* Lazy-load latex_entities.yml [Charlie Somerville]
412

513
== 4.2.9 / November 25, 2011

README.rdoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
= Specifics of this RedCloth fork
2+
3+
This RedCloth fork fixes CVE-2012-6684 as
4+
{reported by Kousuke Ebihara}(http://co3k.org/blog/redcloth-unfixed-xss-en)
5+
using a {patch by Antonio Terceiro}(http://sources.debian.net/src/ruby-redcloth/4.2.9-4/debian/patches/0001-Filter-out-javascript-links-when-using-filter_html-o.patch/)
6+
7+
Read on below for the original RedCloth documentation
8+
19
= RedCloth - Textile parser for Ruby
210

311
Homepage:: http://redcloth.org

lib/redcloth/formatters/html.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@ def bq_close(opts)
111111
end
112112

113113
def link(opts)
114-
"<a href=\"#{escape_attribute opts[:href]}\"#{pba(opts)}>#{opts[:name]}</a>"
114+
if (filter_html || sanitize_html) && opts[:href] =~ /^\s*javascript:/
115+
opts[:name]
116+
else
117+
"<a href=\"#{escape_attribute opts[:href]}\"#{pba(opts)}>#{opts[:name]}</a>"
118+
end
115119
end
116120

117121
def image(opts)

lib/redcloth/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module VERSION
33
MAJOR = 4
44
MINOR = 2
55
TINY = 9
6-
RELEASE_CANDIDATE = nil
6+
RELEASE_CANDIDATE = 1
77

88
STRING = [MAJOR, MINOR, TINY, RELEASE_CANDIDATE].compact.join('.')
99
TAG = "REL_#{[MAJOR, MINOR, TINY, RELEASE_CANDIDATE].compact.join('_')}".upcase.gsub(/\.|-/, '_')

spec/security/CVE-2012-6684_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2012-6684
2+
3+
require 'redcloth'
4+
5+
describe 'CVE-2012-6684' do
6+
7+
it 'should not let javascript links pass through' do
8+
# PoC from http://co3k.org/blog/redcloth-unfixed-xss-en
9+
output = RedCloth.new('["clickme":javascript:alert(%27XSS%27)]', [:filter_html, :filter_styles, :filter_classes, :filter_ids]).to_html
10+
expect(output).to_not match(/href=.javascript:alert/)
11+
end
12+
13+
14+
end

0 commit comments

Comments
 (0)