Server-Side Request Forgery (SSRF) in Appsmith via WebClientUtils improper host validation
Description
Vulnerability Description
---
Vulnerability Overview
The server-side HTTP utility (WebClientUtils) in Appsmith only attempts to block user-provided URLs using a static blacklist (string matching) and does not perform consistent range-based (IP/CIDR) validation for domains. As a result, when the server makes requests using user-supplied URLs, it may allow requests to private IP ranges (e.g., 10.0.0.0/8), internal cluster service names (e.g., kubernetes.default.svc, if resolvable), or localhost (127.0.0.1) when running on a non-Docker host. This creates an SSRF attack surface that could lead to internal service access, information disclosure, or privilege escalation depending on the environment.
Vulnerable Code
private static Set<String> computeDisallowedHosts() {
final Set<String> hosts = new HashSet<>(Set.of(
"169.254.169.254", "0:0:0:0:0:0:a9fe:a9fe", "fd00:ec2:0:0:0:0:0:254", "metadata.google.internal"));
if ("1".equals(System.getenv("IN_DOCKER"))) {
hosts.add("127.0.0.1");
hosts.add("0:0:0:0:0:0:0:1");
}
return Collections.unmodifiableSet(hosts);
}computeDisallowedHosts()— The disallowed hosts list is composed only of static string values.requestFilterFn(ClientRequest request)— Only performs normalization for IP string hosts usingInetAddress.getByName, but no range check for domain-based inputs.isDisallowedAndFail(String host, Promise<?> promise)— Uses exact string matching (DISALLOWED_HOSTS.contains(host)).NameResolver(inner class) — Performs hostname resolution and checksaddress.getHostAddress()against the disallowed list, but lacks CIDR-based range blocking.
- Static blacklist definition:
```java private static Set<String> computeDisallowedHosts() { final Set<String> hosts = new HashSet<>(Set.of( "169.254.169.254", "0:0:0:0:0:0:a9fe:a9fe", "fd00:ec2:0:0:0:0:0:254", "metadata.google.internal"));
if ("1".equals(System.getenv("IN_DOCKER"))) { hosts.add("127.0.0.1"); hosts.add("0:0:0:0:0:0:0:1"); } return Collections.unmodifiableSet(hosts); } ```
- Request filter (different handling for IP vs domain):
``java private static Mono<ClientRequest> requestFilterFn(ClientRequest request) { final String host = request.url().getHost(); if (isValidIpAddress(host)) { canonicalHost = InetAddress.getByName(host).getHostAddress(); } return DISALLOWED_HOSTS.contains(canonicalHost) ? Mono.error(new UnknownHostException(HOST_NOT_ALLOWED)) : Mono.just(request); } ``
- Name resolver check (no CIDR validation):
``java protected void doResolve(String inetHost, Promise<InetAddress> promise) { if (isDisallowedAndFail(inetHost, promise)) { return; } address = SocketUtils.addressByName(inetHost); if (isDisallowedAndFail(address.getHostAddress(), promise)) { return; } promise.setSuccess(address); } ``
⇒ The blacklist relies solely on static string values (specific IPs/hosts) and lacks range-based blocking for private IP ranges, loopback, link-local, or K8s cluster IPs. Additionally, the use of the IN_DOCKER environment variable to control loopback blocking introduces environment-dependent insecurity.
PoC
---
PoC Description
A harmless test was performed using a controlled HTTP logging server to verify whether Appsmith can send requests to internal network targets.
PoC
- Run a simple HTTP logging server (Flask) on the host machine, binding to
0.0.0.0:80:
/tmp/ssrf_test_server.py executed with ~/flaskenv Python environment under root privileges:
```bash $ cat > /tmp/ssrf_test_server.py <<'PY' from flask import Flask, request app = Flask(__name__) @app.route('/', defaults={'path': ''}, methods=['GET','POST','PUT','DELETE','HEAD']) @app.route('/<path:path>', methods=['GET','POST','PUT','DELETE','HEAD']) def catch_all(path): print("== REQUEST RECEIVED ==", request.method, request.path) print("Headers:", dict(request.headers)) try: body = request.get_data(as_text=True) print("Body:", body) except Exception: pass return "OK", 200
if __name__ == "__main__": app.run(host="0.0.0.0", port=80) PY ```
- Verify accessibility from within the container:
``bash $ docker exec -it appsmith sh -c "curl -sS -m 5 -o /dev/null -w '%{http_code}\n' http://10.0.0.218/ || echo CURL_FAILED" 200 ``
- From the Appsmith UI, create a new API request with URL
http://10.0.0.218/ssrf-testand click Run.
<img width="641" height="432" alt="image" src="github.com/
- The test server logs show the request received from Appsmith:
<img width="1423" height="296" alt="image" src="github.com/
Impact
---
- Server-Side Request Forgery (SSRF): A malicious user (or compromised Appsmith action) can make Appsmith send HTTP requests to internal resources (private IP ranges, Kubernetes API, host loopback, etc.).
- Information Disclosure & Privilege Escalation: In a Kubernetes deployment, SSRF can access the K8s API (e.g.,
https://kubernetes.default.svc) and potentially retrieve ServiceAccount tokens, allowing cluster resource enumeration or manipulation. - Internal Service Abuse: Internal admin interfaces, databases, or service endpoints may be queried or modified by attackers through SSRF.
- Operational Impact: In misconfigured environments (e.g., running as root or with weak network isolation), attackers could exfiltrate configuration files, service credentials, or metadata and gain further privileges.
- Cloud Metadata Exploitation: The same behavior was observed for the cloud metadata endpoint
http://100.100.100.200/latest/meta-data/(Alibaba Cloud). This is a well-known SSRF exploitation path that allows credential theft or privilege escalation in cloud environments. (gist.github.com/thevillagehacker/ 69bc017fe68f28c3154871f4e9b94a11)
<img width="863" height="488" alt="image" src="github.com/
I want you to solve the problem based on my report.