-
- Notifications
You must be signed in to change notification settings - Fork 396
Specs for three initial vulnerabilities #393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| require File.expand_path('../../spec_helper', __FILE__) | ||
| | ||
| describe :resists_cve_2011_4815, shared: true do | ||
| it "resists CVE-2011-4815 by having different hash codes in different processes" do | ||
| eval("(#{@method}).hash.to_s").should_not == ruby_exe("print (#{@method}).hash") | ||
| end | ||
| end | ||
| | ||
| describe "Object#hash" do | ||
| it_behaves_like :resists_cve_2011_4815, 'Object.new' | ||
| end | ||
| | ||
| describe "Integer#hash with a small value" do | ||
| it_behaves_like :resists_cve_2011_4815, '14' | ||
| end | ||
| | ||
| describe "Integer#hash with a large value" do | ||
| it_behaves_like :resists_cve_2011_4815, '100000000000000000000000000000' | ||
| end | ||
| | ||
| describe "Float#hash" do | ||
| it_behaves_like :resists_cve_2011_4815, '3.14' | ||
| end | ||
| | ||
| describe "String#hash" do | ||
| it_behaves_like :resists_cve_2011_4815, '"abc"' | ||
| end | ||
| | ||
| describe "Symbol#hash" do | ||
| ruby_bug "#13376", "2.3"..."2.4" do | ||
| it_behaves_like :resists_cve_2011_4815, ':a' | ||
| end | ||
| end | ||
| | ||
| describe "Array#hash" do | ||
| it_behaves_like :resists_cve_2011_4815, '[1, 2, 3]' | ||
| end | ||
| | ||
| describe "Hash#hash" do | ||
| it_behaves_like :resists_cve_2011_4815, '{a: 1, b: 2, c: 3}' | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| require File.expand_path('../../spec_helper', __FILE__) | ||
| | ||
| require 'json' | ||
| | ||
| describe "String#to_f" do | ||
| | ||
| it "resists CVE-2013-4164 by converting very long Strings to a Float" do | ||
| "1.#{'1'*1000000}".to_f.should be_close(1.1111111111111112, TOLERANCE) | ||
| end | ||
| | ||
| end | ||
| | ||
| describe "JSON.parse" do | ||
| | ||
| it "resists CVE-2013-4164 by converting very long Strings to a Float" do | ||
| JSON.parse("[1.#{'1'*1000000}]").first.should be_close(1.1111111111111112, TOLERANCE) | ||
| end | ||
| | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| require File.expand_path('../../spec_helper', __FILE__) | ||
| | ||
| require 'rexml/document' | ||
| | ||
| describe "REXML::Document.new" do | ||
| | ||
| it "resists CVE-2014-8080 by raising an exception when entity expansion has grown too large" do | ||
| xml = <<XML | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <!DOCTYPE x [ | ||
| <!ENTITY % x0 "xxxxxxxxxx"> | ||
| <!ENTITY % x1 "%x0;%x0;%x0;%x0;%x0;%x0;%x0;%x0;%x0;%x0;"> | ||
| <!ENTITY % x2 "%x1;%x1;%x1;%x1;%x1;%x1;%x1;%x1;%x1;%x1;"> | ||
| <!ENTITY % x3 "%x2;%x2;%x2;%x2;%x2;%x2;%x2;%x2;%x2;%x2;"> | ||
| <!ENTITY % x4 "%x3;%x3;%x3;%x3;%x3;%x3;%x3;%x3;%x3;%x3;"> | ||
| <!ENTITY % x5 "%x4;%x4;%x4;%x4;%x4;%x4;%x4;%x4;%x4;%x4;"> | ||
| <!ENTITY % x6 "%x5;%x5;%x5;%x5;%x5;%x5;%x5;%x5;%x5;%x5;"> | ||
| <!ENTITY % x7 "%x6;%x6;%x6;%x6;%x6;%x6;%x6;%x6;%x6;%x6;"> | ||
| <!ENTITY % x8 "%x7;%x7;%x7;%x7;%x7;%x7;%x7;%x7;%x7;%x7;"> | ||
| <!ENTITY % x9 "%x8;%x8;%x8;%x8;%x8;%x8;%x8;%x8;%x8;%x8;"> | ||
| ]> | ||
| <x> | ||
| %x9;%x9;%x9;%x9;%x9;%x9;%x9;%x9;%x9;%x9; | ||
| </x> | ||
| XML | ||
| | ||
| lambda { REXML::Document.new(xml).doctype.entities['x9'].value }.should raise_error(REXML::ParseException) { |e| | ||
| e.message.should =~ /entity expansion has grown too large/ | ||
| } | ||
| end | ||
| | ||
| end |
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can now use:
(thanks to ruby/mspec@6856ff8)