Duplicator, the Path Traversal That Wouldn't Die: A Code-Level Teardown of CVE-2020-11738
A deep look at how Duplicator's unauthenticated download handler let attackers climb out of the snapshots directory with a single ../, why sanitize_text_field() gave developers a false sense of safety, and what the 1.3.28 fix teaches WordPress plugin authors about validating file paths.
On this page6
The Setup: An Unauthenticated File Server Buried in a Backup Plugin#
Duplicator's job is to make it easy to package a WordPress site's filesystem and database, then restore them elsewhere. That workflow requires serving files back to a browser: the download step. To make that step work in both the admin dashboard and the standalone installer flow, the plugin exposed a download handler on the front end, hooked into init so it runs on every request, whether or not the caller is logged in.
That handler is the entire story. It didn't need a session, a nonce, or a capability check. It just needed a file parameter — and the plugin then concatenated that parameter onto its snapshot directory and streamed whatever came back. For an unauthenticated attacker, that is a file server.
The Defect: sanitize_text_field() Is Not a Path Sanitizer#
The vulnerable code lived in duplicator.php as duplicator_init(), registered with add_action('init', 'duplicator_init'), and mirror-imaged as an AJAX handler duplicator_download() inside ctrls/class.web.services.php, registered on both wp_ajax_duplicator_download and wp_ajax_nopriv_duplicator_download. Both versions did roughly the same three lines of work:
$file = sanitize_text_field($_GET['file']);$filepath = DUPLICATOR_SSDIR_PATH.'/'.$file;- Then
file_exists(),fopen(),fread(),readfile()and a stream straight back to the caller.
sanitize_text_field() strips tags, invalid UTF-8, and extra whitespace. It is a text field sanitizer, not a filesystem sanitizer. It does not remove ../, does not call basename(), and does not constrain the resulting path to any directory. So when an attacker passed a value containing ../, the final path resolved the traversal in file_exists() and the file was served.
The snapshot directory, DUPLICATOR_SSDIR_PATH, is defined in define.php as duplicator_get_abs_path() . '/wp-snapshots' — a sibling of WordPress core files. One ../ from there lands in the site root. wp-config.php is a short walk away, and it contains the database credentials and salts that turn a single file-read into full site takeover.
The critical misconception here is that any sanitizer with the word sanitize_ in it makes an input safe. Inputs are safe relative to the context they are used in. This input was used as a path component, and no context-appropriate validation happened.
Why Two Entry Points Made It Worse#
The same vulnerable logic was copy-pasted into two different request routes. The init hook fires on every page load, so the download action was available at the site root with a query string. The second copy lived in ctrls/class.web.services.php and was registered for admin-ajax.php with the nopriv prefix, meaning it was callable without authentication through the standard AJAX endpoint.
Duplicate handler logic means duplicate attack surface and duplicate fix effort. When the 1.3.28 patch landed, the team had to remove the init one entirely and rewrite the AJAX one. Reviewers writing defender-side rules for this class of bug should always check both init/template_redirect/wp_loaded style hooks and wp_ajax_nopriv_* registrations — the same defect often ships in both.
The Fix: Stop Trusting the Path, Derive It Server-Side#
Version 1.3.28 removed duplicator_init() and the add_action('init', ...) hook from duplicator.php outright, and rewrote duplicator_download() in ctrls/class.web.services.php to require three parameters: id, hash, and file.
The design change is the important part, not the individual checks:
- The
fileparameter stopped being a filename. It became a selector — aswitchwith three accepted values:sql,archive, andinstaller. Anything else sets$error = true. There is no path to traverse because there is no path in the input. - The real filename is derived server-side from the package's
NameHash, e.g."{$package->NameHash}_database.sql". The attacker never supplies characters that reach the filesystem concat. - The request must reference a real package via
DUP_Package::getByID( $packageId )and present ahashthat matches$package->Hash. That hash is a secret value generated per-package and not exposed to unauthenticated visitors. - On any failure, the handler now calls
sleep(2)beforewp_die('Invalid request'), and the error message no longer echoes an internal filename back to the caller — closing a small information leak that could aid iterative probing. - The view in
views/packages/details/detail.phpwas updated to build download URLs usingid,hash, and the new selector value, so the front-end UI and the handler stayed in sync.
That combination — allowlist the selector, derive the path, authenticate with a secret — is the pattern to copy. Sanitizing the string was never the answer; removing the attacker's control over the path was.
Detection and Prevention for Plugin Authors and Agencies#
If you maintain a plugin that serves files, or you audit plugins for clients, these checks catch this class of bug quickly:
- Grep for
$_GET,$_POST,$_REQUESTvalues being concatenated onto a filesystem path. Look for\$path . '/' . \$inputor\$dir . \$filepatterns. Direct concatenation of request data into a path is almost always wrong. - Grep for unauthenticated AJAX actions:
wp_ajax_nopriv_should be reserved for genuinely public functionality. Every registerednoprivaction deserves a one-line justification. - Never use
sanitize_text_field(),esc_html(),esc_url(), orwp_strip_all_tags()as a path sanitizer. For paths, the correct primitives arebasename(), an allowlistswitch/in_array()on known filenames, and arealpath()containment check comparing against the intended base directory before opening the file. - Treat
DUPLICATOR_SSDIR_PATH-style plugin storage as sensitive. Snapshot and backup directories often sit under webroot and may be listable or directly downloadable. Prefer storing them outside webroot, or block direct access viaindex.phpand server rules. - Audit the file-serving endpoint's auth model, not just the filename handling. This handler was unauthenticated. Even a perfect path sanitizer on an unauth endpoint that streams backups is a problem worth fixing.
For defenders running WordPress sites: monitor access logs for query strings that contain ../, ..%2f, or encoded traversal sequences against any plugin endpoints, especially AJAX routes. A single hit from an unknown IP against a backup plugin's download action is a high-signal event.
The broader lesson is that the vulnerability lived in the type system of the parameter, not in the sanitizer. The file parameter was treated as a name when it was really a path fragment chosen by the attacker. The fix was not a better filter; it was changing the parameter back into a name. You can find a link to the full advisory and version details in the Radar entry.
When a request parameter reaches the filesystem, sanitizing the string is not enough — either remove the attacker's control over the path entirely or prove containment against a fixed base directory. Anything else is a file server.
Vulnerabilities covered
| Severity | Vulnerability | CVE | Published |
|---|---|---|---|
| High7.5 | Directory Traversal | CVE-2020-11738 |
- High7.5VulnCrest analysisKEVPoCDirectory Traversal
Duplicator
<1.3.28Update to 1.3.28
