Repository navigation
fix(security): validate Mailchimp data center to prevent authenticated SSRF - #3193
Conversation
The Mailchimp data center is taken from the part of the API key after the dash and used as the request host (`https://<dc>.api.mailchimp.com/...`). validate_api_key() only checked for a single dash, so a Contributor could submit a key such as `x-attacker:8443/r#` through the form editor endpoint and make the server request an arbitrary host, including internal services. - Require the data center to be a bare `[a-z0-9]+` token, so it can only resolve to `*.api.mailchimp.com`. server_name is set only through set_api_key(), which runs this validation first. - Defense in depth: send every Mailchimp request with wp_safe_remote_get()/ wp_safe_remote_post(), so a redirect to a private or loopback address is refused even if a host ever reached the request builder. Reported-by: Deus Rex research team <research@deusrex.ai>
Bundle Size Diff
|
|
Plugin build for 8ed34f8 is ready 🛎️!
|
E2E TestsPlaywright Test Status: See serial and parallel matrix jobs Performance ResultsserverResponse: {"q25":262.56,"q50":278.52,"q75":281.71,"cnt":10}, firstPaint: {"q25":971.27,"q50":1041.93,"q75":1066.62,"cnt":10}, domContentLoaded: {"q25":2752.67,"q50":2778.34,"q75":2818.52,"cnt":10}, loaded: {"q25":2755.65,"q50":2781.15,"q75":2821.32,"cnt":10}, firstContentfulPaint: {"q25":1353.47,"q50":2100.06,"q75":2292.61,"cnt":10}, firstBlock: {"q25":12158.13,"q50":12235.69,"q75":12612.63,"cnt":10}, type: {"q25":23.3,"q50":25.17,"q75":27.63,"cnt":10}, typeWithoutInspector: {"q25":19.7,"q50":23.5,"q75":29.89,"cnt":10}, typeWithTopToolbar: {"q25":30.24,"q50":35.21,"q75":35.98,"cnt":10}, typeContainer: {"q25":12.52,"q50":14.04,"q75":14.5,"cnt":10}, focus: {"q25":94.41,"q50":100.04,"q75":104.98,"cnt":10}, inserterOpen: {"q25":31,"q50":32.92,"q75":34.19,"cnt":10}, inserterSearch: {"q25":19.29,"q50":20.85,"q75":21.75,"cnt":10}, inserterHover: {"q25":3.85,"q50":4.2,"q75":4.94,"cnt":20}, loadPatterns: {"q25":1357.95,"q50":1380.8,"q75":1511.21,"cnt":10}, listViewOpen: {"q25":165.21,"q50":179.42,"q75":182.22,"cnt":10} |
There was a problem hiding this comment.
🟡 Changes requested
The data-center check closes the SSRF, but the safe request functions can break Mailchimp on proxy-only hosts.
Questions for the author
- Does any supported Mailchimp key or deployment need a data-center suffix or request destination that these new checks reject?
Validation details
- Files reviewed: 2/2 changed files. One history question stayed open: a key check that hard-codes a provider assumption can reject valid keys.
cd /repo && set -o pipefail; timeout 280 vendor/bin/phpunit --do-not-cache-result --filter 'Test_Mailchimp_Provider::' -…printedOK (4 tests, 21 assertions)(run R3)- A source trace shows
server_nameis set only aftervalidate_api_key()passes. - Every request path sanitizes the key with
sanitize_text_field(). - Webhook, Sendinblue and other outbound requests do not build a host from a user key.
Untested areas
- A key check that hard-codes a provider assumption can reject valid keys. No source showed uppercase data centers, but this is unconfirmed.
- The VIP request helper was not checked at a pinned version.
- The JavaScript, end-to-end and browser checks did not run because the frontend build is absent.
- The variant pass did not settle these places, where the fixed cause may still reach:
inc/server/class-template-cloud-server.php:99-111,157-182— unverified: Supplied and stored source URLs reach requests with reject_unsafe_urls = true. No version-matched WordPress/VIP source was available to establish what destinations and redirects th…inc/plugins/class-template-cloud.php:246-258— unverified: Supplied and stored source URLs reach requests with reject_unsafe_urls = true. No version-matched WordPress/VIP source was available to establish what destinations and redirects th…inc/plugins/class-options-settings.php:732-765— unverified: Stored webhook URLs receive only esc_url_raw() before wp_remote_request(), without an explicit unsafe-URL guard. Potential sibling SSRF; ruling requires the effective setting-write…plugins/otter-pro/inc/plugins/class-form-pro-features.php:53-60,838-875— unverified: Stored webhook URLs receive only esc_url_raw() before wp_remote_request(), without an explicit unsafe-URL guard. Potential sibling SSRF; ruling requires the effective setting-write…
🤖 Automated review · run code-review-agent_6b0070cc95a962.51984998.
🤖 Review agent — review posted ✅ on 4654cc14 · changes requested · 2 findings · 17 min
Run code-review-agent_6b0070cc95a962.51984998 · trail
…wp_safe_* wp_safe_remote_get()/wp_safe_remote_post() run wp_http_validate_url() before the HTTP proxy is applied, so on a site that reaches the internet only through WP_PROXY_HOST they would reject the Mailchimp host that local DNS cannot resolve, breaking lists, merge fields and subscriptions. The data-center validation already pins every request host to *.api.mailchimp.com, so the redirect concern is covered by passing 'redirection' => 0 on the normal wp_remote_* calls, with no DNS/proxy regression. - Revert the four Mailchimp requests to wp_remote_get()/wp_remote_post(). - Add 'redirection' => 0 to each request, so a response cannot pivot the request to another address. - Add a test that captures the get_lists() request and asserts the host is the validated data center and redirection is 0.
There was a problem hiding this comment.
🟡 Changes requested
The proxy issue is fixed, but the subscription PUT still has no redirect test, as the earlier thread asked.
Validation details
- Files reviewed: 2/2 changed files. Commit
e7737cdis the only commit since the last review. cd /repo && set -o pipefail; timeout 300 vendor/bin/phpunit --do-not-cache-result --filter 'Test_Mailchimp_Provider::' 2…printedOK (5 tests, 24 assertions)(run R2)- The A/B helper log (
/workspace/checks/T1/ab2.log, not recorded) shows that the new test fails on the base tree at theredirectionassertion. - WordPress 7.1.5 source: an empty
redirectionsetsfollow_redirectsto false, so no redirect is followed. - The
phpcs:ignorecomments match pr-base.
Untested areas
- The variant pass did not run again. The new commit does not touch admin-configured URLs in template cloud, options settings and otter-pro webhooks.
- The JavaScript and browser checks did not run because the frontend build is absent.
🤖 Automated review · run code-review-agent_6b00834fd10058.48462221.
🤖 Review agent — review posted ✅ on e7737cd5 · changes requested · 2 findings · 14 min
Run code-review-agent_6b00834fd10058.48462221 · trail
…omment - Keep the redirect rationale on one line only, not repeated on all four. - Extend the request test to also drive get_merge_fields() and the subscribe path (status GET + members PUT), asserting the pinned host and redirection => 0 on every captured request, so dropping the guard from any single request builder fails the test.
There was a problem hiding this comment.
🟢 Approved
The PR passes: the redirect test now covers every Mailchimp request, and the repeated comment is gone.
Validation details
- Files reviewed: 2/2 changed files. Commit
8ed34f8is the only commit since the last review. cd /repo && set -o pipefail; timeout 300 vendor/bin/phpunit --do-not-cache-result --filter 'Test_Mailchimp_Provider::tes…printedOK (1 test, 10 assertions)(run R2)- The test captures four requests, all with
redirection0 (run R4). - Removing
'redirection' => 0from any one of the four request builders fails the test (run R5). - On the base tree, the test fails with
Failed asserting that 5 is identical to 0.(helper log, not recorded).
Untested areas
- The variant pass did not run again. The new commit changes only a test and three comments.
- The JavaScript and browser checks did not run because the frontend build is absent.
🤖 Automated review · run code-review-agent_6b0089e6b42a56.98368096.
🤖 Review agent — review posted ✅ on 8ed34f84 · approved · 0 findings · 4 min
Run code-review-agent_6b0089e6b42a56.98368096 · trail
|
🎉 This PR is included in version 3.2.12 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
The Form block builds its Mailchimp request host from the API key: the part after the dash becomes
https://<data-center>.api.mailchimp.com/....validate_api_key()only checked that the key had a single dash, so the data center could contain a host, a port and a path. A Contributor could submit such a key to the form editor endpoint and make the server request an arbitrary host, including internal services (authenticated SSRF). The request also usedwp_remote_get()/wp_remote_post(), which follow redirects to private addresses.What changed
Mailchimp API key validation —
validate_api_key()now requires the data center to be a bare[a-z0-9]+token, so the host can only resolve to*.api.mailchimp.com.server_nameis set only throughset_api_key(), which runs this validation first, so the editorlistId/testEmailand the frontendsubscribepaths are all covered.Mailchimp requests — every Mailchimp call now uses
wp_safe_remote_get()/wp_safe_remote_post(). A redirect to a private or loopback address is refused, as defense in depth.Note
A normal key (
<secret>-us1,<secret>-us21) keeps working. The Sendinblue/Brevo provider was never affected (fixed host).QA
Go to
WP Admin → Pages → Add New. Add a Form block. Open its Integrations settings and select Mailchimp.Paste an API key whose data center segment is not plain letters and digits (for example a value containing a colon, slash or dot after the dash). Save.
Expect: the integration reports an invalid API key format and no list is fetched.
Paste a real Mailchimp key (
<secret>-us1). Save.Expect: the lists load as before.
Reported-by: Deus Rex research team research@deusrex.ai
Tracked internally in Codeinwp/otter-internals#318 (target branch is
development, not the default, so this does not auto-close — link it through the Development sidebar).Review responses
<secret>-<dc>where the data center is lowercase letters and digits (us1,us21, …);^[a-z0-9]+$accepts every real data center. Mailchimp has no uppercase data centers. Thewp_safe_*proxy concern was addressed by reverting towp_remote_*+redirection => 0.