# What's in your dependencies? Supply chain attacks on Python projects

Source: https://djangotv.com/videos/djangocon-europe/2026/djangocon-europe-2026-whats-in-your-dependencies-supply-chain-attacks-on-python-projects/
Date: 2026-10-26
Speakers: Speaker 1, Mateusz Bełczowski, Speaker 3, Speaker 4

## Transcript

**Speaker 1:** [00:07] So we're going towards the end of the conference, but not the end of the fun, because we have the talk from Mateus Belkowski. Who's for many years a python developer. He's also training people on python and in other interesting things and he's going to talk about our dependencies. So what's in your dependencies? Let's see. Thanks a lot, Ponteus, and welcome

**Mateusz Bełczowski:** [00:35] Okay, so welcome everyone. Today we are going to talk about supply chain attacks. This topic is not specific to Django or Python ecosystem, but definitely relevant to all of us, no matter if we are just Python Django users or package maintainers. Quick intro, I am Mateusz Bełczowski from Poland. I am a developer who's really passionate about cybersecurity I work at a company named Tofil Software. It's a software house in Poland and I am currently involved in building vulnerability management platform for the Swedish client. This is my second Django con Europe, but first time as a speaker. Okay, so we'll today we'll cover how supply chain attacks work, what attackers typically do with

[01:21] an access, we'll analyze a few case studies and we'll try to learn from them. And the most important part we will discuss how can we defend from these types of attacks. One thing that we need to realize is that nowadays it's almost impossible to build any real life project without using third-party packages even that Django itself comes with a lot of batteries included, we still need to pull additional dependencies. Perhaps over the last two days We had about many great packages that we need to install to get excess functionalities And whenever we decide to introduce a package to our project,

[02:06] we signal that we trust maintainer and the community that this package is safe to use. But we also need to keep in mind that every package that we install can bring the whole chain of transitive dependencies. So even this really simple example that I have on the slide We explicitly requested three packages, so Django request and salary, but as a result total ten total dependencies were installed and we need to somehow trust all of them. And attackers know that and they try to inject malicious code into any package in that tree and that's what we called a supply chain attack Quick note, on Wednesday there

[02:53] was a talk about reporting vulnerabilities in Django and Those are usually CVs are usually accidental mistakes made in the third-party code that carries security implications. Supply chain attacks are about intentional malicious code injection. Okay, so let's put ourselves into the shoes of the attacker for a moment and let's assume that we try to inject malicious code into dependency tree of the project. On the high level it consists of two steps. We must put malicious code out there, probably on the PIPI, and somehow make people install it. Obviously attackers don't gain anything if the back

[03:39] bat package is sitting out there but nobody installs it. So there must be this installation step And we have like a two main ways. One is creating new malicious package. That's much easier because anyone can submit a package to PyPI registry. And the tricky part is how to make people install it. Attackers need to somehow promote it or make it easy to install by accident and popular techniques involve typosquatting or the newer technique slop squatting, also called LRM hallucination. The other way that is a little bit harder to pull off but allows attackers to gain more

[04:24] is about compromising existing packages. So if they target some kind of popular package, they automatically achieve the effect of scale because most popular packages can be installed hundreds of thousands or even millions times a day and that's what we will see in the case studies of these real world attacks Okay, but let's quickly understand what attackers can actually do and what can what they what they are actually trying to accomplish Malicious code can run the moment you PP install or the moment you import a package. When it runs, it runs with your permission. So it has access to everything your process does. It can be environment variables, cloud credentials, SSH keys,

[05:12] your developer credentials thought in the dot files, just everything. Basically, the most common concept is to steal this and send back somehow to the attacker. But sometimes attackers also decide to play the long game and for example put some kind of persistent into the system by placing some kind of backdoors. Most the other important part is the threat component. So nowadays we see that these attacks state to propagate further. So if attackers detect that the exfiltrated environment has access to PyPI, GitHub or some other service, they would use that to publish more

[05:58] malware so the attack quickly compounds. So let's start by typoscottic examples because it's the easiest one. We as a human make Easy mistakes when typing. So for example we've got an example here. We've got the first line is about installing the package called TermColor. But since and N are close to each other on the keyboard, it's easy to make a typo and install telon color. The first one is a legit package, the second one is actually a malware. that it's no longer available but if we are unfortunate to type this to mistype this when it was available our machine could be infected

[06:46] Another trick that we observed recently is that attackers try to use The fact that some packages, some tools goes viral really quickly. So for example, there is this DeepSeek LLM that went viral last year in January. So quickly we quickly observed multiple package names that tried to spoof the actual lipsig official package. and most likely these malicious packages were written by an LLM. Okay, so let's move to the case studies because I be I believe that's the interesting part. So let's start in December 2024.

[07:31] and it's about ultra lytics package. This is quite popular computer vision library. And attackers used clever GitHub Action Exploit to publish multiple malicious versions that contained cryptocurrency miner. The attack was active for about 12 hours and came in two waves. I won't go into much details, but the pipeline was basically vulnerable to the shell injection. Attackers created pull requests with a branch name that allowed them to execute specific payload in the pipeline and that pipeline had access to GitHub secret and allowed to exfiltrate PyPI tokens

[08:19] So a few lessons for maintainers is that we need to revoke credentials immediately after any breach. So I mentioned that this attack came in two waves and basically the second wave was caused by the fact that exfiltrated PyPI credentials were not rotated. We need to audit our CICD workflow permissions so there was some misconfiguration that allowed external PRs to access the secrets. And there is a PyPI feature called trusted publishing that allows to use fmrl tokens instead of persistent ones. So even if Attackers streak token, it's no it's valid only for short time

[09:08] Another case study covers num2ad package, obviously as name suggests it's about converting number to words This time it's a little bit more recent because from July last year. And the techn technical it was not technical exploit but fishing that led to the theft of maintainer credentials. The method itself was pretty clever because basically someone sent to the maintainer the fake PyPI email and the domain used was PyPj instead of PyPI But under the hood there was like a real -time transparent proxy that defeated the second factor authentication.

[09:54] So basically even though the account was had 2FA configured it was bypassed using this transparent proxy and as a result multiple accounts were compromised but and malicious versions were published to the PyPI But since attackers gained access to the only to the PyPI, there were no associated GitHub commits. that looked a little bit suspicio suspicious when someone started analyzing why that was a release in PyPI and nothing in GitHub. This time the demol were targeted Windows and obviously once again there was it was designed to steal credentials. From the outside package appeared to work normally

[10:41] and there was even this accept pass pattern so even in case ever anything goes wrong the editor was silenced. Many people could potentially install it and even not notice Once again attackers try to propagate the attack through the compromised PyPI credentials. So we observe the same pattern that attackers attacks nowadays try to propagate further. Perhaps the hardware security keys would be a little bit better because they are bound to the specific domain so a UbiKey enrolled on pypi. org wouldn't wouldn't work on the fee

[11:27] on this phishing domain. But also we observe something that worries that is worry some a little bit because dependabot started to create pull requests allowing users to upgrade to the malicious version. So The tool that was supposed to help us keep up to date was used against us to create PRs with malicious version. So even though it was detected within two hours still some people were affected. How many people had about light alm attack that happened last month?

[12:12] Okay, so not enough. Okay, so this is the most recent case study coming from la last month There's a package called LiteLM. I haven't personally used it, but it appears that it has 3 million downloads per day, so pretty much. And the fun fact is that light LM maintainers were using another tool that is called Trivi. Does anyone know Trivi? It's like a security scanner and this security scanner was compromised the irony and as a result the It was running in the pipeline

[12:58] and attackers were able to fully take over the GitHub account of the maintainer. As a result multiple versions were published and we got a little bit lucky because there was a bug in the malware that caused some noticeable system issues. Users installed it and noticed that there is something wrong going on locally and started to investigate that But the actual exploit was pretty clever. To be honest, I haven't heard before about. pth extension. But apparently there's like the file that you can put in the site packages that gets executed automatically on every Python process startup.

[13:45] So it doesn't matter if you import the package or not. you could install the light LLM and never import it and you will still be affected because of this functionality So this is official timeline published by PyPI team. So we see that like it was put down but after about three hours but package was still downloaded around one hundred one twenty hundred thousand times so pretty many downloads Once again, it collected everything that it was able to. So private SSH keys, cloud credentials,

[14:33] crypto wallets, files, even shell history, things like that. There was additional logic to that side to achieve persistence for related usage, for example in the inside the Kubernetes clusters. And also the encrypted files were shared were sent to the domain that looked like the it belongs to light LLM. So maybe if we observe the logs it looks like a legit traffic. that also made the detection a little bit harder. Okay, so most important most important from this is Security tools are also dependencies. So we usually remember about pinning specific project dependencies, but for example if we use some kind of

[15:22] 3v security scanner inside the pipeline and we don't pin exact version, we can become a victim of attack like this. Credential rotation is speed is critical because there was like a few days gap between the TV 's compromise and actual LHLM incident and obviously the unpinned dependencies in CICD are high risk Okay, so let's before we talk about ways to defend ourselves we can go through some common misconceptions that don't always tell the full story. So I'm always hitting that log file protects us.

[16:07] So yes, they protect us If we are sure that the dependencies that we locked in are safe, but obviously you need to still install new packages, install update the existing dependencies. If we are unlucky and run install or update commands during the time when the package is malicious log files wouldn't protect us. Obviously we also have some kind of many packages that are like Dev dependencies that we don't care about that much and they also be targeted in this type of attack A few years ago I was just hitting the advice, it's easy, just don't install suspicious packages and you are fine.

[16:52] But now it seems like the attacks are more and more sophisticated, so I don't know AI generated readmes and the package the package looks legit so it's not easy to tell if something is like malicious or not. just looking at the package itself. We run everything in Docker so we are safe. Yeah so it limits the blast radius, limits the damage but Obviously credentials can still be exfilcated from the Docker, so it doesn't prevent that. And unfortunately the sad truth is that we can't fully prevent supply chain attacks It's enough to have one weak link in the chain of dependencies to be affected.

[17:38] So even if we make sure that like 99 of our dependencies are safe, it's enough to have like one bad dependency to be affected. Yeah, so basically we can either never update any package and get hit by critical CV or update fast and get hit by a supply chain attack. That's the choice that's the choice that we are faced facing, but on the series note there must be something in between Yeah, so most important thing that we can do is to use concept of dependency cooldown. So we don't ever want to be the first to install the fresh version Most of the poly malicious packages are detected within

[18:24] minutes, hours or days. And this is like one asterisk here because obviously it's it's about popular packages, but if there is like less popular package The time to detect malicious action can take even longer, so that's something that we need to keep in mind. Unfortunately both UV and Peep offer dedicated flags to filter the package. version by upload time so we can specify that we don't want to the versions that were released like six hours ago, two days ago or whatever period of time we select It's important to pin versions and verify hashes, so

[19:09] Having just three requirements takes day is not enough. It's not it's not a proper log file, it doesn't have a checksum, so we need to think about that this. And we need to be extra careful when adding or updating the dependencies to new versions we need to scan with tools. I will discuss them in a moment. We need to check project health and review the Pendabot PRs and don't blindly accept them Okay, so I don't want to try to sell you any specific tools as we have seen. Triv was supposed to help and in the light LM attack it

[19:54] it was the cause. So I would like to you to present the overview of what's available out there and what approaches are taken by different tools so you can decide yourself. which approach is relevant for your use case. Basically there is a concept of pattern scanning so there are tools like GarDoc from Datadoc Company that analyzes the package source code for suspicious patterns like base 64 execution network calls in the setup pie and it does it before you install There's also install time firewall, so it's there is like a database of known malicious packages and tools like socket firewall or

[20:40] supply chain firewall from Datadoc are checking the package that is about to be installed against these versions. There's a new concept of LLM-based diff analysis, so there are tools that monitor registers for new releases and diff against previous versions and use LLM to classify if the changes are correct or malicious. Before introducing dependency to our project, we can review the project health. So there's a like an open SSF scorecard that allows us to check if project is following security practices

[21:26] so we can assess that before adopting and there's also this concept of hard and built environments so coin container images with extra security tool tools like this socket file that I mentioned in the second row. Obviously Pype I is getting better so they have introduced a few things that are worth mentioning so those short-lived tokens there's an option to quarantine the suspicious package there's a concept of att station so approved that a package came from a specific CIA workflow There's also this concept of typosquatting detection, so they try to automatically check when you register a package if it's It's trying to

[22:12] post as a different package, but yeah. Like every presentation now needs to mention AI so I don't want to be worse, so AI here is like a double double-edged sort. We can treat AI as an as an attack vector. Like I mentioned, slop squatting, so it's a technique where LLMs sometimes hallucinate package names that do not exist. And attackers use that fact and try to register these packages, relying on the fact that if another user prompts their LLM for similar use case, they will be recommended the same package. Fortunately or unfortunately

[22:59] more and more projects use AI to automatically trash issues or PRs. So this is like a real-life example of the appearance injection for the GitHub issue. That is we are using LLMs so there are like plug-in cell skills for the LLMs and they can also contain malicious code. The sad fact is that some often the AI agents don't just suggest that we need to install some package, they install it automatically. So that's why sometimes we can be affected very quickly. But there are also upsides, so I mentioned the LM

[23:44] -based package monitoring. Someone from Elastic built a tool called Supply Chain Monitor. Basically they they've read about light LLM incident and decided that maybe that that's approach that it's worth following so they build it in like a MVP version in a single afternoon And fun fact is that there was a supply chain attack on the Axios, so it's like a popular NPM package That happened like a week after Light LM and it was called Live using this tool. It was tested on the real example and worked, so maybe there's potential there. And obviously we can use

[24:31] Scale advantage so LLMs can analyze more packages per day than human reviewers so maybe that's an approach that it's worth exploring Okay, so at the end of this presentation I wanted to present you with like a few tips when it comes to managing dependencies. Minimize your dependency service so it's easy to add new packets, we often forget to remove them. So let's remember about that. If you need only one specific piece of code from a library, we could consider copying it directly instead of bringing the whole dependency. I found the proverb in the Golang community that a little copying is better than a little dependency.

[25:21] So maybe that's something worth thinking about And if we need to use the package but it's it seems like unmaintained or maybe we don't fully trust it but there's no alternative we could consider forking it so at least we have a full control over it Yeah, when it comes to protecting environment, as we have seen, like all of the attacks had this component of credentials exploitation. So like a highest impact single thing would be restricting outbound network traffic for some kind of firewall.

[26:07] We need to reduce the blast radius, so we don't we don't let's don't keep what you what we don't actually need so we should use containers as VMs to isolate things. If there are credentials that we are no longer needed needing, we can consider removing them. As a fun exercise, you can just dump your n variables and look for the SSH keys and cloud credentials and all the other tokens and like assess if you really need all these things to be available on your machine And we need to investigate anything suspicious, so there was this unexpected network traffic, high CP usage.

[26:54] potentially symptoms of something going wrong so we can't ignore it we need to investigate as soon as possible And last tips are I hope that it doesn't happen to any of you, but when you are compromised we need to assume the full compromise. It's not enough to just uninstall the package. We need to rotate all credentials accessible, even the cached wheels, because they can re-infect the machine we need to check if we were part of the chain so if we had access to any publishing credentials like PyPI and PM tokens We need to check that and potentially rotate.

[27:40] And if possible builds don't patch. So if we have some kind of backups Whether it's like our local environment or the production, we need to restore the known good version Okay, so that's all I wanted to show you today. I hope this presentation has increased the awareness about supply chain attacks. And we need to remember that dependencies in our projects can be considered an attack surface, so that's why we need to defend them. Thanks.

**Speaker 1:** [28:22] Thank you very much for the great presentation. So we have time for questions. Anybody having questions?

**Speaker 3:** [28:34] Hi. So you mentioned these attacks which are broad. How would you defend against a specific attack against one person or one organization? Especially from a powerful adversary. Like if I was an insider on PyPI or if I hacked PyPI, I could just I don't know select your IP range and then only give the malicious package to you And you probably wouldn't know it, right? Even with all these tools, maybe except for the LLM diff. How would you defend against that?

**Mateusz Bełczowski:** [29:10] Yeah, so I mean if someone has big budgets you can't defend against that. That's the sad truth. So we need to put trust somewhere. I mean we can be really it depends on the our risk level but we can be really paranoid about it maybe like isolate the machines run firewalls locally but there's always some kind of because here we talked only about the packages themselves but if we consider all the other toolings so like system packages like IDs, plugins for the IDs, coding agents,

[29:56] plugins for the coding agents. So the surface is really huge. So it's we can talk about PyPI and how to make it better, but it wouldn't be enough even if we make PyPI perfect so no one slips in to the PyPI. There are a lot of other potential vectors that could cause some damage.

**Speaker 3:** [30:19] Okay thanks.

**Speaker 1:** [30:21] I think we have time for one more question. Yeah.

**Speaker 4:** [30:25] Hello, thank you for this talk. Are there ways that we can limit the effect of specific Python packages, for example to prevent certain operations from being executed by setup PY even if the package once installed needs to do them later.

**Mateusz Bełczowski:** [30:46] To be honest, yeah so by default it installs as the user that you are currently logged in. So it has the same permissions. I know that in the npm there is like a flag that allows you to disable pre and post install hooks, but I don't know anything in Python for the setup. py So I'm afraid that one thing that you could try is to install the package inside the isolated environment like a Docker container. and there are ways in Docker to like cut out the network so only you can only like allow this package to be installed but any external call would be caught

[31:32] by the Docker firewall so that's an option but I don't I'm not aware of any ways to limit that in setup Pi

**Speaker 1:** [31:44] Thank you very much for this great presentation. Round of applause please.
