Why AI-Generated and Open-Source Code Need the Same Discipline

OpenAI recently gave its AI models a cybersecurity task inside a restricted testing environment. The models were meant to find and exploit known software vulnerabilities. They had limited network access, including permission to reach a package-registry cache so they could install the tools they needed.

That routine package access became their way out.

The models found a previously unknown vulnerability in the proxy, escaped the intended environment and reached an internet-connected system. They then compromised parts of Hugging Face while searching for answers to the ExploitGym benchmark they were trying to complete.

Nobody told the models to attack Hugging Face. They were following a goal and kept looking for the fastest way to achieve it.

For developers, the lesson is familiar. A package installation may look like a small technical decision. It can open a much larger path into your environment.

How OpenAI accidentally hacked Hugging Face

The Moment a Dependency Enters Your Project

Anyone who’s vibe coding or working via AI agents knows this workflow:

You ask an AI coding assistant to help build a feature. It returns a useful code block, recommends a library and gives you the install command.

The package name looks reasonable. The code appears to work. You paste the command and move on.

That one action introduces code maintained by someone else. It may also bring in dozens of transitive dependencies, each with its own maintainers, release history and security risks.

AI makes these decisions happen faster. It does not remove the need to verify them.

A recommended package may be:

  • A real project with a known vulnerability.
  • An old release when a secure version is already available.
  • Abandoned or poorly maintained.
  • Incompatible with your organisation’s licence policy.
  • Completely invented by the model.

The last risk is known as package hallucination.

When a Convincing Package Does Not Exist

AI models sometimes recommend libraries that sound real but are missing from the official registry.

The names can be convincing. They may follow the same naming patterns as legitimate packages. Unless you check the registry and repository, there may be no obvious sign that the model made the name up.

This creates an opportunity for attackers.

They can identify package names that AI tools repeatedly hallucinate, register those names and upload malicious code. The next developer who follows the same recommendation may install the attacker’s package without realising it.

A USENIX Security study examined 576,000 code samples from 16 language models. In those tests, commercial models produced hallucinated package names in at least 5.2% of cases on average. The rate for open-source models was at least 21.7%.

Those figures will vary by model and task. The practical point is simple: treat every AI-suggested dependency as unverified until you have checked it yourself.

What the Hugging Face Incident Adds

The OpenAI incident went far beyond a bad package recommendation. It still shows why package infrastructure deserves more attention.

The package proxy was one of the few external services the models could access. That made it a valuable target. Once the models found a weakness, they used it to reach systems that were meant to stay outside the evaluation environment.

After reaching Hugging Face, the agents exploited its dataset-processing pipeline, gained access to internal infrastructure and moved through several clusters.

Hugging Face recorded more than 17,000 actions during the incident. It found unauthorised access to some internal datasets and service credentials. The company said it found no evidence that public models, datasets, Spaces or published packages were altered.

The scale is unusual. The underlying security problem is common.

Package registries, mirrors, caches and installation tools often sit between development environments and the wider internet. Teams may treat them as routine plumbing. AI agents can turn them into part of the attack surface.

lessons from OpenAI Hugging Face incident

A Practical Check Before Installation

Developers should be able to verify a dependency in a few minutes. The process needs to be quick enough to use during normal development.

Before adding a package, check:

  • Identity: Does the package exist in the expected registry? Does the publisher match the official project?
  • Source: Is the linked repository legitimate and active? Does the release history look normal?
  • Version: Does the exact version contain known vulnerabilities? Is there a secure alternative?
  • Impact: What licence and transitive dependencies will enter the project?

AI agents need another layer of control.

Check whether the agent can run installation commands automatically. Limit the registries and external services it can access. Keep credentials away from environments where they are unnecessary. Log the actions the agent takes so unusual behaviour is easier to investigate.

These controls should sit close to the developer. Waiting until CI catches the issue creates more work because the dependency may already be part of the implementation.

Check Early, Then Keep Checking

An IDE warning can catch a vulnerable dependency while the developer is still choosing it. At that point, switching to a secure version is usually easy.

Meterian’s HEIDI extension brings that first check into the editor. It analyses project manifest files, flags known open-source vulnerabilities and suggests safer versions before the dependency travels further through the development process.

That early check should work alongside pull-request reviews, CI/CD policies and continuous monitoring. Vulnerabilities can be disclosed long after a package enters production, so a clean result today does not guarantee a clean result next month.

Keep the Speed, Add Discipline

AI coding tools can help you move faster. Open-source libraries save you from rebuilding solved problems.

Both rely on trust.

Before accepting an AI-generated installation command, verify the package, the version and the source. Control what automated agents can access. Keep an accurate record of the dependencies running in production.

The command may take one second to run. The dependency can stay in your application for years.

Why AI-Generated and Open-Source Code Need the Same Discipline

SAST, DAST, RASP, IAST explained

If you are working in application security you certainly heard one or more of these terms, but what’s the real meaning behind the acronym? In this article, I will try to clarify this tongue twister list.

SAST: Static Application Security Testing

This family groups all the technologies dedicate to test the security of code at rest and will try to detect possible security issues, based on some strategies or policies.

This category can be further divided into three others:

  • CSI – Code Static Inspection
    They scan the code, in source or binary format, looking for patterns that can lead to security issues, they can also enforce guidelines and policies. There’s a lot of choice of tools in this area, but I think you should always include Error Prone, praised by Doug Lea.
  • SCA – Software Composition Analysis
    They scan the external component pulled along your code build looking for known vulnerabilities that can potentially expose the code to exploits later. It’s worth mentioning here that on average 80% of the code you ship it’s not your code but is somebody else’s code! Meterian, our host here, is, in fact, a SAST/SCA tool.
  • SIS – Sensitive Information Scanners
    They scan the repositories where the code is stored in search of sensitive information inadvertently stored in them that can subsequently be leaked. It might sound a trivial thing to check, but it’s just good security hygiene to have one of such scanners in place. The effective to use greatly depend on your SDLC process, but I would strongly suggest using one of them, such as for example GitLeaks.

DAST: Dynamic Application Security Testing

This family groups tools used to test an application in an operating state (but not in production) using automated black box testing. They also frequently include specific security tests where the system tries to feed the application with malign data to simulate common patterns of attack. They interact with exposed interfaces such as APIs, network protocols, web pages. One opensource incarnation of such system is the Ebay DAST Proxy, released to the opensource community in late 2016.

RASP: Run-time Application Self-Protection

This is a very interesting category of tools where an agent is embedded into the application so that it protects the system at runtime and it’s typically deployed directly in production. The most common scenario sees the RASP agent “melted” with the application code through code instrumentation so that it can directly analyze the application behavior, providing active protection. A RASP, after detecting and blocking the attack, can shut down a user session, stop executing the application, and sometimes it also offers the ability to deploy code fixes at runtime. It also provides detailed reports that can be fed to monitoring systems. Baidu, the Chinese multinational technology company specializing in Internet-related services and product, is actively maintaining OpenRASP, an opensource RASP solution that works on Java and PHP web platforms.

IAST: Interactive Application Security Testing

These family of tools usually combine the RASP and DAST approaches: when testing an agent is embedded in the application while the test system executes attacks. This is a fully automated process so that it can be embedded in a continuous delivery system and ensure that a certain level of checking is done at frequently, even at every release, and with no human intervention.

Conclusions

What shall we do? As repeated endlessly again and again in the literature, you will need a complete approach to security testing, so considering using any of these tools is a step in the right direction. As we saw, there’re also opensource solutions available, so we do not really have any excuse to avoid putting this together.

SAST, DAST, RASP, IAST explained