-
Notifications
You must be signed in to change notification settings - Fork 451
Prevent denial of service in filehash and filehash58 probes #2407
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
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 |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| if(OPENSCAP_PROBE_INDEPENDENT_FILEHASH) | ||
| add_oscap_test("test_probes_filehash.sh" LABELS independent) | ||
| add_oscap_test("test_probes_filehash_dos.sh" LABELS independent) | ||
| endif() |
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,40 @@ | ||
| <ns0:oval_definitions xmlns:ns0="http://oval.mitre.org/XMLSchema/oval-definitions-5" xmlns:ns2="http://oval.mitre.org/XMLSchema/oval-common-5" xmlns:ns3="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent" xmlns:ns4="http://oval.mitre.org/XMLSchema/oval-definitions-5#unix" xmlns:ns5="http://oval.mitre.org/XMLSchema/oval-definitions-5#linux" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://oval.mitre.org/XMLSchema/oval-common-5 oval-common-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5 oval-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5#independent independent-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5#unix unix-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5#linux linux-definitions-schema.xsd"> | ||
| <ns0:generator> | ||
| <ns2:product_name>combine_ovals.py from SCAP Security Guide</ns2:product_name> | ||
| <ns2:product_version>ssg: [0, 1, 40], python: 3.6.5</ns2:product_version> | ||
| <ns2:schema_version>5.11</ns2:schema_version> | ||
| <ns2:timestamp>2018-07-20T09:33:24</ns2:timestamp> | ||
| </ns0:generator> | ||
| <ns0:definitions> | ||
| <ns0:definition class="compliance" id="oval:ssg-oval_test_has_hash:def:1" version="1"> | ||
| <ns0:metadata> | ||
| <ns0:title>Test that reading a FIFO (named pipe) by the filehash probe doesn't freeze OpenSCAP.</ns0:title> | ||
| <ns0:affected family="unix"> | ||
| <ns0:platform>Red Hat Enterprise Linux 7</ns0:platform> | ||
| </ns0:affected> | ||
| <ns0:description>description</ns0:description> | ||
| <reference ref_id="oval_test_has_hash" source="ssg" /> | ||
| </ns0:metadata> | ||
| <ns0:criteria> | ||
| <ns0:criterion comment="Check file hash of /oval-test" test_ref="oval:xxx:tst:1" /> | ||
| <ns0:criterion comment="Check file hash of /oval-test" test_ref="oval:xxx:tst:2" /> | ||
| </ns0:criteria> | ||
| </ns0:definition> | ||
| </ns0:definitions> | ||
| <ns0:tests> | ||
| <ns3:filehash_test check="all" comment="-" id="oval:xxx:tst:1" version="1"> | ||
| <ns3:object object_ref="oval:xxx:obj:1" /> | ||
| </ns3:filehash_test> | ||
| <ns3:filehash_test check="all" comment="-" id="oval:xxx:tst:2" version="1"> | ||
| <ns3:object object_ref="oval:xxx:obj:2" /> | ||
| </ns3:filehash_test> | ||
| </ns0:tests> | ||
| <ns0:objects> | ||
| <ns3:filehash_object id="oval:xxx:obj:1" version="1"> | ||
| <ns3:filepath>/tmp/oscap-test-fifo</ns3:filepath> | ||
| </ns3:filehash_object> | ||
| <ns3:filehash_object id="oval:xxx:obj:2" version="1"> | ||
| <ns3:filepath>/tmp/oscap-test-symlink</ns3:filepath> | ||
| </ns3:filehash_object> | ||
| </ns0:objects> | ||
| </ns0:oval_definitions> |
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,34 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Copyright 2021 Red Hat Inc., Durham, North Carolina. | ||
| # All Rights Reserved. | ||
| # | ||
| # OpenSCAP Probes Test Suite. | ||
| # | ||
| # Authors: | ||
| # Jan Černý, <jcerny@redhat.com> | ||
|
|
||
| set -e -o pipefail | ||
| . $builddir/tests/test_common.sh | ||
|
|
||
| probecheck "filehash" || return 255 | ||
| require "md5sum" || return 255 | ||
| require "sha1sum" || return 255 | ||
|
|
||
| # Block the scan indefinitely | ||
| rm -f /tmp/oscap-test-fifo | ||
| mkfifo /tmp/oscap-test-fifo | ||
|
|
||
| # Burn CPU forever | ||
| rm -f /tmp/oscap-test-symlink | ||
| ln -s /dev/zero /tmp/oscap-test-symlink | ||
|
|
||
| result="$(mktemp)" | ||
|
|
||
| $OSCAP oval eval --results "$result" "$srcdir/dos.oval.xml" | ||
| assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:xxx:tst:1"][@result="error"]' | ||
| assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:xxx:tst:2"][@result="error"]' | ||
|
|
||
| rm -f /tmp/oscap-test-fifo | ||
| rm -f /tmp/oscap-test-symlink | ||
| rm -f "$result" |
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 |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| if(ENABLE_PROBES_INDEPENDENT) | ||
| add_oscap_test("test_probes_filehash58.sh" LABELS independent) | ||
| add_oscap_test("test_probes_filehash58_dos.sh" LABELS independent) | ||
| add_oscap_test("rhbz1959570_segfault.sh" LABELS independent) | ||
| endif() |
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,42 @@ | ||
| <ns0:oval_definitions xmlns:ns0="http://oval.mitre.org/XMLSchema/oval-definitions-5" xmlns:ns2="http://oval.mitre.org/XMLSchema/oval-common-5" xmlns:ns3="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent" xmlns:ns4="http://oval.mitre.org/XMLSchema/oval-definitions-5#unix" xmlns:ns5="http://oval.mitre.org/XMLSchema/oval-definitions-5#linux" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://oval.mitre.org/XMLSchema/oval-common-5 oval-common-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5 oval-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5#independent independent-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5#unix unix-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5#linux linux-definitions-schema.xsd"> | ||
| <ns0:generator> | ||
| <ns2:product_name>combine_ovals.py from SCAP Security Guide</ns2:product_name> | ||
| <ns2:product_version>ssg: [0, 1, 40], python: 3.6.5</ns2:product_version> | ||
| <ns2:schema_version>5.11</ns2:schema_version> | ||
| <ns2:timestamp>2018-07-20T09:33:24</ns2:timestamp> | ||
| </ns0:generator> | ||
| <ns0:definitions> | ||
| <ns0:definition class="compliance" id="oval:ssg-oval_test_has_hash:def:1" version="1"> | ||
| <ns0:metadata> | ||
| <ns0:title>Test that reading a FIFO (named pipe) by the filehash58 probe doesn't freeze OpenSCAP.</ns0:title> | ||
| <ns0:affected family="unix"> | ||
| <ns0:platform>Red Hat Enterprise Linux 7</ns0:platform> | ||
| </ns0:affected> | ||
| <ns0:description>description</ns0:description> | ||
| <reference ref_id="oval_test_has_hash" source="ssg" /> | ||
| </ns0:metadata> | ||
| <ns0:criteria> | ||
| <ns0:criterion comment="Check file hash of /oval-test" test_ref="oval:xxx:tst:1" /> | ||
| <ns0:criterion comment="Check file hash of /oval-test" test_ref="oval:xxx:tst:2" /> | ||
| </ns0:criteria> | ||
| </ns0:definition> | ||
| </ns0:definitions> | ||
| <ns0:tests> | ||
| <ns3:filehash58_test check="all" comment="-" id="oval:xxx:tst:1" version="1"> | ||
| <ns3:object object_ref="oval:xxx:obj:1" /> | ||
| </ns3:filehash58_test> | ||
| <ns3:filehash58_test check="all" comment="-" id="oval:xxx:tst:2" version="1"> | ||
| <ns3:object object_ref="oval:xxx:obj:2" /> | ||
| </ns3:filehash58_test> | ||
| </ns0:tests> | ||
| <ns0:objects> | ||
| <ns3:filehash58_object id="oval:xxx:obj:1" version="1"> | ||
| <ns3:filepath>/tmp/oscap-test-fifo</ns3:filepath> | ||
| <ns3:hash_type>SHA-256</ns3:hash_type> | ||
| </ns3:filehash58_object> | ||
| <ns3:filehash58_object id="oval:xxx:obj:2" version="1"> | ||
| <ns3:filepath>/tmp/oscap-test-symlink</ns3:filepath> | ||
| <ns3:hash_type>SHA-256</ns3:hash_type> | ||
| </ns3:filehash58_object> | ||
| </ns0:objects> | ||
| </ns0:oval_definitions> |
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,35 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Copyright 2021 Red Hat Inc., Durham, North Carolina. | ||
| # All Rights Reserved. | ||
| # | ||
| # OpenSCAP Probes Test Suite. | ||
| # | ||
| # Authors: | ||
| # Jan Černý, <jcerny@redhat.com> | ||
|
|
||
| set -e -o pipefail | ||
| . $builddir/tests/test_common.sh | ||
|
|
||
| probecheck "filehash58" || return 255 | ||
| require "sha256sum" || return 255 | ||
| require "sha512sum" || return 255 | ||
|
|
||
| # Block the scan indefinitely | ||
| rm -f /tmp/oscap-test-fifo | ||
| mkfifo /tmp/oscap-test-fifo | ||
|
|
||
| # Burn CPU forever | ||
| rm -f /tmp/oscap-test-symlink | ||
| ln -s /dev/zero /tmp/oscap-test-symlink | ||
|
|
||
| result="$(mktemp)" | ||
|
|
||
| $OSCAP oval eval --results "$result" "$srcdir/dos.oval.xml" | ||
| assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:xxx:tst:1"][@result="error"]' | ||
| assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:xxx:tst:2"][@result="error"]' | ||
|
|
||
| rm -f /tmp/oscap-test-fifo | ||
| rm -f /tmp/oscap-test-symlink | ||
| rm -f "$result" | ||
|
|
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.