This is an Ubuntu 20.04 machine hosting an application used to upload CIF files. This is a format used by scientific programs for storing crystallographic structural data. The applications used to read the data contained in the files are based on Python but, unfortunately, one of the parsing libraries is vulnerable since it calls eval() function without proper sanitization (CVE-2024-23346). We exploit this to get an initial shell in the system, then move laterally to another user after finding an MD5 hash in a local SQLite database file. Regarding escalation, we exploit a web application based on library aiohttp/3.9.1, a version vulnerable to path traversal (CVE-2024-23334).
KEYWORDS
Crystallographic Information Files (CIF), pymatgen, CVE-2024-23346, SQLite, aiohttp/3.9.1, CVE-2024-23334.
> nmap $target -p22,5000 -sV -sC -Pn -vv -nStartingNmap7.93 ( https://nmap.org ) at 2024-11-27 11:18 ESTNmapscanreportfor10.10.11.38Hostisup,receiveduser-set (0.044s latency).Scannedat2024-11-2711:18:39ESTfor96sPORTSTATESERVICEREASONVERSION22/tcpopensshsyn-ackOpenSSH8.2p1Ubuntu4ubuntu0.11 (Ubuntu Linux; protocol2.0)|ssh-hostkey:|3072b6fc20ae9d1d451d0bced9d020f26fdc (RSA)| ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj5eCYeJYXEGT5pQjRRX4cRr4gHoLUb/riyLfCAQMf40a6IO3BMzwyr3OnfkqZDlr6o9tS69YKDE9ZkWk01vsDM/T1k/m1ooeOaTRhx2Yene9paJnck8Stw4yVWtcq6PPYJA3HxkKeKyAnIVuYBvaPNsm+K5+rsafUEc5FtyEGlEG0YRmyk/NepEFU6qz25S3oqLLgh9Ngz4oGeLudpXOhD4gN6aHnXXUHOXJgXdtY9EgNBfd8paWTnjtloAYi4+ccdMfxO7PcDOxt5SQan1siIkFq/uONyV+nldyS3lLOVUCHD7bXuPemHVWqD2/1pJWf+PRAasCXgcUV+Je4fyNnJwec1yRCbY3qtlBbNjHDJ4p5XmnIkoUm7hWXAquebykLUwj7vaJ/V6L19J4NN8HcBsgcrRlPvRjXz0A2VagJYZV+FVhgdURiIM4ZA7DMzv9RgJCU2tNC4EyvCTAe0rAM2wj0vwYPPEiHL+xXHGSvsoZrjYt1tGHDQvy8fto5RQU=
|256f1ae1c3e1dea55446c2ff2568d623c2b (ECDSA)|ecdsa-sha2-nistp256AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBLzrl552bgToHASFlKHFsDGrkffR/uYDMLjHOoueMB9HeLRFRvZV5ghoTM3Td9LImvcLsqD84b5n90qy3peebL0=|25694421b78f25187073e9726c9a25c0a26 (ED25519)|_ssh-ed25519AAAAC3NzaC1lZDI1NTE5AAAAIELLgwg7A8Kh8AxmiUXeMe9h/wUnfdoruCJbWci81SSB5000/tcpopenupnp?syn-ack|fingerprint-strings:|GetRequest:|HTTP/1.1200OK|Server:Werkzeug/3.0.3Python/3.9.5|Date:Wed,27Nov202416:19:13GMT|Content-Type:text/html; charset=utf-8|Content-Length:719|Vary:Cookie|Connection:close|<!DOCTYPEhtml>|<htmllang="en">|<head>|<metacharset="UTF-8">|<metaname="viewport"content="width=device-width, initial-scale=1.0">|<title>Chemistry-Home</title>|<linkrel="stylesheet"href="/static/styles.css">|</head>|<body>|<divclass="container">| class="title">ChemistryCIFAnalyzer</h1>|<p>WelcometotheChemistryCIFAnalyzer.ThistoolallowsyoutouploadaCIF (Crystallographic InformationFile) and analyze the structural data contained within.</p>|<divclass="buttons">|<center><a href="/login"class="btn">Login</a>| href="/register" class="btn">Register</a></center>|</div>|</div>|</body>|RTSPRequest:|<!DOCTYPEHTMLPUBLIC"-//W3C//DTD HTML 4.01//EN"|"http://www.w3.org/TR/html4/strict.dtd">|<html>|<head>|<metahttp-equiv="Content-Type"content="text/html;charset=utf-8">|<title>Errorresponse</title>|</head>|<body>|<h1>Errorresponse</h1>|<p>Errorcode:400</p>|<p>Message:Badrequestversion ('RTSP/1.0').</p>|<p>Errorcodeexplanation:HTTPStatus.BAD_REQUEST-Badrequestsyntaxorunsupportedmethod.</p>|</body>|_</html>1serviceunrecognizeddespitereturningdata.Ifyouknowtheservice/version,pleasesubmitthefollowingfingerprintathttps://nmap.org/cgi-bin/submit.cgi?new-service:SF-Port5000-TCP:V=7.93%I=7%D=11/27%Time=67474665%P=x86_64-pc-linux-gnu%r(GSF:etRequest,38A,"HTTP/1\.1\x20200\x20OK\r\nServer:\x20Werkzeug/3\.0\.3\x2SF:0Python/3\.9\.5\r\nDate:\x20Wed,\x2027\x20Nov\x202024\x2016:19:13\x20GMSF:T\r\nContent-Type:\x20text/html;\x20charset=utf-8\r\nContent-Length:\x2SF:0719\r\nVary:\x20Cookie\r\nConnection:\x20close\r\n\r\n<!DOCTYPE\x20htmSF:l>\n<html\x20lang=\"en\">\n<head>\n\x20\x20\x20\x20<meta\x20charset=\"USF:TF-8\">\n\x20\x20\x20\x20<meta\x20name=\"viewport\"\x20content=\"width=SF:device-width,\x20initial-scale=1\.0\">\n\x20\x20\x20\x20<title>ChemistrSF:y\x20-\x20Home</title>\n\x20\x20\x20\x20<link\x20rel=\"stylesheet\"\x20SF:href=\"/static/styles\.css\">\n</head>\n<body>\n\x20\x20\x20\x20\n\x20\SF:x20\x20\x20\x20\x20\n\x20\x20\x20\x20\n\x20\x20\x20\x20<div\x20class=\"SF:container\">\n\x20\x20\x20\x20\x20\x20\x20\x20<h1\x20class=\"title\">ChSF:emistry\x20CIF\x20Analyzer</h1>\n\x20\x20\x20\x20\x20\x20\x20\x20<p>WelSF:come\x20to\x20the\x20Chemistry\x20CIF\x20Analyzer\.\x20This\x20tool\x20SF:allows\x20you\x20to\x20upload\x20a\x20CIF\x20\(Crystallographic\x20InfoSF:rmation\x20File\)\x20and\x20analyze\x20the\x20structural\x20data\x20conSF:tained\x20within\.</p>\n\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\SF:"buttons\">\n\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<center><aSF:\x20href=\"/login\"\x20class=\"btn\">Login</a>\n\x20\x20\x20\x20\x20\x2SF:0\x20\x20\x20\x20\x20\x20<a\x20href=\"/register\"\x20class=\"btn\">RegiSF:ster</a></center>\n\x20\x20\x20\x20\x20\x20\x20\x20</div>\n\x20\x20\x20SF:\x20</div>\n</body>\n<")%r(RTSPRequest,1F4,"<!DOCTYPE\x20HTML\x20PUBLICSF:\x20\"-//W3C//DTD\x20HTML\x204\.01//EN\"\n\x20\x20\x20\x20\x20\x20\x20\SF:x20\"http://www\.w3\.org/TR/html4/strict\.dtd\">\n<html>\n\x20\x20\x20\SF:x20<head>\n\x20\x20\x20\x20\x20\x20\x20\x20<meta\x20http-equiv=\"ContenSF:t-Type\"\x20content=\"text/html;charset=utf-8\">\n\x20\x20\x20\x20\x20\SF:x20\x20\x20<title>Error\x20response</title>\n\x20\x20\x20\x20</head>\n\SF:x20\x20\x20\x20<body>\n\x20\x20\x20\x20\x20\x20\x20\x20<h1>Error\x20resSF:ponse</h1>\n\x20\x20\x20\x20\x20\x20\x20\x20<p>Error\x20code:\x20400</pSF:>\n\x20\x20\x20\x20\x20\x20\x20\x20<p>Message:\x20Bad\x20request\x20verSF:sion\x20\('RTSP/1\.0'\)\.</p>\n\x20\x20\x20\x20\x20\x20\x20\x20<p>ErrorSF:\x20code\x20explanation:\x20HTTPStatus\.BAD_REQUEST\x20-\x20Bad\x20requSF:est\x20syntax\x20or\x20unsupported\x20method\.</p>\n\x20\x20\x20\x20</bSF:ody>\n</html>\n");ServiceInfo:OS:Linux; CPE:cpe:/o:linux:linux_kernelNmapdone:1IPaddress (1 hostup) scanned in 96.77 seconds
There is a web server listening on port 5000, enumerate the site with Firefox.
Sign up a new account and login. A web site to upload CIF files comes into view, the page offers the possibility to download an example of these kind of files.
There is a vulnerability in one of the in the parsing libraries,pymatgen, that insecurely calls eval() function without proper input sanitization. More info here: https://www.cvedetails.com/cve/CVE-2024-23346
This looks like source code for several API endpoints, and an SQLite database is mentioned also. The database file is in the location /home/app/instance/database.db
Inside the database there are several MD5 hashes, including rosa's.
Forward the port to your machine and enumerate the site with Firefox. I used local port 9000 to avoid conflicts with Burpsuite, which I'll use later and is running also on port 8080.
Some kind of monitoring web site appears.
I couldn't find any info related to the site by inspecting it so I captured the traffic with Burpsuite and analyzed the requests
First, it seems the application uses Python 3.9 aiohttp/3.9.1.
And also take note of the application folder structure.