/

CVE-2026-105796

Severity:

HIGH RISK

(8.8)

Code Injection (CWE-94) in Kiota Java/PHP Generators

CVE-2026-105796

Awaiting Analysis

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Code Execution

Severity:

HIGH RISK

(8.8)

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's Java and PHP documentation-comment sanitizers can mishandle attacker-controlled OpenAPI descriptions, allowing generated text to escape documentation comments and become source code. If a developer or build pipeline generates, compiles, and loads affected output, injected code may execute in the consuming application or build environment.

Kiota's Java and PHP documentation-comment sanitizers can mishandle attacker-controlled OpenAPI descriptions, allowing generated text to escape documentation comments and become source code. If a developer or build pipeline generates, compiles, and loads affected output, injected code may execute in the consuming application or build environment.

Affected context

The issue can occur when Kiota generates Java or PHP source from OpenAPI documents containing malicious description text and the language-specific documentation-comment sanitizer removes comment terminators without safely neutralizing them. The Java implementation may also remove non-ASCII characters during normalization, potentially causing characters to form a new comment terminator. Exploitation depends on generated output being compiled and loaded for Java or loaded for PHP; the stated affected range is based on the Java defect and does not imply that PHP generation existed in every release.

The issue can occur when Kiota generates Java or PHP source from OpenAPI documents containing malicious description text and the language-specific documentation-comment sanitizer removes comment terminators without safely neutralizing them. The Java implementation may also remove non-ASCII characters during normalization, potentially causing characters to form a new comment terminator. Exploitation depends on generated output being compiled and loaded for Java or loaded for PHP; the stated affected range is based on the Java defect and does not imply that PHP generation existed in every release.

Exploit preconditions

  • Attack surface: OpenAPI descriptions processed by Kiota's Java or PHP source generators
  • Required access: Ability to influence the OpenAPI document or its documentation fields, plus access to a generation workflow
  • Trigger point: Documentation-comment sanitization followed by source generation
  • Execution condition: The generated Java output must be compiled and loaded, or the generated PHP output must be loaded
  • Why exploitation is possible: Sanitization can leave overlapping characters that reform a documentation-comment terminator, allowing attacker-controlled text to be interpreted as executable source rather than documentation
  • Attack surface: OpenAPI descriptions processed by Kiota's Java or PHP source generators
  • Required access: Ability to influence the OpenAPI document or its documentation fields, plus access to a generation workflow
  • Trigger point: Documentation-comment sanitization followed by source generation
  • Execution condition: The generated Java output must be compiled and loaded, or the generated PHP output must be loaded
  • Why exploitation is possible: Sanitization can leave overlapping characters that reform a documentation-comment terminator, allowing attacker-controlled text to be interpreted as executable source rather than documentation

Why this happens

The underlying bug is an output-neutralization failure in documentation-comment sanitizers. Instead of encoding or safely preserving comment terminators, the affected logic deletes them, allowing adjacent characters to be recombined into a valid terminator. In Java, additional character normalization can further change the sanitized output and create the same condition. This maps to CWE-94: Improper Control of Generation of Code, because untrusted specification content can cross from documentation data into generated program syntax.

The underlying bug is an output-neutralization failure in documentation-comment sanitizers. Instead of encoding or safely preserving comment terminators, the affected logic deletes them, allowing adjacent characters to be recombined into a valid terminator. In Java, additional character normalization can further change the sanitized output and create the same condition. This maps to CWE-94: Improper Control of Generation of Code, because untrusted specification content can cross from documentation data into generated program syntax.

Potential impact

  • Attacker-controlled code may execute in a build environment
  • Generated Java or PHP applications may execute injected logic
  • Source repositories or generated artifacts may be modified or poisoned
  • Build credentials, application data, or deployment secrets could be exposed
  • Downstream users may receive compromised generated client code
  • Attacker-controlled code may execute in a build environment
  • Generated Java or PHP applications may execute injected logic
  • Source repositories or generated artifacts may be modified or poisoned
  • Build credentials, application data, or deployment secrets could be exposed
  • Downstream users may receive compromised generated client code

General mitigation guidance

Mitigation generally focuses on preserving a strict separation between OpenAPI metadata and generated source syntax.

Common defensive patterns include:

  • Encode or neutralize comment delimiters rather than deleting them
  • Use context-aware escaping for every target language and output position
  • Treat OpenAPI documents and descriptions as untrusted input during generation
  • Validate generated source with language-aware parsers or compilation checks before use
  • Review generated diffs and keep generated artifacts isolated from privileged build steps
  • Run generation and compilation with least-privilege identities and restricted filesystem and network access
  • Prefer generator implementations that apply centralized, tested output-encoding routines

Mitigation generally focuses on preserving a strict separation between OpenAPI metadata and generated source syntax.

Common defensive patterns include:

  • Encode or neutralize comment delimiters rather than deleting them
  • Use context-aware escaping for every target language and output position
  • Treat OpenAPI documents and descriptions as untrusted input during generation
  • Validate generated source with language-aware parsers or compilation checks before use
  • Review generated diffs and keep generated artifacts isolated from privileged build steps
  • Run generation and compilation with least-privilege identities and restricted filesystem and network access
  • Prefer generator implementations that apply centralized, tested output-encoding routines

How teams detect issues like this

Organizations can look for this issue through:

  • Static analysis of sanitizers that delete comment markers or perform lossy character normalization
  • Code review checks for direct insertion of OpenAPI descriptions into source comments or generated code
  • Regression tests using delimiter-like sequences, overlapping characters, and non-ASCII input
  • Generated-source scanning for unexpected statements outside documentation comments
  • CI policies that require review of generated diffs and isolate code generation from deployment credentials
  • Automated security review tools configured to identify code-generation and output-encoding weaknesses

Organizations can look for this issue through:

  • Static analysis of sanitizers that delete comment markers or perform lossy character normalization
  • Code review checks for direct insertion of OpenAPI descriptions into source comments or generated code
  • Regression tests using delimiter-like sequences, overlapping characters, and non-ASCII input
  • Generated-source scanning for unexpected statements outside documentation comments
  • CI policies that require review of generated diffs and isolate code generation from deployment credentials
  • Automated security review tools configured to identify code-generation and output-encoding weaknesses

Sources

SourceLink
github.comgithub.com/microsoft/kiota/commit/68f33b865be9273464a6efbbe17379760e51f1a4
github.comgithub.com/microsoft/kiota/pull/8017
github.comgithub.com/microsoft/kiota/releases/tag/v1.35.0
github.comgithub.com/microsoft/kiota/security/advisories/GHSA-rm89-rhwj-9j92

Frequently asked

questions

Exploitation is indirect. An attacker must influence an OpenAPI document and have the resulting source generated and subsequently compiled and loaded or otherwise executed by a consuming workflow.

The attacker generally needs a path to modify, publish, or supply OpenAPI metadata used by a developer or automated build pipeline. Direct access to the target runtime is not necessarily required.

Use context-aware escaping that neutralizes documentation delimiters and other source syntax without relying on deletion or lossy normalization. Validate generated output before it enters trusted build or runtime environments.

Treat specification content as untrusted, test generators with adversarial Unicode and delimiter inputs, review generated diffs, and run generation and compilation with minimal privileges and isolated credentials.

Exploitation is indirect. An attacker must influence an OpenAPI document and have the resulting source generated and subsequently compiled and loaded or otherwise executed by a consuming workflow.

The attacker generally needs a path to modify, publish, or supply OpenAPI metadata used by a developer or automated build pipeline. Direct access to the target runtime is not necessarily required.

Use context-aware escaping that neutralizes documentation delimiters and other source syntax without relying on deletion or lossy normalization. Validate generated output before it enters trusted build or runtime environments.

Treat specification content as untrusted, test generators with adversarial Unicode and delimiter inputs, review generated diffs, and run generation and compilation with minimal privileges and isolated credentials.

Find out what's already
exploitable in your codebase.