Skip to content
Snippets Groups Projects
Verified Commit 56f266dd authored by Dave Long's avatar Dave Long
Browse files

Issue #3508196 by mcdruid, smustgrave, longwave, benjifisher, greggles,...

Issue #3508196 by mcdruid, smustgrave, longwave, benjifisher, greggles, larowlan, jenlampton, xjm, quicksketch: Add tests for SA-CORE-2024-006
parent df9baa95
No related branches found
No related tags found
3 merge requests!5423Draft: Resolve #3329907 "Test2",!3478Issue #3337882: Deleted menus are not removed from content type config,!579Issue #2230909: Simple decimals fail to pass validation
Pipeline #487713 passed with warnings
Pipeline: drupal

#487728

    Pipeline: drupal

    #487717

      <?php
      declare(strict_types=1);
      // cSpell:ignore phpggc
      namespace Drupal\KernelTests\Core\File;
      use Drupal\KernelTests\KernelTestBase;
      /**
      * Tests protection against SA-CORE-2024-006 File Delete Gadget Chain.
      *
      * @group file
      */
      class FileDeleteGadgetChainTest extends KernelTestBase {
      /**
      * Tests unserializing a File Delete payload.
      */
      public function testFileDeleteGadgetChain(): void {
      file_put_contents('public://canary.txt', 'now you see me');
      // ./phpggc --public-properties Drupal/FD1 public://canary.txt
      $payload = 'O:34:"Drupal\Core\Config\StorageComparer":1:{s:18:"targetCacheStorage";O:39:"Drupal\Component\PhpStorage\FileStorage":1:{s:9:"directory";s:19:"public://canary.txt";}}';
      try {
      unserialize($payload);
      $this->fail('No exception was thrown');
      }
      catch (\Throwable $e) {
      $this->assertInstanceOf(\TypeError::class, $e);
      $this->assertStringContainsString('Cannot assign Drupal\Component\PhpStorage\FileStorage to property Drupal\Core\Config\StorageComparer::$targetCacheStorage', $e->getMessage());
      }
      $this->assertTrue(file_exists('public://canary.txt'));
      unlink('public://canary.txt');
      }
      }
      0% Loading or .
      You are about to add 0 people to the discussion. Proceed with caution.
      Please register or to comment