Skip to content

Commit 59fdd51

Browse files
Merge pull request sonic-net#107 from Kalimuthu-Velappan/PENTEST
Initial changes
2 parents 53f0b60 + 11252aa commit 59fdd51

File tree

1 file changed

+151
-0
lines changed

1 file changed

+151
-0
lines changed

system/penetration-test-fixes.md

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
# SONiC Penetration Test Fixes
2+
3+
Information on fixes for some of the security vulnerabilities reported by the eBay Red team as part of their SONiC Network OS PenTest report
4+
5+
# High Level Design Document
6+
7+
#### Rev 0.1
8+
9+
# Table of Contents
10+
* [List of Tables](#list-of-tables)
11+
* [Revision](#revision)
12+
* [About This Manual](#about-this-manual)
13+
* [Scope](#scope)
14+
* [Definition/Abbreviation](#definitionabbreviation)
15+
* [Feature Overview](#FeatureOverview)
16+
* [Requirements](#Requirements)
17+
* [Design](#Design)
18+
* [Unit Test](#UnitTest)
19+
20+
21+
# List of Tables
22+
[Table 1: Abbreviations](#table-1-abbreviations)
23+
24+
# Revision
25+
| Rev | Date | Author | Change Description |
26+
|:---:|:-----------:|:------------------:|-----------------------------------|
27+
| 0.1 | 28/12/2020 | Senthil | Initial version |
28+
29+
# About this Manual
30+
31+
This document provides information on fixes for some of the security vulnerabilities reported by the eBay Red team as part of their SONiC Network OS PenTest report.
32+
33+
# Scope
34+
35+
This document describes the high-level design on fixes for some of the security vulnerabilities reported by the eBay Red team as part of their SONiC Network OS PenTest report. This document focuses only the following three main categroies of issues reported.
36+
37+
1. Docker running with privilage access.
38+
2. Sudo entry with wildcard expression which allows privileage escalation.
39+
3. Redis database accesss without authentication.
40+
41+
Other issues that are reported as part of penetration tests are not covered in this document.
42+
43+
# Definition/Abbreviation
44+
45+
### Table 1: Abbreviations
46+
| **Term** | **Meaning** |
47+
|-----------------------|-------------------------------------|
48+
| ODM | Original Design Manufacturer |
49+
| ACL | Access Control List |
50+
| ENV | Environment variable |
51+
52+
# 1 Feature Overview
53+
54+
This document provides information on fixes for some of the security vulnerabilities reported by the eBay Red team as part of their SONiC Network OS PenTest report. The PenTest report provides detailed information about each vulnerability and possible solutions to counter the identified issues. This document can be used as a response from the Enterprise SONiC team to overcome the identified vulnerabilities. These changes are being proposed for the SONiC 3.2.0 release.
55+
56+
57+
## 1.1 Requirements
58+
59+
### 1.1.1 Functional Requirements
60+
61+
Address the three major vulnerabilities reported in PenTest by ebay.
62+
63+
- It should allow only the authenticated application or user to access the redis database.
64+
- Entries in the sudo file should have a explicit command specification that requires prvilege access and all the command that uses wildcard(*) should be replaced with specific instance of required command.
65+
- All the container privilege access should be removed and should run isolated from the host environment, Any container requires specicial access from host should use sys capability feature instead of privilege access.
66+
67+
### 1.1.2 Configuration and Management Requirements
68+
- NA
69+
70+
### 1.1.3 Scalability Requirements
71+
- NA
72+
73+
### 1.1.4 Warm/fast/cold Boot Requirements
74+
- NA
75+
76+
# 2 Design
77+
78+
### 2.1 Sudo entry with wildcard expression leading to privilege escalation.
79+
80+
##### 1. sudo Entry "/usr/bin/docker exec * ps aux" leading to privilege escalation
81+
82+
- The intention for the wildcard character ‘*’ specified in the sudo entry is to allow the “ps aux” command to be executed in all docker containers. However, the wildcard character ‘*’ can be used by a hacker to inject a crafted command to get access to the shell inside the container.
83+
84+
##### Command to check the vulnerability
85+
86+
- sudo docker exec -it mgmt-framework sh -c "/bin/bash;# ps aux"
87+
88+
##### Solution
89+
90+
- Removed sudo entry of "docker exec * ps aux" in the sudoers file and replaced it with specific "docker exec {{container-name}} ps aux" commands.
91+
92+
##### 2. sudo Entry "/usr/bin/vtysh -c show *" can be used to do a configuration write by a non sudoer
93+
94+
- The vtysh command allows a user to execute multiple commands using chained -c command arguments. The wildcard character “*” used in the sudo entry can be used by a hacker to substitute it with configuration commands while using a show command in the beginning to match the sudo entry. The vtysh is not validating user input from a security standpoint and it is expected that the sudo entry take care of it which is being bypassed due to the use of ‘*’.
95+
96+
##### Command to check the vulnerability
97+
98+
- sudo vtysh -c 'show version' -c 'configure terminal' -c 'interface Ethernet0' -c 'exit' -c 'exit' -E
99+
100+
101+
##### Solution
102+
- vtysh script has been modified to validate user input and allow only show commands. The command exits with an error if any other vty command is used.
103+
104+
##### 3. sudo entry "/bin/cat /var/log/syslog" arbitrary file read*
105+
106+
- A non-sudo user is able to read the contents of /etc/shadow even though the file permissions of /etc/shadow file do not allow the unprivileged to view this file.
107+
108+
##### Command to check the vulnerability
109+
- sudo /bin/cat /var/log/syslog.123 /etc/shadow
110+
111+
##### Solution
112+
- The sudo entry has been modified to specifically allow cat of only syslog and syslog.1
113+
114+
## 2.2 Local state/config Redis database accessible without authentication
115+
- The local Redis database acts as a centralized location for storing device state and configuration. The Redis server runs inside the database container, and the user is required to execute redis-cli inside the database container to access the Redis database, which requires admin privilege. However, the Redis database also listens locally on TCP6379 without authentication, allowing any user to read/write to the Redis database.
116+
117+
##### Vulnerability check
118+
- The Redis server listens on TCP6379 on localhost. The standard redis-cli client binary is uploaded to host OS for accessing Redis database via TCP6379 without authentication.
119+
120+
##### Solution
121+
- Enabled redis db authentication by default to prevent read/write access from local unprivileged users.
122+
- Random passwords generated on every system boot up to be stored in a file shared across linux host and all containers with appropriate permissions set.
123+
- All Clients(cpp,python,go variants) to pass in the password parameter(read from the file) while accessing the redis db.
124+
- redis-cli client binary internally parses the password from an env variable (REDISCLI_AUTH) set.
125+
- Non-sudo users direct read/write access to redis db is prevented but the basic fixed show commands which depend on the redis db are added to sudoers file.
126+
127+
## 2.3 Docker Containers Running in Privileged Mode
128+
129+
- Each service is running inside their own docker container in privileged mode. The privileged mode container doesn’t offer security benefit of isolating but have full read/write access to host OS resources, such as file system, allowing container escape or elevate privilege on the host OS. The docker socket on the host OS is also exposed inside mgmt-framework container, giving the container full control over all other docker containers and host OS.
130+
131+
##### Check the vulnerability
132+
- for c in $(docker ps --format '{{.Names}}'); do printf "$c:"; docker inspect $c --format {{.HostConfig.Privileged}}'; done
133+
134+
##### Solution
135+
136+
- All the container privilege access should be removed and should run isolated from the host environment, Any container requires specicial access from host should use sys capability feature instead of privilege access.
137+
138+
139+
# 3 Unit Test
140+
141+
|SNO| Testcase | Result |
142+
|---|------------------------------------------------------------------| ------- |
143+
| 1 | Verify the dockeer exec cmd from non sudo user | |
144+
| 1 | Verify the the vtysh show command from non sudo user | |
145+
| 1 | Verify the syslog file asscess from non sudo user | |
146+
| 2 | Verify the database access with the authentication | |
147+
| 2 | Verify the database access without the authentication | |
148+
| 3 | Verify the contianer isolation with capability support | |
149+
150+
151+

0 commit comments

Comments
 (0)