Opened 3 weeks ago
Last modified 3 weeks ago
#66391 reviewing defect (bug)
`get_allowed_http_origins()` should not trust the insecure origin of an HTTPS site
| Reported by: | johnbillion | Owned by: | johnbillion |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.3 |
| Component: | HTTP API | Version: | |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: |
Description
The get_allowed_http_origins() function always adds both the http:// and https:// variants of the admin and home host to the allowed origins list, regardless of the site's scheme. On a site served only over HTTPS, the http:// origin is therefore trusted even though the site doesn't use it.
This feeds send_origin_headers() which reflects a matching Origin into Access-Control-Allow-Origin. A network attacker who can tamper with plaintext HTTP traffic can issue a credentialed cross-origin request to the HTTPS site and read the response.
Fix: Add the http:// origin only when the corresponding admin_url()/home_url() is not HTTPS.
Related: #43428
Originally reported by talkemade on HackerOne.
Change History (3)
This ticket was mentioned in PR #15002 on WordPress/wordpress-develop by @johnbillion.
3 weeks ago
#1
- Keywords has-patch has-unit-tests added
@sadmansakibnadvi commented on PR #15002:
3 weeks ago
#3
Tested 5695cb8 on 7.2-beta3-64990. Home and admin share a host here. I forced HTTPS per request with home_url / admin_url filters, and sent Origin headers without a port, since origins are compared by host only.
get_allowed_http_origins():
| Site | Before | After |
|---|---|---|
| HTTP home and admin | http, https | https, http |
| HTTPS home and admin | http, https | https only |
| HTTPS admin, HTTP home | http, https | https, http |
End to end, Access-Control-Allow-Origin from admin-ajax.php:
| Site | Origin | Before | After |
|---|---|---|---|
| HTTP | http:// | sent | sent |
| HTTP | https:// | sent | sent |
| HTTPS | http:// | sent | not sent |
| HTTPS | https:// | sent | sent |
So an HTTPS site no longer echoes an http:// origin, and mixed setups keep both. No notices from the new code.
get_allowed_http_origins()added both thehttp://andhttps://variants of the admin and home host unconditionally, so an HTTPS-only site trusted anhttp://origin it never uses. This adds thehttp://origin only when the correspondingadmin_url()/home_url()is not HTTPS, evaluated independently for each. Includes unit tests.