Post

CVE-2026-72708 - How a 15-character regex gave me the keys to every SPIP database

CVE-2026-72708 - How a 15-character regex gave me the keys to every SPIP database

There is a function in SPIP whose entire job is to stop SQL injection. It works. It has worked for twenty years.

It just has one small exception for date columns, and that exception is fifteen characters long.

This is the story of those fifteen characters, told slowly, because the interesting part is not that there was a bug. It is that every single decision leading to it was reasonable.

CVE-2026-72708 - CVSS 4.0 8.7 (High), CWE-89. Affects SPIP before 4.4.18. No authentication required. Reported 2026-08-05, fixed in 4.4.18. My first CVE.

Who this post is for

You do not need to know SPIP. You do not really need to know PHP. If you have ever written WHERE id = ? and wondered what the ? is actually protecting you from, you have enough.

I am going to walk through this one step at a time, because the bug only gets interesting once you understand what was supposed to happen instead.

One paragraph on SPIP: it is a French open source CMS, around since 2001, and it is everywhere in the French speaking web. Government sites, universities, newspapers, NGOs. It has its own template language, its own database layer, its own everything. That last part matters. SPIP does not use an ORM you have heard of. It wrote its own quoting layer. And that is where we are going.

Step 1 - How SPIP normally keeps you safe

Every value about to touch SQL goes through one function, sql_quote(). It looks at the value, looks at the type of the column it is heading for, and hands both to the right driver for escaping.

How the quoting layer normally works How the quoting layer normally works Send it anything. It comes back as a quoted string.

1
2
3
4
function sql_quote($val, $serveur = '', $type = '') {
    $f = sql_serveur('quote', $serveur, true);
    return $f($val, $type);
}

Two things reach the escaper:

  • $val, the value, which comes from the user
  • $type, the SQL type of the destination column, which does not

The promise is the same one every quoting layer makes: whatever the user sends comes out the other side as data, never as code. Send '; DROP TABLE spip_articles; -- and MySQL faithfully stores a string containing a sad little SQL joke. Nothing executes.

That promise holds. Almost.

Step 2 - Except for one small exception

Here is a real problem a developer had to solve.

SPIP’s template language lets authors write things like {date < NOW()}. The intent is obvious: compare against the current timestamp. But if NOW() goes through the quoting layer like everything else it comes out as 'NOW()', and MySQL dutifully stores the literal six character string. The date column fills with garbage.

The NOW() problem and the shortcut that solved it The NOW() problem and the shortcut that solved it

So someone added a carve out. If the destination column is a date type, and the value looks like a function call, let it through unquoted so MySQL treats it as a function.

1
2
3
4
5
6
7
8
9
10
11
12
function spip_mysql_cite($v, $type) {
    if (!$type) {
        return "'" . addslashes($v) . "'";
    }
    // ... numeric types, string types, all quoted normally ...

    } elseif (sql_test_date($type) and preg_match('/^\w+\(/', $v)) {
        return $v;                    // straight through, no quotes
    }

    return ("'" . addslashes($v) . "'");
}

I want to be fair here. This is not a careless line. It solves a real problem, it is guarded by a type check, and it looks narrow. The author clearly thought “this only applies to date columns, and only to things shaped like NOW()”.

They were right about the first half.

Step 3 - The regex does not say what they think it says

Here is the entire security boundary:

1
/^\w+\(/

Read it out loud: one or more word characters, then an opening parenthesis. That is the whole check.

What the regex actually matches What the regex actually matches It checks the shape of a function call, never the name of the function.

Notice what it never does. It never compares the word against a list. NOW is a word. So is SLEEP. So is UPDATEXML. The regex cannot tell them apart, because it was never asked to.

ValueMatches?What it does
NOW()yesthe intended case
CURDATE()yesalso intended
SLEEP(5)yespauses the database for five seconds
IF(1=1,SLEEP(5),0)yesasks a yes/no question, answers with time
UPDATEXML(1,CONCAT(0x7e,version()),1)yesleaks data inside an error message
2026-01-01noquoted safely, as expected

A whitelist would have closed this completely:

1
preg_match('/^(NOW|CURDATE|CURTIME|CURRENT_TIMESTAMP)\s*\(\s*\)$/i', $v)

Same intent, same single line, and the exception stays an exception. The difference between the two regexes is about thirty characters and roughly eight CVSS points.

The same pattern lives in the SQLite driver at ecrire/req/sqlite_generique.php:2156, and the PostgreSQL driver has a similar path. One shortcut, copied three times.

Step 4 - Finding a door that opens from outside

At this point we have a bypass, but it is not worth much. Two things have to line up:

  1. a date column, so sql_test_date() returns true
  2. a value we control from an HTTP request

If you need admin rights to reach it, nobody cares. So the real question was: can I hit a date comparison from the public internet, with no account at all?

SPIP templates live in squelettes-dist/. Every .html file at the root is a public page:

1
2
3
4
squelettes-dist/
├── sommaire.html      ->  /spip.php?page=sommaire
├── recherche.html     ->  /spip.php?page=recherche
└── sitemap.xml.html   ->  /spip.php?page=sitemap.xml

And there, in a file that ships with every SPIP installation on earth, sitting in the open:

1
<BOUCLE_a(ARTICLES){annee?}{!par date_modif}{!par date}{0,2000}>

{annee?} filters by year. The ? makes it optional, so the clause disappears when the parameter is missing.

Here is the part that makes it work. SPIP compiles each template to PHP once and caches it. The compiler is what decides which column type annee gets escaped against, and it writes that decision into the cached file:

1
2
3
array('=', 'YEAR(articles.date)',
    sql_quote(($Pile[0]['annee'] ?? null), '',
        'datetime NOT NULL DEFAULT \'0000-00-00 00:00:00\''))

So the type is datetime. Condition one is satisfied at compile time, before our request even exists. Condition two is satisfied by whatever we type in the URL bar.

A sitemap is public by definition. That is the entire point of a sitemap.

Step 5 - The journey of one malicious parameter

The path from the URL bar into the SQL engine The path from the URL bar into the SQL engine

Enough theory. Here is the control, captured off the wire on a live SPIP 4.4.16:

Baseline request, annee=2026 Baseline request, annee=2026 A normal year. 0.175 s.

And here is the same endpoint, same lack of authentication, one different parameter value:

Injection request, annee=IF(1,SLEEP(5),0) Injection request, annee=IF(1,SLEEP(5),0) 5.064 s. The response body is identical. Only the clock changed.

No cookie. No login. One GET request, and the database took a five second nap on request.

If you replay these in Burp Repeater, change the z= parameter each time. SPIP caches public pages by URL, so sending the exact same request twice returns the cached page instantly and the delay vanishes. That is a caching artefact, not a failed injection. It cost me a confusing ten minutes.

Step 6 - Reading a database through a stopwatch

The page never shows us any data. sitemap.xml returns a list of article URLs, not whatever we put in the WHERE clause. So we cannot simply read the answer.

What we can do is ask questions the database answers with time.

Turning response time into an oracle Turning response time into an oracle

Watch the oracle work on a single character. First question: is the first byte of the admin password hash above ASCII 52?

Oracle answering yes Oracle answering yes 2.051 s. Slow means yes.

Same question, threshold moved by one:

Oracle answering no Oracle answering no 0.049 s. Fast means no.

Above 52, not above 53. The character is ASCII 53, which is 5. Two requests, one byte, no data ever appeared in a response body.

Then you do what you always do with yes/no questions: binary search. About seven requests narrows one character. A bcrypt hash is sixty characters, so roughly four hundred and twenty requests gets you all of it.

Here is the whole thing running end to end against the lab:

Full proof of concept output Full proof of concept output recovered came out of the timing oracle. actual came from the database. They match.

That is not fast. But notice what it does not require: no articles, no configuration, no content, no account.

One caveat worth knowing if you reproduce this. The injected SLEEP() sits in a WHERE clause, which MySQL evaluates per row. On a brand new install with zero articles there are no rows, nothing fires, and the response is instant. Seed one published article first or you will conclude the bug is not there.

Step 7 - The faster road, if you have an account

There is a second entry point, and it is much louder.

With editor (redacteur) rights, the article editing form reaches the same sink through a different path, except this time the query is an UPDATE, which means MySQL will happily put your data into the error message.

1
2
if ($d or strtotime($d = $date) > time()) {
    $champs['date'] = $date = $d;

Look closely at that or. PHP short circuits. When $d is "SLEEP(5)", a non empty string, it is truthy, the whole condition is already true, and strtotime() on the right hand side never runs. The validation that was supposed to happen is standing right there, politely skipped.

Two separate bugs, one short circuit apart, holding the door open for each other.

With an UPDATE in reach, UPDATEXML() turns the database into a very cooperative witness:

1
2
3
4
5
6
[Injection] date=UPDATEXML(1,CONCAT(0x7e,version()),1)
  MySQL: XPATH syntax error: '~8.0.34'

[Injection] date=UPDATEXML(1,CONCAT(0x7e,(SELECT SUBSTRING(pass,1,30)
                FROM spip_auteurs WHERE id_auteur=1)),1)
  MySQL: XPATH syntax error: '~71e5488067c00f907f048104aeb3e5'

UPDATEXML expects valid XPath. Hand it ~ followed by your data, it panics, and quotes the offending input back at you in full. Two requests for a complete hash, against four hundred and twenty for the blind version.

Step 8 - Why a read-only bug ends in a shell

Here is what makes this more than a data leak.

The injection can only read. No stacked queries, no writes. On paper that caps the damage at “attacker reads your database”, which is bad but bounded.

Except there is one row in that database that is not data. It is a key.

alea_ephemere, in spip_meta, is the secret SPIP uses to sign every action link in the interface. Delete a section, edit an account, uninstall a plugin: each carries an HMAC built from that secret.

1
2
3
4
5
function _action_auteur($action, $id_auteur, $pass, $alea) {
    $sha[$entry] = hash_hmac('sha256',
        "$action::$id_auteur",
        "$pass::" . _action_get_alea($alea));
}

For an anonymous visitor $id_auteur is 0 and $pass is empty, so the formula collapses to something with exactly one unknown:

1
$hash = hash_hmac('sha256', "editer_auteur-1::0", "::" . $alea_ephemere);

And we just read $alea_ephemere out of the database.

From one leaked secret to two independent roads to RCE From one leaked secret to two independent roads to RCE

From there, two independent roads. Both work because of a deliberate design decision: most SPIP actions verify the nonce but not your permissions, on the assumption that the link would never have been rendered for an unauthorised user in the first place. That assumption holds for people clicking buttons. It does not hold for curl.

Chain A, take the account. Forge a nonce for editer_auteur and reset the admin password. The function that writes a new password has no autoriser() call, while the functions next to it that change statut and webmestre both do (CVE-2026-72709). Log in, upload a plugin containing a webshell. Installing plugins is a feature, not a vulnerability, which is somehow worse.

Chain B, skip the account entirely. Forge a nonce for editer_objet with arg=job/0. That action resolves job to the real spip_jobs table, inserts an empty row, then fills every column straight from the request, because spip_jobs never declared an editable field whitelist (CVE-2026-72710). Set fonction=system and args=a:1:{i:0;s:2:"id";}, then nudge the queue:

1
2
3
$args = unserialize($row['args']);
$fonction = $row['fonction'];
$res = $fonction(...$args);        // system('id')

No password changed. No session created. No account touched at all.

Credit where it is due. I found the sink and the authenticated path. Franck Chevalier (Wayko) of Lexfo / Ambionics independently found the same sink, found the sitemap entry point, and built both chains to RCE. Their full writeup goes far deeper than this section and is the reason this bug is an 8.7 rather than a 6.

The fix

Upgrade to SPIP 4.4.18. That is the whole remediation.

If you are pinned to an older version, the patch is one regex:

1
2
3
4
5
} elseif (sql_test_date($type) and preg_match(
    '/^(NOW|CURDATE|CURTIME|CURRENT_TIMESTAMP|CURRENT_DATE|CURRENT_TIME|UTC_DATE|UTC_TIME|UTC_TIMESTAMP)\s*\(\s*\)$/i',
    $v
)) {
    return $v;

Apply the same change in ecrire/req/sqlite_generique.php.

If you cannot patch right now, you can take the public entry point off the board at the reverse proxy:

1
2
3
if ($arg_page = "sitemap.xml") { set $check_annee 1; }
if ($arg_annee ~ "[^0-9]")     { set $check_annee "${check_annee}1"; }
if ($check_annee = "11")       { return 403; }

That closes the unauthenticated path. It does not close the authenticated one, so treat it as a tourniquet, not a cure.

What I took away from this

A type check is not a value check. sql_test_date($type) was doing its job perfectly. It told the truth about the column. It just has nothing to say about whether the value is safe, and it was quietly carrying half of a security decision it knew nothing about.

Describing a shape is not the same as naming a thing. /^\w+\(/ describes what NOW() looks like. The author needed to say which functions are allowed. Those two feel identical when you write the line with one example in your head.

Exceptions are where bugs live. The quoting layer is correct everywhere except one branch, and that branch exists because of a legitimate edge case. When you audit, go find the elseif that starts with “except when”.

Short circuits hide validation. if ($d or strtotime($d = $date) > time()) reads like there is a check. There is a check. It just does not run on the path that matters.

Timeline

DateEvent
2026-07-29Ambionics reports the chain to SPIP
2026-08-05I find the same sink during a source audit, report to securite@spip.net
2026-08-05SPIP proposes a first patch, incomplete
2026-08-10SPIP 4.4.18 ships the complete fix
2026-09-11VulnCheck assigns CVE-2026-72708, 72709 and 72710
2026-09-15CISA SSVC assessment

References


Responsible disclosure throughout. SPIP’s security team was notified before anything was made public, and 4.4.18 was out before this post existed. If you run SPIP, go update it.

This post is licensed under CC BY 4.0 by the author.