diff --git a/core/modules/system/src/Tests/Form/ExternalFormUrlTest.php b/core/modules/system/src/Tests/Form/ExternalFormUrlTest.php
new file mode 100644
index 0000000..df3544c
--- /dev/null
+++ b/core/modules/system/src/Tests/Form/ExternalFormUrlTest.php
@@ -0,0 +1,99 @@
+<?php
+/**
+ * @file
+ * Contains \Drupal\system\Tests\Form\ExternalFormUrlTest
+ */
+
+namespace Drupal\system\Tests\Form;
+
+
+use Drupal\Core\DependencyInjection\DependencySerializationTrait;
+use Drupal\Core\Form\FormInterface;
+use Drupal\Core\Form\FormState;
+use Drupal\Core\Form\FormStateInterface;
+use Drupal\simpletest\KernelTestBase;
+use Drupal\user\Entity\User;
+use Symfony\Component\HttpFoundation\Request;
+
+/**
+ * Ensures that form actions can't be tricked into sending to external urls.
+ *
+ * @group system
+ */
+class ExternalFormUrlTest extends KernelTestBase implements FormInterface {
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = ['user', 'system'];
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getFormId() {
+    return 'external_form_url_test';
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function buildForm(array $form, FormStateInterface $form_state) {
+    $form['something'] = [
+      '#type' => 'textfield',
+      '#title' => 'What do you think?',
+    ];
+    return $form;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function validateForm(array &$form, FormStateInterface $form_state) {}
+
+  /**
+   * {@inheritdoc}
+   */
+  public function submitForm(array &$form, FormStateInterface $form_state) {}
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+    $this->installSchema('system', ['key_value_expire', 'sequences']);
+    $this->installEntitySchema('user');
+    $this->logger = \Drupal::logger('test_logger');
+    $test_user = User::create(array(
+      'name' => 'foobar',
+      'mail' => 'foobar@example.com',
+    ));
+    $test_user->save();
+    \Drupal::service('current_user')->setAccount($test_user);
+    // Create a new request and make it the master request.
+    $request_stack = \Drupal::service('request_stack');
+    $original_request = $request_stack->pop();
+    $request = Request::create($original_request->getSchemeAndHttpHost() . '//example.org');
+    $request_stack->push($request);
+  }
+
+  /**
+   * Tests form behaviour.
+   */
+  public function testExternalUrlBehavior() {
+    $form_state = new FormState();
+    $form_state->setCached();
+    $form_builder = $this->container->get('form_builder');
+    $form = $form_builder->getForm(get_class($this));
+    $markup = \Drupal::service('renderer')->render($form);
+    $dom = new \DOMDocument();
+    $dom->loadXML($markup);
+    $xpath = new \DOMXPath($dom);
+    $form = $xpath->query('//form');
+    $action = $form->item(0)->getAttribute('action');
+    $this->assertNotEqual('//example.org', $action);
+    $this->assertEqual('/example.org', $action);
+  }
+
+}
