Python developers warned to watch for rogue ‘torchtriton’ package

2023-01-05 08:27:57
关注

Python developers are being warned to check they haven’t installed a malicious package and if they have to take action immediately to remove it. Known as “torchtriton”, it is delivered through the Python Package Index (PyPi) and shares a name with a genuine package operated by the PyTorch Foundation.

PyPi vulnerability: Developers warned about rogue package
When installing via PIP packages logged with the Python Package Index take precedence over other indices. (Photo by Trismegist san/Shutterstock)

It is likely a small group of users unintentionally installed the malicious code due to a quirk in the way Python packages are handled and distributed, with those accustomed to installing the latest preview builds of libraries most at risk.

The malicious version of the package was able to send system data from a computer to a recent domain, including nameservers, hostname, current username, current working directly and environment variables. It was also able to read hosts, passwords, the first 1,000 files in home and configuration details.

It was then able to upload all of the information, including the contents of files, through an encrypted DNS query to a specific host server. In a statement to Bleeping Computer, the person behind the malicious package claimed it was “not intended to be malicious” and instead used for research. The developer claims to have reported the bug to Meta, which created the PyTorch framework, on December 29, as well as to other companies affected by the vulnerability. They say they offered to hand over control of the package but have not had any replies.

Companies Intelligence

View All

Reports

View All

Data Insights

View All

“I understand that I could have done a better job to not send all of the user’s data,” the hacker wrote in an email, explaining that previously when investigating these types of issues it wasn’t possible to identify the victims by their hostname, username and CWD so had it sent more data this time. “Looking back this was wrong decision and I should have been more careful.”

The hacker says they are behind the h4ck.cfd website where the data is being uploaded. A message on the site reads: “If you stumbled on this in your logs, then this is likely because your Python was misconfigured and was vulnerable to a dependency confusion attack.”

The “research” note goes on to say that the hacker will delete all of the metadata about the compromised servers once companies and individuals have been identified and they have been able to report the findings. It isn’t clear if this actually happened.

PyPi vulnerability: dummy package logged

Open-source machine learning framework PyTorch, developed by Meta and now part of the Linux Foundation, produces a dependency called “torchtriton”, a language and compiler for custom deep learning operations, that it hosts on its own PyTorch nightly package Index.

Content from our partners

How to develop a constant set of readiness for the next cyberattack

How to develop a constant set of readiness for the next cyberattack

How adopting B2B2C models is enabling manufacturers to get ever closer to their consumers

How adopting B2B2C models is enabling manufacturers to get ever closer to their consumers

Technology and innovation can drive post-pandemic recovery for logistics sector

Technology and innovation can drive post-pandemic recovery for logistics sector

Installing it via that particular library is safe, but over the Christmas break a package with the same name, containing malicious code, was uploaded to the Python Package Index (PyPi) and that is where the issues come from as many developers install libraries using the “pip” command, which defaults to PyPi hosted files.

View all newsletters Sign up to our newsletters Data, insights and analysis delivered to you By The Tech Monitor team

The issue was quickly spotted by the PyTorch Foundation which has since renamed its own dependency to “pytorch-torchtriton”, registered it as a dummy package on PyPi to prevent similar attacks and asked PyPi to hand ownership of “torchtriton” to it and delete the malicious version.

Developers should run a pip3 uninstall comment on “torch torchvision torchaudio torchtriton” then purge the cache, switch to PyTorch stable and then reinstall torchtriton. PyTorch says it has also removed all nightly packages that depend on torchtriton, not just torchtriton itself, until they can be verified.

Tzachi Zorn, Head of SCS at Checkmarx wrote in a Medium blog that PyTorch had effectively been “poisoned with a malicious dependency” that lasted about five days. It specifically targeted developers using Linux systems and contained an executable written in C++.

This form of “dependency confusion technique” was first revealed in 2021 and has been used multiple times in different package registries including PyPi and NPM, explained Zorn.

“Despite any messages or disclaimers that may have been included, it is clear that the package in question is malicious,” he said. “This is not acceptable behaviour for a security researcher and simply claiming to be a security researcher does not give someone permission to engage in malicious activity.”

Read more: AI coding assistants leave developers “deluded” about the quality of their software

Topics in this article : Python

参考译文
Python开发人员警告要注意流氓“torchtriton”软件包
Python 开发人员被提醒要检查自己是否安装了一个恶意软件包,如果安装了,请立即采取措施将其删除。这个名为“torchtriton”的软件包通过 Python 软件包索引(PyPi)分发,其名称与由 PyTorch 基金会运营的合法软件包相同。通过 pip 安装时,从 Python 包索引中记录的包会优先于其他索引。(图片由 Trismegist san / Shutterstock 提供)由于 Python 包处理和分发方式的特殊性,很可能是一小部分用户无意中安装了该恶意代码,尤其是那些习惯于安装库的最新预览版本的用户最容易受到影响。该恶意包能够将计算机上的系统数据发送到一个最近的域名,包括名称服务器、主机名、当前用户名、当前工作目录和环境变量。此外,它还能读取 hosts 文件、密码、家庭目录下前 1000 个文件以及配置详情。然后,它可以通过加密的 DNS 查询将所有这些信息,包括文件内容,上传到特定的主机服务器。在接受 BleepingComputer 的声明中,该恶意包的发布者声称该软件包“本意并非恶意”,而是用于研究。开发者称,他们已于 12 月 29 日向创建 PyTorch 框架的 Meta 公司报告了这一漏洞,并向受该漏洞影响的其他公司也进行了报告。他们表示,他们提出将该软件包的控制权移交给 PyTorch 基金会,但尚未收到任何回复。公司情报 查看所有报告 查看所有数据洞察 “我理解自己本可以做得更好,以避免发送用户的所有数据,”这名黑客在一封电子邮件中解释道,他提到以前在调查这类问题时,无法通过主机名、用户名和当前工作目录(CWD)识别受害者,因此这次他发送了更多数据。“回顾起来,这确实是一个错误的决定,我应该更加谨慎。”这名黑客表示,他是 h4ck.cfd 网站的幕后运营者,该网站正是用于上传数据。该网站上的一条信息写道:“如果你在日志中发现了这个网站,那么很可能是由于你的 Python 配置有误,容易受到依赖混淆攻击。”这份“研究”说明中还提到,一旦确认了受感染的公司和个人,黑客将删除所有有关被入侵服务器的元数据,并报告发现的情况。目前尚不清楚该计划是否真的执行。PyPi 漏洞:虚假包已记录 Meta 公司开发并现已并入 Linux 基金会的开源机器学习框架 PyTorch,生成了一个名为“torchtriton”的依赖项,这是一个用于自定义深度学习操作的语言和编译器,托管在其自己的 PyTorch 夜间软件包索引中。来自我们的合作伙伴的内容 如何为下一次网络攻击建立恒定的准备能力 采用 B2B2C 模式使制造商能够更接近消费者 科技与创新可推动物流行业在疫情后的复苏 通过该特定库安装是安全的,但今年圣诞节期间,一个同名但包含恶意代码的包被上传到了 Python 包索引(PyPi)。许多开发人员使用“pip”命令安装库,而该命令默认使用 PyPi 托管的文件,因此问题就出在这里。查看所有简报 注册我们的简报 数据、洞察与分析直接送达您邮箱 由 Tech Monitor 团队提供 注册此处 PyTorch 基金会迅速发现了该问题,之后将其自身的依赖项名称改为“pytorch-torchtriton”,并在 PyPi 上注册为一个假包以防止类似攻击发生,并要求 PyPi 将“torchtriton”的所有权转交给 PyTorch 基金会,并删除恶意版本。开发人员应运行 pip3 uninstall 命令对“torch torchvision torchaudio torchtriton”执行卸载,然后清除缓存、切换到 PyTorch 稳定版本,再重新安装 torchtriton。PyTorch 表示,它还删除了所有依赖 torchtriton 的夜间版本软件包,不仅限于 torchtriton 本身,直至这些包经过验证。Checkmarx 公司的 SCS 负责人 Tzachi Zorn 在一篇 Medium 博客中写道,PyTorch 实际上已被一个恶意依赖项“污染”,这持续了大约五天。它专门针对使用 Linux 系统的开发者,包含了一个用 C++ 编写的可执行文件。Zorn 解释说,这种形式的“依赖混淆技术”最早于 2021 年被揭示,并已在不同的软件包注册站(如 PyPi 和 NPM)中多次使用。“尽管可能包含了一些说明或免责声明,但很明显,这个包是恶意的,”他说道,“对于安全研究人员来说,这样的行为是不可接受的,仅仅声称是安全研究人员并不能为从事恶意活动提供正当理由。”阅读更多:AI 代码助手让开发者“对软件质量产生误解” 本文主题:Python
您觉得本篇内容如何
评分

评论

您需要登录才可以回复|注册

提交评论

提取码
复制提取码
点击跳转至百度网盘