Key injection occurs when untrusted input or LLM output supplies field names that are malformed, unexpected, duplicated, or meaningful to downstream systems.
The purpose may be to confuse parsing, overwrite values, bypass schema assumptions, trigger exceptions, or exploit unsafe consumers.
A syntactically valid key is not necessarily an authorized key.
These names are especially important when data crosses into JavaScript or object-oriented consumers.
{
"keys": [
"__proto__",
"constructor",
"prototype"
]
}
Note: Python dictionaries do not have JavaScript prototype-pollution behavior by default. The risk depends on downstream conversion and usage.
Duplicate names can cause silent overwrites or inconsistent interpretation between parsers.
{
"keys": [
"password",
"password",
"password"
]
}
Names containing spaces, punctuation, control characters, or unexpected types can break assumptions in downstream code.
{
"keys": [
"x y z",
"",
"user-name",
"user.name",
"name\nrole"
]
}
The validator should handle values that are not strings without crashing.
{
"keys": [
null,
123,
true,
[],
{},
["nested"]
]
}
A key may pass a regular expression but still be outside the application’s permitted schema.
{
"keys": [
"admin",
"is_authenticated",
"role",
"tenant_id"
]
}
Different spellings may normalize to the same field name.
userName
user_name
user-name
user.name
For example, converting punctuation and camel case to underscores may cause different inputs to become the same normalized key.
https://cwe.mitre.org/data/definitions/1321.html https://owasp.org/www-project-top-ten/ https://json-schema.org/learn/getting-started-step-by-step