Skip to content

Developers use an AI coding assistant that suggests a package you cannot find in your approved list. What is the risk and what do you do?

Short answer

The risk is package hallucination: models may suggest non-existent libraries, and attackers can register those names with malicious code that developers then install. Treat AI suggestions as untrusted input: verify the package exists and is legitimate, pull only through an internal proxy with an allow-list, pin versions, scan dependencies, and require human review of AI-generated dependency changes.

This scenario tests whether you treat AI output as untrusted input and connect it to supply-chain controls rather than just banning a tool.

The risk

OWASP lists misinformation (LLM09:2025) as a top LLM risk and includes unsafe code generation: models may suggest "insecure or non-existent code libraries." The page describes attackers publishing malicious packages under commonly hallucinated names, which developers may then install unknowingly. Overreliance, "users place excessive trust in LLM-generated content, failing to verify its accuracy", makes it worse.

What you do

First, do not install the unknown name: check that the package exists, who maintains it, when it was created and whether it matches what the code needs. Longer term, enforce structure. Route installs through an internal registry proxy with an allow-list, pin versions with lockfiles, run software composition analysis, and require review of dependency changes in pull requests.

Align with OWASP mitigations

OWASP recommends cross-verification and human oversight, automatic validation of key outputs, secure coding practices that stop incorrect suggestions introducing vulnerabilities, and user training on the limits of LLMs.

Why the distractors are tempting

"The model validated it" is exactly the overreliance failure. "Test in production" and "ban everything" are the extremes.

What interviewers want

Name package hallucination, treat output as untrusted, and propose layered, proportionate controls.

Likely follow-ups

  • How does this differ from classic dependency confusion or typosquatting?
  • What controls in the CI pipeline would catch a freshly published malicious package?
  • Which metrics would show whether developers are over-trusting AI-generated code?

Sources

Get 100 cybersecurity interview questions + answers

Drop your email and we'll send you the free PDF pack and the flashcard deck.

No spam. Unsubscribe anytime.