/

CVE-2026-59867

Severity:

HIGH RISK

(7.1)

SSRF and File Inclusion (CWE-918) in Kiota Generator

CVE-2026-59867

Deferred

Vulnerability type

Category:

Server-Side Request Forgery and File Inclusion

CWE:

CWE-22, CWE-829, CWE-918

Impact:

Server-Side Request Forgery and Sensitive File Disclosure

Severity:

HIGH RISK

(7.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Kiota, an OpenAPI-based HTTP client generator, previously resolved $ref definitions by automatically fetching remote URLs and reading arbitrary local file paths.

When a project consumed an attacker-controlled or influenced OpenAPI description, running kiota generate could trigger server-side request forgery, remote file inclusion, or local file inclusion during build time, leaking data into generated client code.

Affected context

The vulnerability appears in development or build environments that use Kiota to generate HTTP client code from OpenAPI specifications.

It is relevant when $ref properties inside OpenAPI documents are resolved automatically and the specification file or its transitive references can be modified or influenced by untrusted parties.

This includes scenarios such as consuming third-party API descriptions, loading specifications from external repositories, or processing specifications supplied by CI/CD pipelines without strict validation.

Exploit preconditions

  • Attack surface: The kiota generate command processing OpenAPI files, typically in developer workstations, build servers, or CI pipelines.
  • Required access: Ability to supply, modify, or influence the OpenAPI description or any referenced file/URL (e.g., contributing to a spec repository, poisoning a downloaded spec, or tampering with inputs in automated build processes).
  • Trigger point: Execution of the code generation step, where Kiota resolves $ref values and automatically fetches remote schemas or reads local file paths.
  • Why exploitation is possible: Kiota's reference resolution logic trusted $ref values and allowed fetching from arbitrary HTTP(S) endpoints and local absolute or out-of-tree paths without enforcing strict origin or path restrictions, effectively granting the OpenAPI description access to the generator's network and filesystem.

Why this happens

The issue stems from overly permissive resource resolution logic when handling $ref in OpenAPI documents.

Kiota treated reference targets as fully trusted, enabling the generator to follow remote HTTP(S) URLs or local file paths outside the expected project tree.

This pattern maps to:

  • CWE-918: Server-Side Request Forgery (SSRF) because the tool makes arbitrary outbound requests based on attacker-controlled input.
  • CWE-22: Path Traversal and local file inclusion because $ref could point to files outside the intended directory boundary.
  • CWE-829: Inclusion of Functionality from Untrusted Control Sphere as external schemas from untrusted origins could be automatically incorporated into generated clients.

The absence of strict allowlists, path confinement, and origin validation allowed an attacker-controlled specification to drive both network and file system access.

Potential impact

  • Unauthorized HTTP(S) requests from developer or CI environments to internal services (SSRF), which may expose internal APIs or metadata services.
  • Local file inclusion, where sensitive local files (e.g., configuration files, API keys, or environment-specific metadata) may be inlined into generated client code.
  • Remote file inclusion, allowing attacker-hosted schemas to be embedded into generated clients, potentially leaking information or polluting the resulting codebase.
  • Disclosure of internal service structure or hostnames through error messages or inlined content derived from SSRF targets.
  • Supply-chain style contamination of generated client libraries, where secret or proprietary data from the build environment becomes part of distributed artifacts.

General mitigation guidance

Effective mitigation focuses on reducing trust in external references and constraining I/O performed during specification resolution:

  • Constrain reference resolution to a well-defined, project-local directory tree and reject absolute or parent-directory (..) paths for $ref targets.
  • Introduce strict origin allowlists for remote HTTP(S) references so that only approved domains can be fetched, and disallow arbitrary URLs from untrusted specifications.
  • Treat OpenAPI specifications as untrusted input by default and apply validation or linting steps that flag or block external references that do not comply with organizational policies.
  • Separate build-time network and file access privileges by running code generation with minimal permissions, limited network egress, and restricted filesystem visibility.
  • Prefer offline, vendored copies of external schemas that are reviewed and stored under source control, instead of fetching arbitrary schemas during the build process.

How teams detect issues like this

Several high-level detection strategies can help identify this class of issue:

  • Static analysis and linting: Define rules that flag OpenAPI $ref values referencing absolute paths, parent-directory traversals, or non-approved HTTP(S) endpoints. Automated spec linters or API governance tools can enforce these rules.
  • Code review and policy checks: During review of build scripts and generator configurations, look for automatic fetching of remote schemas or unbounded path resolution. Require explicit allowlists for external origins and directory roots.
  • Build pipeline monitoring: Instrument CI/CD to log all outbound network connections and file reads during code generation. Alert or block builds when generation steps access non-approved hosts or directories.
  • Tool configuration validation: Regularly audit generator settings and wrapper scripts to ensure they enforce restricted origins, path constraints, and minimal privileges, and that no overrides bypass these protections.

Sources

SourceLink
github.comgithub.com/microsoft/kiota/commit/cccd798027f0a20db796b3df6c64f9897a39d7b1
github.comgithub.com/microsoft/kiota/pull/7888
github.comgithub.com/microsoft/kiota/releases/tag/v1.32.5
github.comgithub.com/microsoft/kiota/security/advisories/GHSA-rg4h-fpcp-2qm8

Frequently asked

questions

Indirectly. The vulnerable behavior occurs when a developer or build system runs kiota generate on an OpenAPI specification controlled or influenced by an attacker. While the attacker may only provide the spec, the resulting SSRF or file access is performed from within the environment running the generator.

An attacker needs the ability to introduce or modify OpenAPI documents or their referenced schemas that will be processed by Kiota. This may occur through contributions to repositories, poisoning downloaded specifications, or manipulating artifacts that pipelines treat as trusted input.

The safest pattern is to treat OpenAPI specifications as untrusted input, restrict $ref resolution to a controlled set of directories and domains, and ensure the generator enforces these boundaries by default. Any external schema use should be explicitly allowed and vendored where possible.

Future tools should implement strict allowlists and sandboxing for all network and filesystem operations derived from user-controlled configuration. Designing generators to run under least privilege, with constrained I/O and strong validation of external references, substantially reduces the risk of SSRF and file inclusion vulnerabilities.

Find out what's already
exploitable in your codebase.