Decide: a magic link shown as plain URL text can be fetched by WordPress and burn its single-use token

Đang mở
#2,140 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
20/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
php, wordpress
Lĩnh vực
authentication

Hướng nghiên cứu

The bare URL is printed in url mode in views/dashboard-widgets/magic-link-url.php, lines 20-24, and the mismatch handling is in verify_and_consume_token() in inc/sso/class-magic-link.php. Reproduce first: a page holding only the shortcode with display_as="url" in a block theme, then check whether a WordPress/ user-agent request reaches the token URL. The issue asks for a maintainer decision on the mismatch behaviour before any change, so the first step is to get that decision. Done means the url output no longer triggers autoembed and anchor and button modes are unchanged.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug hold-for-review no-auto-dispatch origin:interactive status:available

Decision needed

A magic link shown in the "Plain URL Text" display mode (display_as="url") can be fetched by WordPress itself while the page renders. That consumes the single-use token, so the customer's later click fails. How should that be prevented?

Found while re-verifying the account area after #2133. Not caused by it: neither file below changed there.

Premise check

Correct, reproduced on a block theme with a page containing only [wu_magic_link_url display_as="url"].

Evidence, in order:

  1. The page render generated a token bound to the browser's user agent. The server's own request log shows a request for that exact URL 23 seconds later, with the user agent WordPress/<version>; <site url> (the WordPress HTTP API), which followed the 301 to a 200. The browser's use of the link came after it.
  2. The magic-link log then reads User agent mismatch. Expected: <browser UA>, Got: WordPress/<version> and Security context mismatch, followed by Token not found or expired for every later attempt.
  3. A temporary pre_http_request hook recorded the caller. The stack is core only: render_block_core_pattern calls WP_Embed::autoembed, which calls WP_Embed::shortcode, wp_oembed_get, WP_oEmbed::discover and wp_safe_remote_get. WordPress treats a URL that is alone on a line as an embed and runs oEmbed discovery on it.
  4. Control: the same page in the default link mode (display_as unset, rendered as an anchor) made zero server-side requests, and the link signed a fresh logged-out browser session in as the customer, landing in the subsite admin.

Where it comes from:

  • views/dashboard-widgets/magic-link-url.php lines 20-24 print the bare URL, surrounded by blank lines, with no wrapper, in url mode. That is the shape autoembed matches. The anchor and button modes are inside an element and are unaffected.
  • inc/sso/class-magic-link.php, verify_and_consume_token(): on a user-agent or IP mismatch it runs delete_transient() on the token before returning false, so a single request from another client, including a server-side one, invalidates it for the real user.

Analysis

  • The token is bound to the generator's user agent and IP on purpose. Deleting it on mismatch is a conservative choice: a token presented from another client is treated as leaked.
  • Any automated client that follows links has the same effect: a mail scanner, a link previewer, a prefetcher. WordPress autoembed is one instance that is easy to trigger.
  • Changing the url output (for example wrapping it) would stop autoembed, but the mode exists to give raw URL text, possibly for use inside markup, so wrapping may break existing usage.
  • Not deleting the token on a mismatch removes the burn, but leaves a token that someone else presented valid until it expires (TOKEN_EXPIRATION, 600 seconds).

Recommended path

  1. Keep the mismatch behaviour as is. It is a security decision and the evidence here is about one display mode.
  2. Make url mode not print the URL alone on a line, for example by emitting it with no surrounding newlines so it is inline wherever it is placed, and document in the shortcode catalogue and the element's description that anchor or button should be used when the link is shown on a page.
  3. Reconsider the delete-on-mismatch behaviour separately if emailed magic links turn out to be burned by mail scanners.

Verification, if this is built

  • A page containing only the shortcode in url mode, rendered in a block theme: the request log shows no WordPress/ request for the token URL, and the link signs a fresh logged-out session in.
  • The anchor and button modes are unchanged.
  • A temporary pre_http_request hook that logs requests to URLs containing wu_magic_token is a quick way to check for a server-side fetch.

Files Scope

  • views/dashboard-widgets/magic-link-url.php
  • inc/ui/class-magic-link-url-element.php

aidevops.sh v3.39.189 plugin for OpenCode

Ngôn ngữ chính
PHP
Star
219
Fork
88
Merge trung bình
1 ngày 7 giờ
Pull request đã merge (30 ngày)
58

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Ultimate-Multisite/ultimate-multisite

Tất cả issue của Ultimate-Multisite/ultimate-multisite

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.