druid-javascript-security
Securing Apache Druid's JavaScript execution engine against code injection and security bypass attacks.
- License 许可
- MIT
- 最近更新
- 2026-10-02
- Stars
- ★ 93
- Forks
- 8
01 前言 Front Matter
- name
- druid-javascript-security
- description
- Securing Apache Druid's JavaScript execution engine against code injection and security bypass attacks.
03 SKILL.md 正文
Apache Druid JavaScript Security
Vulnerability Context
Apache Druid versions up to 0.20.0 have a critical vulnerability in JavaScript expression handling where an empty key ("") can bypass security settings, allowing arbitrary code execution through the java.lang.Runtime API.
Key Components
1. JavaScript Transform Spec
- Located in indexing service modules
- Handles JavaScript expressions for data transformation
- Uses GraalVM or Nashorn engine for JavaScript execution
2. Security Filter Structure
The vulnerable structure looks like:
{
"filter": {
"type": "javascript",
"function": "function(){...}",
"": {
"enabled": true
}
}
}
The empty key "" is the bypass vector.
Patching Strategy
1. Input Validation
- Reject filter/transform specs with empty string keys
- Validate all keys in security configuration objects
- Enforce strict schema validation before passing to JavaScript engine
2. Security Configuration Enforcement
- Ensure
enabledflag is only checked for known, valid keys - Implement whitelist of allowed configuration keys
- Reject any configuration with unexpected keys
3. Code Changes Needed
- Typically in classes handling JavaScript filter/transform deserialization
- Common classes:
JavaScriptFilter,JavaScriptExpressionValidator, JavaScript spec handlers - May need to add validation in both request parsing and execution phases
Testing the Fix
Exploit Request (should fail)
POST /druid/indexer/v1/sampler
{
"type": "index",
"spec": {
"dataSchema": {
"transformSpec": {
"filter": {
"type": "javascript",
"function": "function(){java.lang.Runtime.getRuntime().exec('malicious_command');}",
"": {
"enabled": true
}
}
}
}
}
}
Legitimate Request (should work)
POST /druid/indexer/v1/sampler
{
"type": "index",
"spec": {
"dataSchema": {
"transformSpec": {
"filter": {
"type": "javascript",
"function": "function(row){return true;}"
}
}
}
}
}
Common Druid File Locations
- JavaScript filter implementation:
processing/src/main/java/org/apache/druid/query/filter/JavaScriptFilter.java - Indexing service:
indexing-service/src/main/java/org/apache/druid/indexing/ - Transform specs: Related to dataSchema handling
Jackson Deserialization Considerations
The vulnerability likely involves improper validation during Jackson deserialization. Use raw @JsonAnySetter or similar mechanisms to catch unexpected properties and validate them strictly before further processing.
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.