Skip to content

Commit

Permalink
Fix possible deserialization of untrusted data
Browse files Browse the repository at this point in the history
There is a deserialization of untrusted data vulnerability in the Kredis
JSON deserialization code. This vulnerability has been assigned the CVE
identifier CVE-2023-27531.

Carefully crafted JSON data processed by Kredis may result in
deserialization of untrusted data, potentially leading to deserialization
of unexpected objects in the system.

Any applications using Kredis with JSON are affected.
  • Loading branch information
eileencodes committed Mar 13, 2023
1 parent 1c2e3a6 commit d576b7a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/kredis/type/json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def type
end

def cast_value(value)
JSON.load(value)
JSON.parse(value)
end

def serialize(value)
Expand Down
3 changes: 3 additions & 0 deletions test/types/scalar_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ class ScalarTest < ActiveSupport::TestCase
json = Kredis.json "myscalar"
json.value = { "one" => 1, "string" => "hello" }
assert_equal({ "one" => 1, "string" => "hello" }, json.value)

json.value = {"json_class"=>"String", "raw"=>[97, 98, 99]}
assert_equal({"json_class"=>"String", "raw"=>[97, 98, 99]}, json.value)
end

test "invalid type" do
Expand Down

0 comments on commit d576b7a

Please sign in to comment.