KEVWire

Security intelligence, with context.

Response snapshot Oct 27, 2026, 02:47 UTC

Back to the wire
Permalink
VulnerabilityCVE-2026-72701

Grav: Non constant time nonce comparison in Utils::verifyNonce() used for CSRF protection

`Grav\Common\Utils::verifyNonce()`, the core function Grav and its plugins use to validate CSRF nonces, compares the submitted nonce to the expected value with PHP's `===` operator instead of `hash_equals()`.

At a glance

Exploited
Not known
Severity
3.7 Low (CVSS 3.1)
Chance of exploitation
0.2% in the next 30 days
Sources
1 source

What to do

GitHub lists first patched versions: getgrav/grav: 2.0.16. Confirm the affected range and upgrade guidance in the exact advisory.

Read GitHub-reviewed advisory GHSA-38p6-h87p-r4cg (opens a new tab)

What happened

## Summary

`Grav\Common\Utils::verifyNonce()`, the core function Grav and its plugins use to validate CSRF nonces, compares the submitted nonce to the expected value with PHP's `===` operator instead of `hash_equals()`. `===` on strings short circuits at the first differing byte, so the comparison time leaks how many leading bytes of a guess are correct. This is CWE-208, Observable Timing Discrepancy.

The codebase already knows to avoid this pattern. `hash_equals()` is used for the equivalent purpose in four other places I found: `system/src/Grav/Common/Session.php`, `system/src/Grav/Framework/Cache/Adapter/FileCache.php`, `system/src/Grav/Common/Scheduler/Scheduler.php` (the webhook token check), and `system/src/Grav/Common/Scheduler/JobQueue.php`. `Utils::verifyNonce()` is the one place I found that still uses a plain equality check for a secret comparison.

## Affected product and version

Continue reading

Product: Grav CMS, getgrav/grav Confirmed present in: 2.0.15, commit c2b46866857a93a0aa7048e7ed707ed3ed45dbc3

## Affected code

`system/src/Grav/Common/Utils.php`, lines 1512 to 1521: ```php public static function verifyNonce($nonce, $action) { //Safety check for multiple nonces if (is_array($nonce)) { $nonce = array_shift($nonce); }

//Nonce generated 0-12 hours ago if ($nonce === self::getNonce($action)) { return true; }

//Nonce generated 12-24 hours ago return $nonce === self::getNonce($action, true); } ```

The nonce itself is `md5($tick . '|' . $action . '|' . $username . '|' . session_id() . '|' . Security::getNonceKey())`, computed in the private `generateNonceString()` a few lines above. `Security::getNonceKey()` is an installation level secret. So the value being compared with `===` is a value derived from a secret, which is exactly the case `hash_equals()` exists for.

## Proof of concept, verified, real output

I could not exploit this end to end over a real network from this sandbox, since that requires a live deployment and a timing measurement setup outside a single machine.

What I did verify directly, by running real code, is that the underlying primitive this function relies on, PHP's `===` string comparison, is not constant time in the PHP build actually used here, and that a measurable timing signal is still present at the exact length Grav's nonces have, 32 hex characters, an md5 digest.

Step 1, confirm PHP build: ``` $ php -v PHP 8.3.6 (cli) (built: Jul 16 2026 18:30:41) (NTS) ```

Step 2, benchmark script, measures the median time of `$a === $b` over many trials, once with a long string to establish a clean signal, once at the real 32 byte nonce length: ```php <?php // timing_poc2.php function timeCompare(string $a, string $b, int $iterations): float { $r = null; $start = hrtime(true); for ($i = 0; $i < $iterations; $i++) { $r = ($a === $b); } $end = hrtime(true); return ($end - $start) / $iterations; }

function median(array $arr): float { sort($arr); $n = count($arr); $mid = intdiv($n, 2); return $n % 2 ? $arr[$mid] : ($arr[$mid - 1] + $arr[$mid]) / 2; }

function runExperiment(int $len, int $iterations, int $trials): array { $secret = bin2hex(random_bytes((int)ceil($len / 2))); $secret = substr($secret, 0, $len);

$wrongEarly = $secret; $wrongEarly[0] = ($secret[0] === 'a') ? 'b' : 'a';

$wrongLate = $secret; $last = $len - 1; $wrongLate[$last] = ($secret[$last] === 'a') ? 'b' : 'a';

$earlyTimes = []; $lateTimes = []; timeCompare($wrongEarly, $secret, 20000); timeCompare($wrongLate, $secret, 20000); for ($t = 0; $t < $trials; $t++) { $earlyTimes[] = timeCompare($wrongEarly, $secret, $iterations); $lateTimes[] = timeCompare($wrongLate, $secret, $iterations); } return [median($earlyTimes), median($lateTimes)]; }

echo "=== Length 4096 bytes, establishes the primitive is not constant time ===\n"; [$e, $l] = runExperiment(4096, 20000, 15); printf("Median mismatch at position 0 : %.2f ns/op\n", $e); printf("Median mismatch at last position : %.2f ns/op\n", $l); printf("Ratio (late/early) : %.2fx\n\n", $l / $e);

echo "=== Length 32 bytes, the actual Grav nonce length, md5 hex output ===\n"; [$e2, $l2] = runExperiment(32, 200000, 21); printf("Median mismatch at position 0 : %.2f ns/op\n", $e2); printf("Median mismatch at last position : %.2f ns/op\n", $l2); printf("Ratio (late/early) : %.2fx\n", $l2 / $e2); ```

Step 3, run it three times to confirm the result is reproducible and not noise: ``` $ php timing_poc2.php ```

Actual output, run 1: ``` === Length 4096 bytes, establishes the primitive is not constant time === Median mismatch at position 0 : 13.83 ns/op Median mismatch at last position : 338.58 ns/op Ratio (late/early) : 24.48x

=== Length 32 bytes, the actual Grav nonce length, md5 hex output === Median mismatch at position 0 : 14.13 ns/op Median mismatch at last position : 17.41 ns/op Ratio (late/early) : 1.23x ```

Actual output, run 2: ``` === Length 4096 bytes, establishes the primitive is not constant time === Median mismatch at position 0 : 14.25 ns/op Median mismatch at last position : 333.99 ns/op Ratio (late/early) : 23.44x

=== Length 32 bytes, the actual Grav nonce length, md5 hex output === Median mismatch at position 0 : 13.83 ns/op Median mismatch at last position : 17.24 ns/op Ratio (late/early) : 1.25x ```

Actual output, run 3: ``` === Length 4096 bytes, establishes the primitive is not constant time === Median mismatch at position 0 : 14.20 ns/op Median mismatch at last position : 336.89 ns/op Ratio (late/early) : 23.73x

=== Length 32 bytes, the actual Grav nonce length, md5 hex output === Median mismatch at position 0 : 13.98 ns/op Median mismatch at last position : 17.39 ns/op Ratio (late/early) : 1.24x ```

Interpretation, stated honestly. At 4096 bytes the effect is unambiguous and consistent across three independent runs, a mismatch near the end of the string takes about 23 to 24 times longer to reject than a mismatch at the very first byte, which is direct proof `===` is not constant time in this PHP buil

Affected package ranges reported by GitHub: getgrav/grav: <= 2.0.15

Scores and how they were measured

CVSS base severity

3.7

Version 3.1As of

CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:N

Measurement source (opens a new tab)

How bad it is if exploited. Not a prediction of exploitation or proof you are exposed.

EPSS probability

0.2%

Scored Percentile 11.9%

Model and measurement source (opens a new tab)

A model's estimate of exploitation in the next 30 days, not certainty or your own risk.

Related technology

Sources

  1. Primary source

    GitHub-reviewed advisory GHSA-38p6-h87p-r4cg (opens a new tab)

    The public advisory supplies the description, affected package/version ranges, and any listed CVSS metric. GitHub review is not local review.

    Published Checked

  2. Primary source

    GitHub public advisory API page (opens a new tab)

    The API page supplied GHSA-38p6-h87p-r4cg, its actual identifiers, source dates, and structured metrics.

    Published Date not suppliedChecked

  3. Primary source

    FIRST measured EPSS score (opens a new tab)

    Measured EPSS probability and percentile for CVE-2026-72701, scored 2026-10-26. This is a model estimate, not proof of exposure.

    Published Checked

Cite this record

For factual claims, cite the primary sources above; cite KEVWire for its compilation, dates, and classifications.

APA

KEVWire. (2026, October 26). Grav: Non constant time nonce comparison in Utils::verifyNonce() used for CSRF protection (CVE-2026-72701). https://kevwire.com/record/CVE-2026-72701

MLA

"Grav: Non constant time nonce comparison in Utils::verifyNonce() used for CSRF protection (CVE-2026-72701)." KEVWire, 26 Oct. 2026, kevwire.com/record/CVE-2026-72701.

Chicago

KEVWire. "Grav: Non constant time nonce comparison in Utils::verifyNonce() used for CSRF protection (CVE-2026-72701)." Last modified October 26, 2026. https://kevwire.com/record/CVE-2026-72701.

Evidence summary (plain text)

Grav: Non constant time nonce comparison in Utils::verifyNonce() used for CSRF protection (Sep 17, 2026).
`Grav\Common\Utils::verifyNonce()`, the core function Grav and its plugins use to validate CSRF nonces, compares the submitted nonce to the expected value with PHP's `===` operator instead of `hash_equals()`. `===` on strings short circuits at the first differing byte, so the comparison time leaks how many leading bytes of a guess are correct. This is CWE-208, Observable Timing Discrepancy.

The codebase already knows to avoid this pattern. `hash_equals()` is used for the equivalent purpose in four other places I found: `system/src/Grav/Common/Session.php`, `system/src/Grav/Framework/Cache/Adapter/FileCache.php`, `system/src/Grav/Common/Scheduler/Scheduler.php` (the webhook token check), and `system/src/Grav/Common/Scheduler/JobQueue.php`. `Utils::verifyNonce()` is the one place I found that still uses a plain equality check for a secret comparison.
CVSS 3.7 (version 3.1; evidence as of Oct 26, 2026; https://github.com/advisories/GHSA-38p6-h87p-r4cg).
EPSS 0.2% for the following 30 days, scored Oct 26, 2026 (https://api.first.org/data/v1/epss?cve=CVE-2026-72701&date=2026-10-26).
Sources:
GitHub-reviewed advisory GHSA-38p6-h87p-r4cg: https://github.com/advisories/GHSA-38p6-h87p-r4cg
GitHub public advisory API page: https://api.github.com/advisories?type=reviewed&per_page=100&sort=updated&direction=desc
FIRST measured EPSS score: https://api.first.org/data/v1/epss?cve=CVE-2026-72701&date=2026-10-26
Record ID: CVE-2026-72701.
Record origin: Ingested record.
AI evidence: Not assessed.
Known exploitation: Not assessed.
Zero-day status: Not assessed. KEV membership alone does not establish zero-day status.
About this data

This record was ingested from a data source. Retrieved: Oct 27, 2026, 01:40 UTC. Ingestion is not an independent editorial investigation.

A CISA KEV listing documents known exploitation, not necessarily a zero-day; absence from the catalog does not prove a vulnerability has never been exploited.

Technology tags indicate possible relevance, not verified exposure. Confirm the affected product, version, and configuration against your own inventory; KEVWire does not scan your systems.

A personal reading checklist on this device, not verified remediation.

Record JSON

Your account

Email alerts

Email alerts are not available yet. To follow your stack today, use its RSS feed, which honors your filters, or connect an AI agent through the API.

Suggest an improvement

Ideas, missing sources, corrections, and bugs are all welcome. No account needed. Suggestions are reviewed by a person before anything changes.

Record details

Record detail