Skip to content

Commit 71f349a

Browse files
committed
Merge branch '5-1-1'
* 5-1-1: bump version Updating the changelog Properly encode ID parameters to avoid possible information leak
2 parents 5038de5 + f58dc93 commit 71f349a

File tree

5 files changed

+23
-3
lines changed

5 files changed

+23
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
* Fix railtie logic that adds Active Job serialization support.
22

3+
## Active Resource 5.1.1 (May 5, 2020) ##
4+
5+
* Properly encode ID parameters to avoid possible information leak [CVE-2020-8151]
6+
37
## Active Resource 5.1.0 (Nov 2, 2018) ##
48

59
* Improve support of Active Resource objects inside fibers.

lib/active_resource/base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ def element_path(id, prefix_options = {}, query_options = nil)
774774
check_prefix_options(prefix_options)
775775

776776
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
777-
"#{prefix(prefix_options)}#{collection_name}/#{URI.parser.escape id.to_s}#{format_extension}#{query_string(query_options)}"
777+
"#{prefix(prefix_options)}#{collection_name}/#{URI.encode_www_form_component(id.to_s)}#{format_extension}#{query_string(query_options)}"
778778
end
779779

780780
# Gets the element url for the given ID in +id+. If the +query_options+ parameter is omitted, Rails

lib/active_resource/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module ActiveResource
44
module VERSION #:nodoc:
55
MAJOR = 5
66
MINOR = 1
7-
TINY = 0
7+
TINY = 1
88
PRE = nil
99

1010
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")

test/cases/base_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ def test_custom_element_path
688688
assert_equal "/people/1/addresses/1.json", StreetAddress.element_path(1, person_id: 1)
689689
assert_equal "/people/1/addresses/1.json", StreetAddress.element_path(1, "person_id" => 1)
690690
assert_equal "/people/Greg/addresses/1.json", StreetAddress.element_path(1, "person_id" => "Greg")
691-
assert_equal "/people/ann%20mary/addresses/ann%20mary.json", StreetAddress.element_path(:'ann mary', "person_id" => "ann mary")
691+
assert_equal "/people/ann%20mary/addresses/ann+mary.json", StreetAddress.element_path(:'ann mary', "person_id" => "ann mary")
692692
end
693693

694694
def test_custom_element_path_without_required_prefix_param

test/cases/finder_test.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,20 @@ def test_find_single_by_symbol_from
172172
david = Person.find(:one, from: :leader)
173173
assert_equal "David", david.name
174174
end
175+
176+
def test_find_identifier_encoding
177+
ActiveResource::HttpMock.respond_to { |m| m.get "/people/%3F.json", {}, @david }
178+
179+
david = Person.find("?")
180+
181+
assert_equal "David", david.name
182+
end
183+
184+
def test_find_identifier_encoding_for_path_traversal
185+
ActiveResource::HttpMock.respond_to { |m| m.get "/people/..%2F.json", {}, @david }
186+
187+
david = Person.find("../")
188+
189+
assert_equal "David", david.name
190+
end
175191
end

0 commit comments

Comments
 (0)