codegen-literal-security-scan
Skill3.8k starsChanged 6 months agoMITView on GitHub
Detect and remediate code-generation literal injection risks in Kiota writer code (wire names, serialization names, URL templates, base URLs, defaults, and path parameter keys).
Trending
Quiet since April.thin dataabout the whole repository
Who's talking about microsoft/kiota
- A Hacker News story“Kiota: OpenAPI-based HTTP client code generator”Hacker News · Aug 14, 2024 · 72 points
- bitcoin/bitcoin“RFC: Formal description of the RPC API”GitHub · Apr 19, 2024 · 14 reactions
- keycloak/keycloak“@keycloak/keycloak-admin-client fails to install in version 26.6.0”GitHub · Apr 9, 2026 · 5 reactions
- @jdlong.cerebralmastication.com“I've only been beating on this thing in anger on and off for a few weeks, but it's... uh... weird. They …”Bluesky · Dec 28, 2024 · 2 likes
- @hn100.bsky.social“Kiota: OpenAPI-based HTTP client code generator Discussion”Bluesky · Aug 14, 2024 · 1 likes
The biggest 5 of 5 mentions linking to the repository that our crawl found. Each line is their own headline.
In this repositoryOne other file it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
The file
We split this skill into the rules it gives an agent
10 rules. About 0 are common, 8 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 6
Use this skill when auditing or modifying any code generator writer logic.
- Very specific: line 29
search for interpolation/writes that include the focus surfaces and emit language string literals (WriteLine, WriteLines, StartBlock, doc …
- Distinctive: line 30
Verify context-aware escaping is applied at the emission site:
- Distinctive: line 42
Keep quote style unchanged and apply matching sanitizer.
- Distinctive: line 46
keep Go struct tag behavior intact
- Distinctive: line 47
avoid changing enum/default value resolution logic
- Distinctive: line 48
avoid introducing extra quoting around non-string literals
- Distinctive: line 56
Default value emission in constructors, getters, and parameter signatures.
- Very specific: line 63
Add/adjust regression tests in corresponding writer test suites under tests/Kiota.Builder.Tests/Writers/.
- Distinctive: line 65
Ensure assertions validate escaped output, not just general generation success.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Use this skill when auditing or modifying any code generator writer logic.
Goal
Prevent generated-source injection (including potential RCE chains) by ensuring every untrusted schema-derived value is escaped for the destination literal context before being emitted.
Focus surfaces (expanded)
Prioritize all literal-emission paths under src/Kiota.Builder/Writers/**/*.cs, especially:
WireName,SerializationName,IndexParameter.SerializationNameUrlTemplateOverride, URI template constants, base URL defaultsDefaultValue(constructor assignments, getter fallback values, parameter signatures)- Path/query parameter assignment keys in convention helpers
- Query parameters mapper constants and metadata constants
- Enum wire values and enum member attributes
- Property annotations/attributes that carry serialized names
- Backing store keys for custom/additional-data properties
- Documentation long/short comments that interpolate external links/labels
Required checks
- Locate candidate sinks:
- search for interpolation/writes that include the focus surfaces and emit language string literals (
WriteLine,WriteLines,StartBlock, doc attributes/tags).
- search for interpolation/writes that include the focus surfaces and emit language string literals (
- Verify context-aware escaping is applied at the emission site:
- double-quoted literal contexts must use
SanitizeDoubleQuote() - single-quoted literal contexts must use
SanitizeSingleQuote() - already-quoted defaults must use
SanitizeQuotedStringLiteral() - Dart quoted literals must use
SanitizeDartSingleQuoteLiteral/SanitizeDartDoubleQuoteLiteral(to also escape$) - Go struct tags must keep backticks and sanitize embedded quoted values (do not switch tag quoting style)
- double-quoted literal contexts must use
- Confirm no fallback path emits the raw value.
- Confirm convention-layer helpers (
AddParametersAssignmentand equivalents) are also sanitized, not only writer methods.
Remediation rules
- Escape at the final write site, not only upstream.
- Keep quote style unchanged and apply matching sanitizer.
- Reuse existing helpers in
src/Kiota.Builder/Writers/StringExtensions.cs. - For cross-language consistency, patch all affected writers (C#/Dart/Go/Java/PHP/Python/Ruby/TypeScript and helpers).
- Preserve runtime semantics while hardening:
- keep Go struct tag behavior intact
- avoid changing enum/default value resolution logic
- avoid introducing extra quoting around non-string literals
High-risk sink families to explicitly review
- Serializer/deserializer key emission (
WireName, discriminator keys, query mapper keys). - Request-builder URL/template metadata (
UrlTemplateOverride, URI template constants, base URL defaults). - Indexer/path parameter map writes (
urlTplParams[...],.Add(...),.put(...), map assignments). - Property/enum metadata attributes and constants (
QueryParameter,EnumMember, enum objects, navigation/request metadata constants). - Default value emission in constructors, getters, and parameter signatures.
- Documentation comments with external links/labels and deprecation text.
Verification expectations
After changes:
- Add/adjust regression tests in corresponding writer test suites under
tests/Kiota.Builder.Tests/Writers/**. - Include malicious payloads with quote + newline/control characters (
",',\n,\r,\t,\\, and$where relevant). - Ensure assertions validate escaped output, not just general generation success.
- Validate targeted writer tests and then broader builder/solution validation.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

