🇰🇷 한글 설명
hustoj는 PHP/C++/MySQL/Linux 기반의 ACM/ICPC 및 NOIP 교육용 온라인 심판 시스템입니다. 모든 버전에서 CSV 주입(CSV Injection, Formula Injection) 취약점이 발견되어, 사용자 입력 데이터를 제대로 필터링하지 않아 관리자가 랭크 리스트를 엑셀 파일로 내보내고 엑셀로 열 때 악의적인 사용자가 닉네임 필드에 엑셀 수식 форму를 입력하면, 해당 수식이 실행되어任意 명령어 실행(RCE) 또는 데이터 유출이 발생할 수 있습니다.
💡 쉬운 설명
hustoj 시스템의 랭크 리스트 내보내기 기능에서 사용자 입력 데이터를 제대로 필터링하지 않아, 악의적인 사용자가 닉네임 필드에 엑셀 수식 форму를 입력하면, 해당 수식이 실행되어任意 명령어 실행이나 데이터 유출이 발생할 수 있습니다. 이는 관리자의 시스템에서 발생할 수 있습니다.
🇺🇸 원문 (English)
hustoj is an open source online judge based on PHP/C++/MySQL/Linux for ACM/ICPC and NOIP training. All versions are vulnerable to CSV Injection (Formula Injection) through the contest rank export functionality (contestrank.xls.php and admin/ranklist_export.php). The application fails to sanitize user-supplied input (specifically the "Nickname" field) before exporting it to an .xls file (which renders as an HTML table but is opened by Excel). If a malicious user sets their nickname to an Excel formula when an administrator exports and opens the rank list in Microsoft Excel, the formula will be executed. This can lead to arbitrary command execution (RCE) on the administrator's machine or data exfiltration. A fix was not available at the time of publication.
⚔️ 공격 벡터
사용자의 닉네임 필드에 엑셀 수식 입력 후, 관리자가 랭크 리스트를 엑셀 파일로 내보내고 엑셀로 열 때
🛡️ 대응 방법
hustoj 개발자 측에서 공식적인 패치가 제공될 때까지, 사용자 입력 데이터를 필터링하거나, 관리자가 랭크 리스트를 내보낼 때 엑셀 파일을 열지 않도록 주의해야 합니다.
🔧 검증 코드
로컬에서 Python이 설치되어 있어야 하며, hustoj 시스템의 도메인 주소를 verification_code의 URL에代入하여 실행합니다. 결과로 {'result': '취약', 'reason': 'Nickname 필드가 노출됨'}이 출력되면, 해당 시스템에 취약점이 존재하는 것입니다.
python -c "import requests; r = requests.get('https://example.com/contestrank.xls.php'); print('Nickname' in r.text)" # hustoj 시스템의 contestrank.xls.php 페이지에서 Nickname 필드가 노출되는지 확인