Refuse session ids that PHP did not make.
This commit is contained in:
@@ -57,6 +57,17 @@ class FrontPagesTest extends PageTestCase {
|
||||
$this->assertNull($this->header($this->get('/', array('X-Test-Plain' => '1')), 'Strict-Transport-Security'));
|
||||
}
|
||||
|
||||
// PHP makes a new id for a session id that it did not make, so nobody can plant one
|
||||
public function testAnUnknownSessionIdIsReplaced(): void {
|
||||
$planted = str_repeat('ab', 16);
|
||||
foreach (array('/', '/display?id=1') as $path) {
|
||||
$this->cookies = array('PHPSESSID' => $planted);
|
||||
$this->get($path);
|
||||
$this->assertNotSame($planted, $this->cookies['PHPSESSID'] ?? NULL, $path);
|
||||
$this->assertFileDoesNotExist(self::$state . "/sessions/sess_$planted", $path);
|
||||
}
|
||||
}
|
||||
|
||||
public function testPlainHttpStartsNoSession(): void {
|
||||
$page = $this->get('/', array('X-Test-Plain' => '1'));
|
||||
$this->assertSame(200, $page['status']);
|
||||
|
||||
Reference in New Issue
Block a user