run2_jackson-inject-security
Preventing Jackson @JacksonInject bypass via empty JSON keys by using OptBoolean.FALSE to reject user-supplied input for injected parameters.
- License 许可
- MIT
- 最近更新
- 2026-10-02
- Stars
- ★ 92
- Forks
- 7
01 前言 Front Matter
- name
- run2_jackson-inject-security
- description
- Preventing Jackson @JacksonInject bypass via empty JSON keys by using OptBoolean.FALSE to reject user-supplied input for injected parameters.
03 SKILL.md 正文
Jackson @JacksonInject Security: Preventing Input Override
Vulnerability
Jackson's @JacksonInject allows server-injected values to be overridden by JSON input. An attacker can use an empty key "" in the JSON payload to inject a custom object that replaces the server-configured value.
How the Empty Key Attack Works
When Jackson deserializes a class with @JacksonInject:
- It first sets the injected value from
InjectableValues - Then it processes JSON properties, including empty-string keys
"" - The empty key
""can match the injectable parameter, overriding the server value
Example Attack Payload
{
"type": "javascript",
"dimension": "dim",
"function": "function(x){java.lang.Runtime.getRuntime().exec('cmd')}",
"": {"enabled": true}
}
Fix: Use OptBoolean.FALSE
Code Change
// BEFORE (vulnerable):
import com.fasterxml.jackson.annotation.JacksonInject;
@JsonCreator
public MyClass(@JacksonInject MyConfig config) { ... }
// AFTER (secure):
import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.annotation.OptBoolean;
@JsonCreator
public MyClass(@JacksonInject(useInput = OptBoolean.FALSE) MyConfig config) { ... }
What useInput = OptBoolean.FALSE Does
- Tells Jackson to NEVER use JSON input for this parameter
- Only the server-injected value from
InjectableValuesis used - Any JSON property (including empty key
"") attempting to set this parameter is ignored
Compatibility
- Requires Jackson 2.9+ (available in Jackson 2.10.2 used by Druid 0.20.0)
com.fasterxml.jackson.annotation.OptBooleanimport required
Patch Generation Workflow
# 1. Make changes to source files
# 2. Generate unified diff patch
cd /root/druid && git diff > /root/patches/fix.patch
# 3. To apply on clean repo:
cd /root/druid && git apply /root/patches/fix.patch
# 4. Build specific module with all dependencies:
mvn clean package -DskipTests -Dcheckstyle.skip=true -Dpmd.skip=true \
-Dforbiddenapis.skip=true -Dspotbugs.skip=true -Danimal.sniffer.skip=true \
-Denforcer.skip=true -Djacoco.skip=true -Ddependency-check.skip=true \
-pl '!web-console' -pl indexing-service -am
04 同仓库更多 Skills
object_counter
Count occurrences of an object in the image using computer vision algorithm.
travel-planning-workflow
Invoke this skill when performing travel planning. It defines a structured workflow for generating itineraries. Following this workflow is essential to ensure the final plan satisfies user requirements.
bundled-dataset-search-tool
invoke this skill when you need to perform database search for travel planning. This skill provides some useful pre-packaged tools to look up accommodations, attractions, cities, driving distance, flights, and restaurants from the bundled dataset.
glm-output
Output-processing guidance for GLM tasks. Especially useful after glm-basics and glm-calibration when you need verifier-matching metrics from output.nc and a final /root/metrics.json.
glm-calibration
Calibration guidance for GLM tasks. Often most effective after glm-basics has clarified the setup; glm-output is the companion skill for exact final metric computation.
glm-basics
A good starting point for GLM calibration tasks. Use to inspect glm3.nml, confirm how GLM runs, and identify the relevant files before moving on to calibration and output evaluation.