TOTP issuer shows HTML entities when the site title has an ampersand
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- authentication, security
Research direction
The bug is in Two_Factor_Totp::generate_qr_code_url(), which reads the site name with get_bloginfo( 'name', 'display' ) and then passes it to rawurlencode() for the issuer and label. Start by reading that function and checking how the display filter escapes the title. Done means an ampersand, apostrophe or quotation mark in the site title appears unescaped in the otpauth:// URL, and the existing TOTP tests still pass.
Written by the indexing model from the issue text.
Description
Description
When the site title contains an ampersand, the TOTP setup link and QR code carry the HTML entity instead of the character, so the authenticator app shows A & B as the account's issuer.
Two_Factor_Totp::generate_qr_code_url() reads the issuer with get_bloginfo( 'name', 'display' ). The display filter escapes the title for HTML, so A & B becomes A & B before it is passed to rawurlencode() for the issuer parameter and the label.
Steps to reproduce
- Set the site title to
A & B. - Open a user profile and start TOTP setup.
- Inspect the
otpauth://link, or scan the QR code.
Expected
otpauth://totp/A%20%26%20B%3A<login>?secret=…&issuer=A%20%26%20B, shown in the app as A & B.
Actual
The issuer and label contain %26amp%3B, shown in the app as A & B. Titles with an apostrophe or quotation marks are affected the same way.
Suggested fix
Read the raw value and decode entities before encoding: wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ).
Environment
Two Factor 0.17.0. The same line is on the default branch today.
- Dominant language
- PHP
- Stars
- 824
- Forks
- 191
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 25
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from WordPress/two-factor
-
Reject oversized TOTP confirmation codes before validationPossibly taken @chubes4 claimed this 95 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
WordPress/two-factor#936 ·
Maintainers usually reply within 1 day
-
Privacy: register a personal data exporter and eraserPossibly taken @faisalahammad claimed this 30 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
WordPress/two-factor#954 ·
Maintainers usually reply within 1 day
-
Enrolling a second factor destroys the user's other sessions and sends no notificationPossibly taken @masteradhoc claimed this 28 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 68/100
WordPress/two-factor#953 · 1 assignee ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
WordPress/two-factor#951 · 1 comment ·
Maintainers usually reply within 1 day
-
Password managers can capture the TOTP setup QR and lock users out of loginPossibly taken @faisalahammad claimed this 18 days ago. OpenEmailed Codes TOTP
Difficulty 5/5 Over a week Newbie friendliness 35/100
WordPress/two-factor#945 · 3 comments ·
Maintainers usually reply within 1 day
All issues in WordPress/two-factor
Similar issues
-
frontend good first issue healthcare-review
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
AfyaLinkAfrica/afyalink-web#25 ·
Maintainers usually reply within 1 day
-
priority:medium type:chore
Difficulty 1/5 1-3 hours Newbie friendliness 84/100
crazy-goat/php-fpm-ng#1041 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
backdrop-contrib/paragraphs#299 ·
-
bug elixir P2 php test-only
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day