Several DataWeave functions execute code or fetch remote content. When their parameters come from user input, an attacker can run arbitrary code in your connector or reach internal services.
Don't Evaluate Untrusted Code
DataWeave’s eval(), run(), evalUrl(), and runUrl() functions execute DataWeave code from strings or URLs. If the script or URL parameter is user-controlled, an attacker can execute arbitrary DataWeave code from a remote location.
Do: Run scripts only from your own repository or trusted sources before you pass them into eval, run, evalUrl, or runUrl.
Don’t: Pass user-provided URLs or script bodies directly into these functions.
read(…, “application/java”) deserializes Java objects from raw bytes. Attacker-controlled serialized data can trigger gadget-chain attacks in vulnerable classpaths.
Do: Deserialize Java objects only from sources that you trust.
Don’t: Call read(…, “application/java”) on user input.
readUrl() accepts http://, https://, and classpath:// URLs.
With a user-controlled URL, an attacker can target internal services, cloud instance-metadata endpoints, or private IPs.
Do: Maintain an allowlist of schemes and hosts before you pass a URL into readUrl().
Don’t: Accept file://, classpath://, or internal IPs from request parameters.
Example
Vulnerable
1readUrl(payload.url, "application/json")
Secure
1var u = parseURI(payload.url default "")2var allowedHosts = ["api.example.com"]3---4if ((u.isValid default false) and ((u.scheme default "") == "https") and ((u.host default "") in allowedHosts))5 readUrl(payload.url, "application/json")6else7 fail("blocked-url")
Constrain Classpath URL Fetches
readUrl() with classpath:// resolves against the project classpath. With user-controlled path strings, an attacker can discover internal configuration files and property files inside your connector’s resources.
Do: Validate every classpath path against an explicit allowlist before you fetch it.
Don’t: Concatenate user input into a classpath:// URL.