agentsclimarketplace

Druid javascript security

Skill cxcscmu/SkillLearnBench/skills/b1-one-shot-claude-haiku-4-5/fix-security-bug/druid-javascript-security

[COLM'26] SkillLearnBench is the first benchmark for evaluating continual learning methods that automatically generate agent skills.

Install
npx -y skills add cxcscmu/SkillLearnBench --skill druid-javascript-security

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

What its author says it does

Copied from the file, not written here

Securing Apache Druid's JavaScript execution engine against code injection and security bypass attacks.

SKILL.md

2.8 KB, 583 tokens by cl100k_base, as published. Nobody here has run it

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 enabled flag 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.

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.