diff --git a/CHANGELOG.md b/CHANGELOG.md index ae48cd4..903a608 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ * issue#719: Plugin Disabled due to mix of string and int * issue: All Columns checkd on Thresholds page * issue: Special character previous value handling broken on data query indexes with special characters +* security: Replace rand() with hrtime(true) for graph image cache-buster (GHSA-vhwj-hfwg-gfg3, CWE-338) --- 1.8.2 --- diff --git a/tests/Unit/GraphCacheBusterTest.php b/tests/Unit/GraphCacheBusterTest.php new file mode 100644 index 0000000..794224a --- /dev/null +++ b/tests/Unit/GraphCacheBusterTest.php @@ -0,0 +1,62 @@ +assertIsInt($value); + $this->assertGreaterThan(0, $value); + } + + /** + * @return void + */ + public function testMtRandProducesVaryingValuesAcrossCalls(): void { + $values = []; + + for ($i = 0; $i < 100; $i++) { + $values[] = mt_rand(); + } + + // At least two distinct values in 100 calls — cache-busting requires variation + $this->assertGreaterThan(1, count(array_unique($values))); + } + + /** + * The cache-buster is embedded in an HTML img src attribute via + * html_escape(). Confirm the value round-trips safely. + * + * @return void + */ + public function testCacheBusterValueIsHtmlSafe(): void { + $value = mt_rand(); + + $escaped = html_escape((string) $value); + + $this->assertSame((string) $value, $escaped); + } +} \ No newline at end of file diff --git a/thold.php b/thold.php index e9c491c..7572085 100644 --- a/thold.php +++ b/thold.php @@ -1275,7 +1275,7 @@ function thold_edit() {
- '> + '>