Knowledge · Application Security

Hidden Dependencies in AI-Generated Code

How direct, transitive, and runtime-expanded dependencies can make the true dependency surface of AI-generated software much larger than its visible imports suggest, and why SBOM generation is essential.

Primary question: Why can the dependency surface of AI-generated software be much larger than its visible imports?

Definitions

Direct dependency

A package or library that is explicitly declared in the project's dependency manifests and imported by the application source code.

Transitive dependency

A package or library that is not directly imported by the application but is required by a direct dependency. Transitive dependencies form a dependency graph that can extend several levels deep.

Runtime dependency expansion

The phenomenon where additional dependencies are loaded or activated at runtime through dynamic imports, configuration-driven loading, or framework-level dependency injection, beyond what is visible in static source code analysis.

Hidden dependency

A dependency that is used by the application but is not obvious from source code inspection alone, including transitive dependencies, dynamically loaded packages, and framework-managed dependencies.

The engineering problem

AI-generated code can import packages that pull in transitive dependencies, expanding the application's dependency surface beyond what is visible in the generated source code. The developer may only see the direct import, not the resolved dependency graph. [hidden-deps-study]

One empirical study of LLM-based coding agents found that generated code frequently references dependencies with missing or incorrect versions, and that transitive dependencies are often not explicitly declared in generated code. [hidden-deps-study]

Runtime dependency expansion — through dynamic imports, configuration-driven loading, or framework-level dependency injection — can introduce additional dependencies that are not visible during static code review of AI-generated code. [nist-sbom-framework]

Without automated SBOM generation, organizations may underestimate the true dependency surface of AI-generated applications, leaving them exposed to vulnerabilities in transitive dependencies that are not reviewed during code inspection. [nist-sbom-framework]

Security controls

Each control inspects a different artifact and produces evidence for an engineering decision.

Dependency discovery

SBOM generation
Artifact
Dependency manifests, project files, installed component directories, and transitive dependency metadata.
Risk
Incomplete dependency inventory that misses transitive and runtime-expanded dependencies in AI-generated applications.
Output
An SBOM documenting the direct and transitive dependencies discovered by the selected resolution and analysis methods, enabling vulnerability assessment and supply-chain evaluation.

Evidence: DerScanner software composition analysis documentationNIST SP 800-161 Rev. 1 — Supply Chain Risk Management Framework

Dependency graph analysis

Transitive dependency analysis
Artifact
The resolved dependency graph produced by SBOM generation, including discovered transitive dependency levels.
Risk
Undetected vulnerabilities in transitive dependencies that are not directly imported by the application but are used by direct dependencies.
Output
A dependency graph showing the direct and transitive dependencies discovered by the selected resolution and analysis methods, with their versions and relationships.

Evidence: DerScanner software composition analysis documentation

Verification workflow

  1. Generate or modify code with an AI coding tool.
  2. Run SBOM generation to discover the direct and transitive dependencies in the AI-generated application.
  3. Analyze the dependency graph to identify transitive dependencies that were not explicitly declared by the developer.
  4. Cross-reference the discovered dependency inventory against known vulnerability databases to identify vulnerabilities in transitive dependencies.
  5. Evaluate runtime dependencies by analyzing dynamic imports, configuration files, and framework-level dependency injection.
  6. Integrate SBOM generation into the build process to continuously monitor the discovered dependency surface of AI-generated applications.

Limits of verification

  • SBOM completeness depends on the quality of dependency manifests and source-file resolution.
  • Static SBOM generation may not capture runtime dependency expansion caused by dynamic imports, configuration-driven loading, or framework-level dependency injection.
  • Dynamic imports and framework-level dependency injection may introduce dependencies that are difficult to discover statically.
  • Production acceptance remains an organizational engineering decision.

Canonical terms used: Hidden dependencies; Transitive dependencies; Runtime dependency expansion; SBOM generation.

Evidence and references

  1. AI-Generated Code Is Not Reproducible (Yet) — Dependency gaps in LLM-based coding agentsOne empirical study of three coding agents and 300 generated Python, JavaScript, and Java projects found that generated code frequently references dependencies that are missing, have incorrect versions, or depend on transitive dependencies that are not explicitly declared. This study examined a specific set of coding agent tasks and should not be generalized to all AI-generated code.hidden-deps-study
  2. NIST SP 800-161 Rev. 1 — Supply Chain Risk Management FrameworkNIST SP 800-161 Rev. 1 provides supply chain risk management guidance for organizations. It recommends maintaining SBOMs as a practice within supply chain risk management to enable vulnerability assessment and incident response, and discusses documenting components including transitive dependencies.nist-sbom-framework
  3. DerScanner software composition analysis documentationDerScanner SCA identifies component vulnerabilities, dependencies, software supply chain risks, and license risks. DerScanner generates SBOMs documenting the dependencies discovered by the selected resolution and analysis methods.derscanner-sca

Discover hidden dependencies

Reveal the true dependency surface of AI-generated applications with automated SBOM generation.

Tell us about your AI-assisted development workflow and dependency discovery challenges. The DerScanner team will help map SBOM generation to your process.

Discover hidden dependencies

Discuss dependency discovery for your AI-assisted development

Share your AI coding tool usage, dependency discovery requirements, and security analysis needs. We will respond with the next practical step for automated dependency discovery.

Engineering knowledge for building and operating trustworthy systems.

DerSecur Recognition · build 821af10 · 2026-08-09 16:41:16Z · system