diff --git a/core/modules/help/lib/Drupal/help/Tests/HelpTest.php b/core/modules/help/lib/Drupal/help/Tests/HelpTest.php
index dd21f0e..f8b1ee3 100644
--- a/core/modules/help/lib/Drupal/help/Tests/HelpTest.php
+++ b/core/modules/help/lib/Drupal/help/Tests/HelpTest.php
@@ -48,7 +48,7 @@ public function setUp() {
     $this->getModuleList();
 
     // Create users.
-    $this->adminUser = $this->drupalCreateUser(array('access administration pages', 'view the administration theme', 'administer permissions'));
+    $this->adminUser = $this->drupalCreateUser(array('access administration pages', 'view the administration theme', 'administer permissions', 'administer themes'));
     $this->anyUser = $this->drupalCreateUser(array());
   }
 
@@ -113,4 +113,31 @@ protected function getModuleList() {
     }
     return $modules;
   }
+
+  /**
+   * Ensures that the help text block is only shown for users with access.
+   */
+  public function testHelpBlockVisibility() {
+    // Log in and test that the settings form for a non-existent theme returns a
+    // 404 and that the help block is not displayed.
+    $this->drupalLogin($this->adminUser);
+    $this->drupalGet('admin/appearance/settings/' . $this->randomName());
+    $this->assertResponse(404, 'The theme settings form for a non-existent theme could not be found.');
+    $help_block = $this->xpath("//div[@id='block-help']");
+    $this->assertFalse($help_block, 'The help block is not displayed.');
+    $this->drupalLogout();
+
+    // Test a non-existent theme settings form and ensure that it returns a 403
+    // for an unprivileged user and that the help block is not displayed.
+    $this->drupalGet('admin/appearance/settings/' . $this->randomName());
+    $this->assertResponse(403);
+    $help_block = $this->xpath("//div[@id='block-help']");
+    $this->assertFalse($help_block, 'The help block is not displayed.');
+
+    // Test block admin page and ensure the help block is not displayed.
+    $this->drupalGet('admin/structure/block');
+    $this->assertResponse(403);
+    $this->assertFalse($help_block, 'The help block is not displayed.');
+  }
+
 }
diff --git a/core/modules/system/lib/Drupal/system/Plugin/Block/SystemHelpBlock.php b/core/modules/system/lib/Drupal/system/Plugin/Block/SystemHelpBlock.php
index f669e61..664af82 100644
--- a/core/modules/system/lib/Drupal/system/Plugin/Block/SystemHelpBlock.php
+++ b/core/modules/system/lib/Drupal/system/Plugin/Block/SystemHelpBlock.php
@@ -11,8 +11,10 @@
 use Drupal\Core\Extension\ModuleHandlerInterface;
 use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
 use Drupal\Core\Session\AccountInterface;
+use Symfony\Component\Debug\Exception\FlattenException;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\Response;
 
 /**
  * Provides a 'System Help' block.
@@ -78,6 +80,10 @@ public static function create(ContainerInterface $container, array $configuratio
    * {@inheritdoc}
    */
   public function access(AccountInterface $account) {
+    $exception = $this->request->attributes->get('exception');
+    if ($exception instanceof FlattenException && $exception->getStatusCode() >= Response::HTTP_BAD_REQUEST) {
+      return FALSE;
+    }
     $this->help = $this->getActiveHelp($this->request);
     return (bool) $this->help;
   }
@@ -90,13 +96,9 @@ public function access(AccountInterface $account) {
    */
   protected function getActiveHelp(Request $request) {
     $output = '';
-    $router_path = $request->attributes->get('_system_path');
-    // We will always have a path unless we are on a 403 or 404.
-    if (!$router_path) {
-      return '';
-    }
 
-    $arg = drupal_help_arg(explode('/', $router_path));
+    $router_path = trim($request->getPathInfo(), '/');
+    $arg = drupal_help_arg(explode('/', $request->attributes->get('_system_path')));
 
     foreach ($this->moduleHandler->getImplementations('help') as $module) {
       $function = $module . '_help';
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index 5e23103..dee503a 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -112,8 +112,11 @@ function system_help($path, $arg) {
       return $output;
     case 'admin/appearance/settings/' . $arg[3]:
       $theme_list = list_themes();
-      $theme = $theme_list[$arg[3]];
-      return '<p>' . t('These options control the display settings for the %name theme. When your site is displayed using this theme, these settings will be used.', array('%name' => $theme->info['name'])) . '</p>';
+      if (!empty($theme_list[$arg[3]])) {
+        $theme = $theme_list[$arg[3]];
+        return '<p>' . t('These options control the display settings for the %name theme. When your site is displayed using this theme, these settings will be used.', array('%name' => $theme->info['name'])) . '</p>';
+      }
+      break;
     case 'admin/appearance/settings':
       return '<p>' . t('These options control the default display settings for your entire site, across all themes. Unless they have been overridden by a specific theme, these settings will be used.') . '</p>';
     case 'admin/modules':
