Disable JavaScript Execution in Druid Filters
Configure and enforce a security policy that completely disables JavaScript filter evaluation in Apache Druid, preventing arbitrary code execution through the javascript filter type even if structural validation is bypassed.
- License 许可
- MIT
- 最近更新
- 2026-10-02
- Stars
- ★ 93
- Forks
- 8
01 前言 Front Matter
- name
- Disable JavaScript Execution in Druid Filters
- description
- Configure and enforce a security policy that completely disables JavaScript filter evaluation in Apache Druid, preventing arbitrary code execution through the javascript filter type even if structural validation is bypassed.
03 SKILL.md 正文
Disabling JavaScript Filter Execution
Problem
Even if empty key validation is in place, the "type": "javascript" filter capability itself is a code execution vector. The security sandbox can be disabled or bypassed.
Solution: Disable JavaScript Filters at Configuration Level
Implementation Strategy
-
Identify JavaScript Filter Registration
- Find
JavaScriptDimFilterclass and its factory registration - Locate where filter types are registered (likely in a filter registry or module)
- Find where JavaScript evaluation is initialized
- Find
-
Create Security Configuration
- Add a Druid configuration property to disable JavaScript filters
- Default to disabled (secure-by-default)
- Prevent re-enabling via ObjectMapper annotations or runtime configuration
-
Enforcement Approach
Option A: Remove from Filter Registry
- Unregister
JavaScriptDimFilterfrom the factory - During module initialization, skip registration of JavaScript filter type
- Returns 400 Bad Request if client attempts to use it
Option B: Reject at Deserialization
- Create a custom deserializer for filter JSON
- If
type == "javascript", throwJsonMappingExceptionimmediately - Prevents any JavaScript filter from being instantiated
- Unregister
-
Configuration Property
druid.javascript.enabled=false (default, required for security)
Code Pattern
// In filter factory or deserializer
if ("javascript".equals(filterType)) {
if (!isJavaScriptEnabled()) {
throw new IllegalArgumentException(
"JavaScript filters are disabled. " +
"Set druid.javascript.enabled=true to enable (not recommended)."
);
}
}
private static boolean isJavaScriptEnabled() {
// Check configuration, default false
return config.getBoolean("druid.javascript.enabled", false);
}
Defense in Depth
- Even if an attacker bypasses empty key validation, they cannot execute JavaScript
- JavaScript evaluation engine should not be initialized if disabled
- Configuration should be immutable once the server starts
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.