Add IAST code injection detection for BeanShell - #12113
Conversation
|
❌ New Groovy Files Detected Please avoid introducing new
Instead, rewrite the new file(s) in Java / JUnit. See the How to Test With JUnit Guide for more details. If this PR needs an exception, add the |
|
🎯 Code Coverage (details) 🔗 Commit SHA: 53d77e6 | Docs | Datadog PR Page | Give us feedback! |
There was a problem hiding this comment.
The new BeanShell SSRF advice only recognizes lowercase http: and bsh: prefixes. A valid mixed-case URL such as HTTP://localhost:1/ is accepted by Java URL handling but bypasses this guard, so tainted Remote.eval requests can execute without an SSRF report; the fix is to compare schemes case-insensitively.
📊 Validated against 1 scenarios · Open Bits AI session
🤖 Datadog Autotest · Commit e6bd5f6 · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
🟡 Java Benchmark SLOs — Performance SLO warning (near threshold)
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e6bd5f6a0a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a748317efe
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
This is a new .groovy test file, we should try to write them in Java/JUnit 5 (see docs/how_to_test_with_junit.md), or add the tag: override groovy enforcement label if an exception is needed
There was a problem hiding this comment.
This is a new .groovy test file, we should try to write them in Java/JUnit 5 (see docs/how_to_test_with_junit.md), or add the tag: override groovy enforcement label if an exception is needed
|
#12113 (comment) and #12113 (comment) comments related with groovy test migration are optional as both extend Groovy-only Spock base classes so they aren't trivially usable from JUnit5/Java tests. Given that, staying in Groovy here seems reasonable rather than a violation to fix, but the tag: override groovy enforcement label should probably be added so the check reflects that explicitly, instead of just failing silently |
|
We need to add CODEOWNERS entry for dd-java-agent/instrumentation/beanshell-2.0/ under the ASM/IAST ownership section |
What Does This Do
Adds IAST code injection detection for BeanShell:
CODE_INJECTIONvulnerability type.beanshell-2.0instrumentation flagging untrusted input reachingInterpreter.eval(String)/eval(Reader)andRemote.eval, plus SSRF onRemote.eval's outbound URL.Motivation
BeanShell evaluates arbitrary Java-like scripts, so untrusted input reaching
evalis a code-injection (RCE) risk. There was no IAST coverage for it.Additional Notes
A few non-obvious decisions:
Stringargument ofeval, not the Reader BeanShell builds internally.bsh.*is in the IAST call-site exclusion trie, sonew StringReader(...)built insidebsh.Interpreteris never tainted. Method advice (unlike call-site) still applies tobsh.*, so inspecting the argument directly works. We deliberately did not removebsh.*from the exclusion trie (global change, re-enables call-site rewriting across all BeanShell internals for the benefit of one sink).eval(Reader)) covers caller-supplied taintedStringReader/InputStreamReader. A coverage boundary that depends on the caller building the Reader through an instrumented propagation path — not a bug.Remote.evalreports SSRF for both connecting schemes (http:andbsh:). Thehttp:branch is not covered by the existing URL/URLConnection sink: that sink is call-site based andbsh.Remoteis excluded, so it never fires inside BeanShell.2.0b4(first stableRemote.eval(String, String)signature). Muzzle covers both Maven coordinates (org.beanshell:bsh,org.apache-extras.beanshell:bsh);latestDepTestruns against2.0b6(newest on Central).Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issue; usesolvesinstead, and assign the PR milestone to the issueJira ticket: APPSEC-68816