From d1d82adca1dbb02382d7ccf49b8830816e8fa00f Mon Sep 17 00:00:00 2001 From: yehudah Date: Mon, 19 Aug 2019 20:57:47 +0000 Subject: Security issues --- Postman/Phpmailer/PostsmtpMailer.php | 3 ++ .../PostmanAbstractAuthenticationManager.php | 3 ++ .../Postman-Auth/PostmanAuthenticationManager.php | 3 ++ .../PostmanAuthenticationManagerFactory.php | 3 ++ .../PostmanGoogleAuthenticationManager.php | 3 ++ .../PostmanMicrosoftAuthenticationManager.php | 3 ++ .../PostmanNonOAuthAuthenticationManager.php | 3 ++ .../PostmanStateIdMissingException.php | 3 ++ .../PostmanYahooAuthenticationManager.php | 3 ++ .../PostmanConfigurationController.php | 21 ++++++++++++++ .../PostmanImportableConfiguration.php | 4 +++ .../PostmanRegisterConfigurationSettings.php | 6 +++- .../Postman-Configuration/PostmanSmtpDiscovery.php | 4 +++ .../Postman-Configuration/postman_manual_config.js | 2 ++ Postman/Postman-Configuration/postman_wizard.js | 22 ++++++++++----- .../Postman-Connectivity-Test/Postman-PortTest.php | 4 +++ .../PostmanConnectivityTestController.php | 18 ++++++++++++ .../Postman-Connectivity-Test/postman_port_test.js | 12 +++++--- Postman/Postman-Controller/PostmanAdminPointer.php | 4 +++ .../PostmanDashboardWidgetController.php | 4 +++ .../PostmanManageConfigurationAjaxHandler.php | 4 +++ .../PostmanWelcomeController.php | 3 ++ .../PostmanDiagnosticTestController.php | 12 ++++++++ .../Postman-Diagnostic-Test/postman_diagnostics.js | 3 +- .../PostmanEmailLogController.php | 22 +++++++++++---- .../Postman-Email-Log/PostmanEmailLogPostType.php | 3 ++ .../Postman-Email-Log/PostmanEmailLogService.php | 4 +++ Postman/Postman-Email-Log/PostmanEmailLogView.php | 10 +++++-- Postman/Postman-Mail/PostmanContactForm7.php | 3 ++ .../Postman-Mail/PostmanDefaultModuleTransport.php | 4 +++ Postman/Postman-Mail/PostmanEmailAddress.php | 4 +++ .../PostmanGmailApiModuleTransport.php | 4 +++ .../PostmanGmailApiModuleZendMailTransport.php | 4 +++ Postman/Postman-Mail/PostmanMailEngine.php | 4 +++ Postman/Postman-Mail/PostmanMailgunMailEngine.php | 4 +++ Postman/Postman-Mail/PostmanMailgunTransport.php | 4 +++ Postman/Postman-Mail/PostmanMandrillMailEngine.php | 4 +++ Postman/Postman-Mail/PostmanMandrillTransport.php | 4 +++ Postman/Postman-Mail/PostmanMessage.php | 4 +++ Postman/Postman-Mail/PostmanModuleTransport.php | 4 +++ Postman/Postman-Mail/PostmanMyMailConnector.php | 4 +++ Postman/Postman-Mail/PostmanSendGridMailEngine.php | 3 ++ Postman/Postman-Mail/PostmanSendGridTransport.php | 4 +++ .../Postman-Mail/PostmanSmtpModuleTransport.php | 4 +++ Postman/Postman-Mail/PostmanTransportRegistry.php | 4 +++ Postman/Postman-Mail/PostmanWooCommerce.php | 3 ++ Postman/Postman-Mail/PostmanZendMailEngine.php | 4 +++ ...ostmanZendMailTransportConfigurationFactory.php | 4 +++ .../PostmanSendTestEmailController.php | 9 ++++++ .../postman_send_test_email.js | 3 +- Postman/Postman.php | 33 +++------------------- Postman/PostmanAdminController.php | 4 +++ Postman/PostmanAjaxController.php | 4 +++ Postman/PostmanConfigTextHelper.php | 4 +++ Postman/PostmanEmailLogs.php | 4 ++- Postman/PostmanInputSanitizer.php | 3 ++ Postman/PostmanInstaller.php | 4 +++ Postman/PostmanLogger.php | 4 +++ Postman/PostmanMessageHandler.php | 3 ++ Postman/PostmanOAuthToken.php | 3 ++ Postman/PostmanOptions.php | 3 ++ Postman/PostmanPluginFeedback.php | 6 ++-- Postman/PostmanPreRequisitesCheck.php | 3 ++ Postman/PostmanSession.php | 3 ++ Postman/PostmanState.php | 3 ++ Postman/PostmanUtils.php | 8 ++++-- Postman/PostmanViewController.php | 14 ++++----- Postman/PostmanWpMail.php | 6 ++-- Postman/PostmanWpMailBinder.php | 3 ++ Postman/notifications/INotify.php | 3 ++ Postman/notifications/PostmanMailNotify.php | 4 ++- Postman/notifications/PostmanNotify.php | 3 ++ Postman/notifications/PostmanPushoverNotify.php | 4 ++- Postman/notifications/PostmanSlackNotify.php | 4 ++- postman-smtp.php | 3 ++ script/postman.js | 9 ++++++ 76 files changed, 356 insertions(+), 67 deletions(-) diff --git a/Postman/Phpmailer/PostsmtpMailer.php b/Postman/Phpmailer/PostsmtpMailer.php index 9eee0a7..b3a421b 100644 --- a/Postman/Phpmailer/PostsmtpMailer.php +++ b/Postman/Phpmailer/PostsmtpMailer.php @@ -1,4 +1,7 @@ '; print '
'; + + wp_nonce_field('post-smtp', 'security'); + // This prints out all hidden setting fields settings_fields( PostmanAdminController::SETTINGS_GROUP_NAME ); @@ -441,6 +448,8 @@ class PostmanConfigurationController { printf( '', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::STEALTH_MODE, $this->options->isStealthModeEnabled() ); printf( '', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::TEMPORARY_DIRECTORY, $this->options->getTempDirectory() ); + wp_nonce_field('post-smtp', 'security' ); + // display the setting text settings_fields( PostmanAdminController::SETTINGS_GROUP_NAME ); @@ -622,6 +631,9 @@ class PostmanGetHostnameByEmailAjaxController extends PostmanAbstractAjaxHandler * This Ajax function retrieves the smtp hostname for a give e-mail address */ function getAjaxHostnameByEmail() { + + check_admin_referer('post-smtp', 'security'); + $goDaddyHostDetected = $this->getBooleanRequestParameter( 'go_daddy' ); $email = $this->getRequestParameter( 'email' ); $d = new PostmanSmtpDiscovery( $email ); @@ -656,6 +668,9 @@ class PostmanManageConfigurationAjaxHandler extends PostmanAbstractAjaxHandler { * @throws Exception */ function getManualConfigurationViaAjax() { + + check_admin_referer('post-smtp', 'security'); + $queryTransportType = $this->getTransportTypeFromRequest(); $queryAuthType = $this->getAuthenticationTypeFromRequest(); $queryHostname = $this->getHostnameFromRequest(); @@ -686,6 +701,9 @@ class PostmanManageConfigurationAjaxHandler extends PostmanAbstractAjaxHandler { * The UI response is built so the user may choose a different socket with different options. */ function getWizardConfigurationViaAjax() { + + check_admin_referer('post-smtp', 'security'); + $this->logger->debug( 'in getWizardConfiguration' ); $originalSmtpServer = $this->getRequestParameter( 'original_smtp_server' ); $queryHostData = $this->getHostDataFromRequest(); @@ -895,6 +913,9 @@ class PostmanImportConfigurationAjaxController extends PostmanAbstractAjaxHandle * and pushes them into the Postman configuration screen. */ function getConfigurationFromExternalPluginViaAjax() { + + check_admin_referer('post-smtp', 'security'); + $importableConfiguration = new PostmanImportableConfiguration(); $plugin = $this->getRequestParameter( 'plugin' ); $this->logger->debug( 'Looking for config=' . $plugin ); diff --git a/Postman/Postman-Configuration/PostmanImportableConfiguration.php b/Postman/Postman-Configuration/PostmanImportableConfiguration.php index ba807d3..0008221 100644 --- a/Postman/Postman-Configuration/PostmanImportableConfiguration.php +++ b/Postman/Postman-Configuration/PostmanImportableConfiguration.php @@ -1,4 +1,8 @@ registerSettings(); + $this->registerSettings(); } /** diff --git a/Postman/Postman-Configuration/PostmanSmtpDiscovery.php b/Postman/Postman-Configuration/PostmanSmtpDiscovery.php index 44da3bb..67a58b3 100644 --- a/Postman/Postman-Configuration/PostmanSmtpDiscovery.php +++ b/Postman/Postman-Configuration/PostmanSmtpDiscovery.php @@ -1,4 +1,8 @@ '; print __( 'This test determines which well-known ports are available for Postman to use.', 'post-smtp' ); print ''; + + wp_nonce_field('post-smtp', 'security' ); + printf( '', __( 'Outgoing Mail Server Hostname', 'post-smtp' ) ); $this->port_test_hostname_callback(); submit_button( _x( 'Begin Test', 'Button Label', 'post-smtp' ), 'primary', 'begin-port-test', true ); @@ -205,6 +211,9 @@ class PostmanPortTestAjaxController { * combinations to run the connectivity test on */ function getPortsToTestViaAjax() { + + check_admin_referer('post-smtp', 'security'); + $queryHostname = PostmanUtils::getRequestParameter( 'hostname' ); // originalSmtpServer is what SmtpDiscovery thinks the SMTP server should be, given an email address $originalSmtpServer = PostmanUtils::getRequestParameter( 'original_smtp_server' ); @@ -222,6 +231,9 @@ class PostmanPortTestAjaxController { * This Ajax function retrieves whether a TCP port is open or not */ function runPortQuizTest() { + + check_admin_referer('post-smtp', 'security'); + $hostname = 'portquiz.net'; $port = intval( PostmanUtils::getRequestParameter( 'port' ) ); $this->logger->debug( 'testing TCP port: hostname ' . $hostname . ' port ' . $port ); @@ -235,6 +247,9 @@ class PostmanPortTestAjaxController { * This is called by both the Wizard and Port Test */ function runSmtpTest() { + + check_admin_referer('post-smtp', 'security'); + $hostname = trim( PostmanUtils::getRequestParameter( 'hostname' ) ); $port = intval( PostmanUtils::getRequestParameter( 'port' ) ); $transport = trim( PostmanUtils::getRequestParameter( 'transport' ) ); @@ -258,6 +273,9 @@ class PostmanPortTestAjaxController { * This Ajax function retrieves whether a TCP port is open or not */ function runSmtpsTest() { + + check_admin_referer('post-smtp', 'security'); + $hostname = trim( PostmanUtils::getRequestParameter( 'hostname' ) ); $port = intval( PostmanUtils::getRequestParameter( 'port' ) ); $transport = trim( PostmanUtils::getRequestParameter( 'transport' ) ); diff --git a/Postman/Postman-Connectivity-Test/postman_port_test.js b/Postman/Postman-Connectivity-Test/postman_port_test.js index 138b4ef..1d5c3fb 100644 --- a/Postman/Postman-Connectivity-Test/postman_port_test.js +++ b/Postman/Postman-Connectivity-Test/postman_port_test.js @@ -23,7 +23,8 @@ jQuery(document).ready(function() { var hostname = jQuery(postman_hostname_element_name).val(); var data = { 'action' : 'postman_get_hosts_to_test', - 'hostname' : hostname + 'hostname' : hostname, + 'security' : jQuery('#security').val(), }; totalPortsTested = 0; @@ -71,7 +72,8 @@ function portQuizTest(socket, hostname, port) { var data = { 'action' : 'postman_port_quiz_test', 'hostname' : hostname, - 'port' : port + 'port' : port, + '_wpnonce' : jQuery('#_wpnonce').val(), }; jQuery.post( ajaxurl, @@ -104,7 +106,8 @@ function firstServiceTest(socket, hostname, port, open) { var data = { 'action' : 'postman_test_port', 'hostname' : hostname, - 'port' : port + 'port' : port, + 'security' : jQuery('#security').val(), }; jQuery .post( @@ -197,7 +200,8 @@ function portTest3(socket, hostname, port, open) { var data = { 'action' : 'postman_test_smtps', 'hostname' : hostname, - 'port' : port + 'port' : port, + '_wpnonce' : jQuery('#_wpnonce').val(), }; jQuery .post( diff --git a/Postman/Postman-Controller/PostmanAdminPointer.php b/Postman/Postman-Controller/PostmanAdminPointer.php index 15fb52d..a05376b 100644 --- a/Postman/Postman-Controller/PostmanAdminPointer.php +++ b/Postman/Postman-Controller/PostmanAdminPointer.php @@ -1,4 +1,8 @@ + + +
+ %s', __( 'Are you having issues with Postman?', 'post-smtp' ) ); /* translators: where %1$s and %2$s are the URLs to the Troubleshooting and Support Forums on WordPress.org */ printf( '

%s

', sprintf( __( 'Please check the troubleshooting and error messages page and the support forum.', 'post-smtp' ), 'https://wordpress.org/plugins/post-smtp/other_notes/', 'https://wordpress.org/support/plugin/post-smtp' ) ); @@ -208,6 +217,9 @@ class PostmanGetDiagnosticsViaAjax { /** */ public function getDiagnostics() { + + check_admin_referer('post-smtp', 'security'); + $curl = curl_version(); $transportRegistry = PostmanTransportRegistry::getInstance(); $this->addToDiagnostics( 'Mailer', PostmanOptions::getInstance()->getSmtpMailer() ); diff --git a/Postman/Postman-Diagnostic-Test/postman_diagnostics.js b/Postman/Postman-Diagnostic-Test/postman_diagnostics.js index 4aeaa5c..140668e 100644 --- a/Postman/Postman-Diagnostic-Test/postman_diagnostics.js +++ b/Postman/Postman-Diagnostic-Test/postman_diagnostics.js @@ -6,7 +6,8 @@ jQuery(document).ready(function() { */ function getDiagnosticData() { var data = { - 'action' : 'postman_diagnostics' + 'action' : 'postman_diagnostics', + 'security' : jQuery('#security').val() }; jQuery.post(ajaxurl, data, function(response) { if (response.success) { diff --git a/Postman/Postman-Email-Log/PostmanEmailLogController.php b/Postman/Postman-Email-Log/PostmanEmailLogController.php index 79751f3..d22b265 100644 --- a/Postman/Postman-Email-Log/PostmanEmailLogController.php +++ b/Postman/Postman-Email-Log/PostmanEmailLogController.php @@ -1,4 +1,8 @@ getRequestParameter( 'email' ); @@ -200,8 +204,13 @@ class PostmanEmailLogController { // only do this for administrators if ( PostmanUtils::isAdmin() ) { $this->logger->trace( 'handling view item' ); - $postid = $_REQUEST ['email']; + $postid = absint( $_REQUEST ['email'] ); $post = get_post( $postid ); + + if ( $post->post_type !== 'postman_sent_mail' ) { + return; + } + $meta_values = PostmanEmailLogs::get_data( $postid ); // https://css-tricks.com/examples/hrs/ print '