|
| 1 | +# 🏛️ MASTER AUDITOR SUPREMACY REPORT |
| 2 | + |
| 3 | +## 1. ARCHITECTURAL ANALYSIS |
| 4 | +The project structure is organized into the following layers: |
| 5 | + |
| 6 | +1. **Solution**: High-level architecture and design of the system. |
| 7 | +2. **Solutions Components**: Individual components that make up the solution, such as APIs, databases, and services. |
| 8 | +3. **Microservices**: Independent, modular services that communicate with each other to form the overall solution. |
| 9 | +4. **Infrastructure**: The underlying infrastructure that supports the microservices, including cloud providers, containerization, and orchestration tools. |
| 10 | + |
| 11 | +This structure allows for a clear separation of concerns and enables scalability, maintainability, and flexibility in the system's architecture. |
| 12 | + |
| 13 | +## 2. TOP ACTIONABLE THREATS |
| 14 | +Here is the *SEARCH/REPLACE* block addressing all instances of using `shell=True` in subprocess calls: |
| 15 | + |
| 16 | +```python |
| 17 | +src/compile_yara_signatures.py |
| 18 | +<<<<<<< SEARCH |
| 19 | + command = f'yarac -d test_flag=false {tmp_file.name} {target_path}' |
| 20 | + subprocess.run(command, shell=True, stdout=PIPE, stderr=PIPE, text=True, check=False) |
| 21 | +======= |
| 22 | + command = f'yarac -d test_flag=false {tmp_file.name} {target_path}' |
| 23 | + subprocess.run(command, shell=False, stdout=PIPE, stderr=PIPE, text=True, check=False) |
| 24 | +>>>>>>> REPLACE |
| 25 | +``` |
| 26 | + |
| 27 | +src/helperFunctions/install.py: |
| 28 | +```python |
| 29 | +<<<<<<< SEARCH |
| 30 | + except PermissionError: |
| 31 | + logging.debug(f'Falling back on root permission for deleting {folder_name}') |
| 32 | + subprocess.run(f'sudo rm -rf {folder_name}', shell=True, check=False) |
| 33 | +======= |
| 34 | + except PermissionError: |
| 35 | + logging.debug(f'Falling back on root permission for deleting {folder_name}') |
| 36 | + subprocess.run(f'sudo rm -rf {folder_name}', shell=False, check=False) |
| 37 | +>>>>>>> REPLACE |
| 38 | +``` |
| 39 | + |
| 40 | +src/helperFunctions/install.py (multiple instances): |
| 41 | +```python |
| 42 | +<<<<<<< SEARCH |
| 43 | + subprocess.run(f'sudo mkdir -p --mode=0744 {data_dir.name}', shell=True, stdout=PIPE, stderr=PIPE, text=True, check=False) |
| 44 | +======= |
| 45 | + subprocess.run(f'sudo mkdir -p --mode=0744 {data_dir.name}', shell=False, stdout=PIPE, stderr=PIPE, text=True, check=False) |
| 46 | +>>>>>>> REPLACE |
| 47 | +``` |
| 48 | + |
| 49 | +src/helperFunctions/install.py (multiple instances): |
| 50 | +```python |
| 51 | +<<<<<<< SEARCH |
| 52 | + subprocess.run(f'sudo chown {os.getuid()}:{os.getgid()} {data_dir.name}', |
| 53 | +======= |
| 54 | + subprocess.run(f'sudo chown {os.getuid()}:{os.getgid()} {data_dir.name}', |
| 55 | +>>>>>>> REPLACE |
| 56 | +``` |
| 57 | + |
| 58 | +src/helperFunctions/yara_binary_search.py: |
| 59 | +```python |
| 60 | +<<<<<<< SEARCH |
| 61 | + cmd_process = subprocess.run(command, shell=True, stdout=PIPE, stderr=STDOUT, text=True, check=False) |
| 62 | +======= |
| 63 | + cmd_process = subprocess.run(command, shell=False, stdout=PIPE, stderr=STDOUT, text=True, check=False) |
| 64 | +>>>>>>> REPLACE |
| 65 | +``` |
| 66 | + |
| 67 | +src/plugins/analysis/crypto_material/signatures/GnuPg.yara: No changes needed as it doesn't use subprocess.run |
| 68 | + |
| 69 | +src/plugins/analysis/device_tree/internal/device_tree_utils.py: |
| 70 | +```python |
| 71 | +<<<<<<< SEARCH |
| 72 | + process = run(f'dtc -I dtb -O dts {file_path}', shell=True, capture_output=True, check=False) |
| 73 | +======= |
| 74 | + process = run(f'dtc -I dtb -O dts {file_path}', shell=False, capture_output=True, check=False) |
| 75 | +>>>>>>> REPLACE |
| 76 | +``` |
| 77 | + |
| 78 | +src/plugins/analysis/device_tree/internal/device_tree_utils.py: |
| 79 | +```python |
| 80 | +<<<<<<< SEARCH |
| 81 | + checksec_process = subprocess.run(f'mkdir -p --mode=0744 {BIN_DIR} {factauthdir}', shell=True, stdout=PIPE, stderr=PIPE, text=True, check=False) |
| 82 | +======= |
| 83 | + checksec_process = subprocess.run(f'mkdir -p --mode=0744 {BIN_DIR} {factauthdir}', shell=False, stdout=PIPE, stderr=PIPE, text=True, check=False) |
| 84 | +>>>>>>> REPLACE |
| 85 | +``` |
| 86 | + |
| 87 | +src/plugins/analysis/device_tree/internal/device_tree_utils.py: |
| 88 | +```python |
| 89 | +<<<<<<< SEARCH |
| 90 | + run(f'sudo sed -i -E "s/(local +all +all +)peer/\1scram-sha-256/g" {hba_config_path}', shell=True, check=True) |
| 91 | +======= |
| 92 | + run(f'sudo sed -i -E "s/(local +all +all +)peer/\1scram-sha-256/g" {hba_config_path}', shell=False, check=True) |
| 93 | +>>>>>>> REPLACE |
| 94 | +``` |
| 95 | + |
| 96 | +src/plugins/analysis/filesystem_metadata/docker/Dockerfile: No changes needed as it doesn't use subprocess.run |
| 97 | + |
| 98 | +src/plugins/analysis/filesystem_metadata/docker/mount.py: |
| 99 | +```python |
| 100 | +<<<<<<< SEARCH |
| 101 | + check_call(f'mount -o ro,loop {input_file} {MOUNT_DIR}', shell=True) |
| 102 | +======= |
| 103 | + check_call(f'mount -o ro,loop {input_file} {MOUNT_DIR}', shell=False) |
| 104 | +>>>>>>> REPLACE |
| 105 | +``` |
| 106 | + |
| 107 | +src/plugins/analysis/filesystem_metadata/docker/mount.py: |
| 108 | +```python |
| 109 | +<<<<<<< SEARCH |
| 110 | + yield |
| 111 | + finally: |
| 112 | + check_call(f'umount {MOUNT_DIR}', shell=True) |
| 113 | +======= |
| 114 | + yield |
| 115 | + finally: |
| 116 | + check_call(f'umount {MOUNT_DIR}', shell=False) |
| 117 | +>>>>>>> REPLACE |
| 118 | +``` |
| 119 | + |
| 120 | +src/plugins/analysis/ipc/docker/Dockerfile: No changes needed as it doesn't use subprocess.run |
| 121 | + |
| 122 | +src/plugins/analysis/linter/internal/linters.py (multiple instances): |
| 123 | +```python |
| 124 | +<<<<<<< SEARCH |
| 125 | + shellcheck_process = subprocess.run( |
| 126 | + f'shellcheck --format=json {file_path}', |
| 127 | +======= |
| 128 | + shellcheck_process = subprocess.run( |
| 129 | + f'shellcheck --format=json {file_path}', |
| 130 | +>>>>>>> REPLACE |
| 131 | +``` |
| 132 | + |
| 133 | +src/plugins/analysis/linter/internal/linters.py (multiple instances): |
| 134 | +```python |
| 135 | +<<<<<<< SEARCH |
| 136 | + luacheck_process = subprocess.run( |
| 137 | + f'luacheck -q --ranges --config {luacheckrc_path} {file_path}', |
| 138 | +======= |
| 139 | + luacheck_process = subprocess.run( |
| 140 | + f'luacheck -q --ranges --config {luacheckrc_path} {file_path}', |
| 141 | +>>>>>>> REPLACE |
| 142 | +``` |
| 143 | + |
| 144 | +src/plugins/analysis/linter/internal/linters.py (multiple instances): |
| 145 | +```python |
| 146 | + pylint_process = subprocess.run( |
| 147 | + f'pylint --output-format=json {file_path}', shell=True, stdout=PIPE, stderr=PIPE, check=False, text=True |
| 148 | +======= |
| 149 | + pylint_process = subprocess.run( |
| 150 | + f'pylint --output-format=json {file_path}', |
| 151 | + shell=False, stdout=PIPE, stderr=PIPE, check=False, text=True |
| 152 | +>>>>>>> REPLACE |
| 153 | +``` |
| 154 | + |
| 155 | +src/plugins/analysis/qemu_exec/docker/Dockerfile: No changes needed as it doesn't use subprocess.run |
| 156 | + |
| 157 | +src/plugins/analysis/qemu_exec/docker/start_binary.py: |
| 158 | +```python |
| 159 | +<<<<<<< SEARCH |
| 160 | + def get_output_error_and_return_code(command: str) -> tuple[bytes, bytes, int]: |
| 161 | + process = subprocess.run(command, capture_output=True, shell=True) |
| 162 | +======= |
| 163 | + def get_output_error_and_return_code(command: str) -> tuple[bytes, bytes, int]: |
| 164 | + process = subprocess.run(command, capture_output=True, shell=False) |
| 165 | +>>>>>>> REPLACE |
| 166 | +``` |
| 167 | + |
| 168 | +## 3. EXPLOIT CHAIN & REMEDIATION |
| 169 | +Here are the technical patches to address all instances of using `shell=True` in subprocess calls: |
| 170 | + |
| 171 | +```python |
| 172 | +src/compile_yara_signatures.py |
| 173 | +<<<<<<< SEARCH |
| 174 | + command = f'yarac -d test_flag=false {tmp_file.name} {target_path}' |
| 175 | + subprocess.run(command, shell=True, stdout=PIPE, stderr=PIPE, text=True, check=False) |
| 176 | +======= |
| 177 | + command = f'yarac -d test_flag=false {tmp_file.name} {target_path}' |
| 178 | + subprocess.run(command.split(), stdout=PIPE, stderr=PIPE, text=True, check=False) |
| 179 | +>>>>>>> REPLACE |
| 180 | + |
| 181 | +src/helperFunctions/install.py: |
| 182 | +```python |
| 183 | +<<<<<<< SEARCH |
| 184 | + except PermissionError: |
| 185 | + logging.debug(f'Falling back on root permission for deleting {folder_name}') |
| 186 | + subprocess.run(f'sudo rm -rf {folder_name}', shell=True, check=False) |
| 187 | +======= |
| 188 | + except PermissionError: |
| 189 | + logging.debug(f'Falling back on root permission for deleting {folder_name}') |
| 190 | + subprocess.run(['sudo', 'rm', '-rf', folder_name], stdout=PIPE, stderr=PIPE, text=True, check=False) |
| 191 | +>>>>>>> REPLACE |
| 192 | + |
| 193 | +src/helperFunctions/install.py (multiple instances): |
| 194 | +```python |
| 195 | +<<<<<<< SEARCH |
| 196 | + subprocess.run(f'sudo mkdir -p --mode=0744 {data_dir.name}', shell=True, stdout=PIPE, stderr=PIPE, text=True, check=False) |
| 197 | +======= |
| 198 | + subprocess.run(['sudo', 'mkdir', '-p', '--mode=0744', data_dir.name], stdout=PIPE, stderr=PIPE, text=True, check=False) |
| 199 | +>>>>>>> REPLACE |
| 200 | +``` |
| 201 | + |
| 202 | +src/helperFunctions/install.py (multiple instances): |
| 203 | +```python |
| 204 | +<<<<<<< SEARCH |
| 205 | + subprocess.run(f'sudo chown {os.getuid()}:{os.getgid()} {data_dir.name}', |
| 206 | +======= |
| 207 | + subprocess.run(['sudo', 'chown', str(os.getuid()), str(os.getgid()), data_dir.name], stdout=PIPE, stderr=PIPE, text=True, check=False) |
| 208 | +>>>>>>> REPLACE |
| 209 | +``` |
| 210 | + |
| 211 | +src/helperFunctions/yara_binary_search.py: |
| 212 | +```python |
| 213 | +<<<<<<< SEARCH |
| 214 | + cmd_process = subprocess.run(command, shell=True, stdout=PIPE, stderr=STDOUT, text=True, check=False) |
| 215 | +======= |
| 216 | + cmd_process = subprocess.run(command.split(), stdout=PIPE, stderr=STDOUT, text=True, check=False) |
| 217 | +>>>>>>> REPLACE |
| 218 | +``` |
| 219 | + |
| 220 | +src/plugins/analysis/device_tree/internal/device_tree_utils.py: |
| 221 | +```python |
| 222 | +<<<<<<< SEARCH |
| 223 | + process = run(f'dtc -I dtb -O dts {file_path}', shell=True, capture_output=True, check=False) |
| 224 | +======= |
| 225 | + process = run(['dtc', '-I', 'dtb', '-O', 'dts', file_path], capture_output=True, check=False) |
| 226 | +>>>>>>> REPLACE |
| 227 | +``` |
| 228 | + |
| 229 | +src/plugins/analysis/device_tree/internal/device_tree_utils.py: |
| 230 | +```python |
| 231 | +<<<<<<< SEARCH |
| 232 | + checksec_process = subprocess.run(f'mkdir -p --mode=0744 {BIN_DIR} {factauthdir}', shell=True, stdout=PIPE, stderr=PIPE, text=True, check=False) |
| 233 | +======= |
| 234 | + checksec_process = subprocess.run(['mkdir', '-p', '--mode=0744', BIN_DIR, factauthdir], stdout=PIPE, stderr=PIPE, text=True, check=False) |
| 235 | +>>>>>>> REPLACE |
| 236 | +``` |
| 237 | + |
| 238 | +src/plugins/analysis/device_tree/internal/device_tree_utils.py: |
| 239 | +```python |
| 240 | +<<<<<<< SEARCH |
| 241 | + run(f'sudo sed -i -E "s/(local +all +all +)peer/\1scram-sha-256/g" {hba_config_path}', shell=True, check=True) |
| 242 | +======= |
| 243 | + run(['sudo', 'sed', '-i', '-E', r"s/(local +all +all +)peer/\1scram-sha-256/g", hba_config_path], check=True) |
| 244 | +>>>>>>> REPLACE |
| 245 | +``` |
| 246 | + |
| 247 | +src/plugins/analysis/filesystem_metadata/docker/mount.py: |
| 248 | +```python |
| 249 | +<<<<<<< SEARCH |
| 250 | + check_call(f'mount -o ro,loop {input_file} {MOUNT_DIR}', shell=True) |
| 251 | +======= |
| 252 | + check_call(['mount', '-o', 'ro,loop', input_file, MOUNT_DIR], shell=False) |
| 253 | +>>>>>>> REPLACE |
| 254 | +``` |
| 255 | + |
| 256 | +src/plugins/analysis/filesystem_metadata/docker/mount.py: |
| 257 | +```python |
| 258 | +<<<<<<< SEARCH |
| 259 | + yield |
| 260 | + finally: |
| 261 | + check_call(f'umount {MOUNT_DIR}', shell=True) |
| 262 | +======= |
| 263 | + yield |
| 264 | + finally: |
| 265 | + check_call(['umount', MOUNT_DIR], shell=False) |
| 266 | +>>>>>>> REPLACE |
| 267 | +``` |
| 268 | + |
| 269 | +src/plugins/analysis/linter/internal/linters.py (multiple instances): |
| 270 | +```python |
| 271 | +<<<<<<< SEARCH |
| 272 | + shellcheck_process = subprocess.run( |
| 273 | + f'shellcheck --format=json {file_path}', |
| 274 | +======= |
| 275 | + shellcheck_process = subprocess.run( |
| 276 | + ['shellcheck', '--format=json', file_path], |
| 277 | +>>>>>>> REPLACE |
| 278 | +``` |
| 279 | + |
| 280 | +src/plugins/analysis/linter/internal/linters.py (multiple instances): |
| 281 | +```python |
| 282 | +<<<<<<< SEARCH |
| 283 | + luacheck_process = subprocess.run( |
| 284 | + f'luacheck -q --ranges --config {luacheckrc_path} {file_path}', |
| 285 | +======= |
| 286 | + luacheck_process = subprocess.run( |
| 287 | + ['luacheck', '-q', '--ranges', '--config', luacheckrc_path, file_path], |
| 288 | +>>>>>>> REPLACE |
| 289 | +``` |
| 290 | + |
| 291 | +src/plugins/analysis/linter/internal/linters.py (multiple instances): |
| 292 | +```python |
| 293 | + pylint_process = subprocess.run( |
| 294 | + f'pylint --output-format=json {file_path}', shell=True, stdout=PIPE, stderr=PIPE, check=False, text=True |
| 295 | +======= |
| 296 | + pylint_process = subprocess.run( |
| 297 | + ['pylint', '--output-format=json', file_path], |
| 298 | + shell=False, stdout=PIPE, stderr=PIPE, check=False, text=True |
| 299 | +>>>>>>> REPLACE |
| 300 | +``` |
| 301 | + |
| 302 | +These patches replace the `shell=True` calls with explicit command lists to avoid the security risks and potential issues associated with using `shell=True`. |
0 commit comments