Apache Druid Security Patching
SkillSecuritySecurity patching for Apache Druid - covers JavaScript execution vulnerabilities, sampler endpoint protection, and filter validation patterns.
Available today. Use it from your connected AI after setup.
No other account needed.
Connect ahel once, and every AI you use reads what you have installed.
Then ask your AI: use the Apache Druid Security Patching skill
What this skill tells your AI
The instructions your AI receives, as published by cxcscmu/skilllearnbench in skills/b1-one-shot-claude-sonnet-4-6/fix-security-bug/apache-druid-security/SKILL.md and read by ahel’s review.
Overview
Apache Druid is a real-time analytics database. Key security concern: JavaScript execution via filter/transform specs in ingestion tasks and the sampler endpoint.
CVE-2021-25646 - JavaScript Filter RCE
Vulnerability Mechanism
JavaScriptDimFilteruses@JacksonInject JavaScriptConfig configto get JavaScript enabled status@JacksonInjectwith defaultvalue=""allows Jackson to fall back to JSON input when the injectable value isn't found or whenuseInput=OptBoolean.DEFAULT- Exploit: Send
"": {"enabled": true}in the filter JSON to inject a permissiveJavaScriptConfig - This bypasses the server-level
druid.javascript.enabled=falsesetting - The Rhino JS engine has no
ClassShutter→ full Java class access →Runtime.exec()possible
Affected Files
processing/src/main/java/org/apache/druid/query/filter/JavaScriptDimFilter.javaindexing-service/src/main/java/org/apache/druid/indexing/overlord/sampler/InputSourceSampler.javacore/src/main/java/org/apache/druid/js/JavaScriptConfig.java
Fix 1: Block JSON Override of @JacksonInject (Root Cause)
// In JavaScriptDimFilter constructor, add useInput = OptBoolean.FALSE:
import com.fasterxml.jackson.annotation.OptBoolean;
@JsonCreator
public JavaScriptDimFilter(
@JsonProperty("dimension") String dimension,
@JsonProperty("function") String function,
@JsonProperty("extractionFn") @Nullable ExtractionFn extractionFn,
@JsonProperty("filterTuning") @Nullable FilterTuning filterTuning,
@JacksonInject(useInput = OptBoolean.FALSE) JavaScriptConfig config // KEY FIX
)
Fix 2: Server-Side Validation in Sampler (Defense in Depth)
// In InputSourceSampler.java - inject JavaScriptConfig via Guice:
import com.google.inject.Inject;
import org.apache.druid.js.JavaScriptConfig;
import org.apache.druid.query.filter.JavaScriptDimFilter;
public class InputSourceSampler {
private final JavaScriptConfig javascriptConfig;
@Inject
public InputSourceSampler(JavaScriptConfig javascriptConfig) {
this.javascriptConfig = javascriptConfig;
}
public SamplerResponse sample(...) {
// Add BEFORE processing:
if (!javascriptConfig.isEnabled()) {
validateNoJavaScriptFilter(nonNullDataSchema.getTransformSpec().getFilter());
}
}
private void validateNoJavaScriptFilter(@Nullable DimFilter filter) {
if (filter instanceof JavaScriptDimFilter) {
throw new SamplerException("JavaScript is disabled. Set druid.javascript.enabled=true to enable.");
}
// Also handle composite filters (AND/OR/NOT)
}
}
Key Architecture Notes
JavaScript Execution Path
POST /druid/indexer/v1/sampler→SamplerResource.post()- →
IndexTaskSamplerSpec.sample()→InputSourceSampler.sample() - →
dataSchema.getTransformSpec().decorate(reader) - →
TransformingInputSourceReader→Transformer - →
filter.toFilter()→JavaScriptDimFilter.getPredicateFactory()← security check is here
Guice-Managed Components
InputSourceSampleris bound asSingletoninSamplerModuleJavaScriptConfigis bound inJavaScriptModulefromdruid.javascriptconfig- Jackson
@JacksonInjectuses Guice'sInjectableValueswhen available
Build Command
cd /root/druid
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
Signals
- GitHub stars
- 83
- Forks
- 5
- Last commit
- Jul 2026
Advanced
- Catalog kind
- skill
- Gateway key
apache-druid-security- Source
- github.com/cxcscmu/skilllearnbench