session.upload_progress.enabled = 0 e session.use_strict_mode = 1, come indicato da Sansec in attesa della patch; restano anche dopo, perche' all'applicazione non servono (Laravel ha le sue sessioni, in Redis). Test di guardia in VersionePhpTest. HANDOFF: stato della mitigazione e scelta ancora aperta sul rilascio in produzione. README: sicurezza. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
55 lines
2.0 KiB
PHP
55 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
/**
|
|
* L'immagine deve partire da una versione di PHP fissata alla patch, e mai
|
|
* sotto quella che corregge CVE-2026-109618 e CVE-2026-109619 (esecuzione di
|
|
* codice da remoto nel core di PHP, 21/10/2026). Con un tag che si sposta
|
|
* ("8.3-fpm") la cache di Docker poteva riusare una base vulnerabile.
|
|
*/
|
|
class VersionePhpTest extends TestCase
|
|
{
|
|
private const MINIMA = '8.3.36';
|
|
|
|
private function dockerfile(): string
|
|
{
|
|
return (string) file_get_contents(dirname(__DIR__, 2) . '/docker/php/Dockerfile');
|
|
}
|
|
|
|
public function test_la_versione_di_php_e_fissata_e_corretta(): void
|
|
{
|
|
// \s* prima di $: nella copia di lavoro su Windows il file ha CRLF.
|
|
$this->assertMatchesRegularExpression('/^ARG PHP_VERSION=(\d+\.\d+\.\d+)\s*$/m', $this->dockerfile());
|
|
|
|
preg_match('/^ARG PHP_VERSION=(\d+\.\d+\.\d+)\s*$/m', $this->dockerfile(), $trovata);
|
|
|
|
$this->assertTrue(
|
|
version_compare($trovata[1], self::MINIMA, '>='),
|
|
"PHP {$trovata[1]} è vulnerabile a CVE-2026-109618/109619: serve almeno " . self::MINIMA . '.',
|
|
);
|
|
}
|
|
|
|
public function test_la_mitigazione_delle_sessioni_resta_nel_php_ini(): void
|
|
{
|
|
// Indicata da Sansec per CVE-2026-109618/109619; all'applicazione non
|
|
// serve, quindi resta anche dopo la patch.
|
|
$ini = (string) file_get_contents(dirname(__DIR__, 2) . '/docker/php/php.ini');
|
|
|
|
$this->assertMatchesRegularExpression('/^session\.upload_progress\.enabled\s*=\s*0\s*$/m', $ini);
|
|
$this->assertMatchesRegularExpression('/^session\.use_strict_mode\s*=\s*1\s*$/m', $ini);
|
|
}
|
|
|
|
public function test_l_immagine_usa_la_versione_fissata_e_non_un_tag_mobile(): void
|
|
{
|
|
preg_match_all('/^FROM php:(\S+)/m', $this->dockerfile(), $basi);
|
|
|
|
$this->assertNotEmpty($basi[1]);
|
|
foreach ($basi[1] as $tag) {
|
|
$this->assertStringStartsWith('${PHP_VERSION}', $tag, "FROM php:{$tag}: usa ARG PHP_VERSION, non un tag che si sposta.");
|
|
}
|
|
}
|
|
}
|