Summary
MyBB contains a username-based cross-site scripting vulnerability in the Buddy/Ignore and Private Messages Select Buddies features. A specially crafted username may be rendered with an unescaped single quote, allowing script execution when a victim removes the user or selects the username from the affected interface.
Affected context
The issue occurs in MyBB installations that use the affected Buddy/Ignore and Private Messages workflows to display usernames in HTML or JavaScript event-handler contexts. Risk is higher when an attacker can create or control a username and a victim with an active session interacts with the confirmation dialog or Select Buddies popup.
Exploit preconditions
- Attack surface: User Control Panel Buddy/Ignore lists and the Private Messages Select Buddies popup
- Required access: The ability to register or otherwise control a username that is displayed by these features
- Trigger point: A victim removes the username and confirms the action, or selects it through the popup
- Why exploitation is possible: Username output is not safely encoded for every surrounding context, allowing a crafted single quote to affect generated markup or an event-handler expression
Why this happens
The vulnerability results from context-incomplete output encoding. Although usernames are passed through htmlspecialchars_uni(), the resulting encoding may leave single quotes unsafe for the JavaScript or quoted-attribute contexts used by the affected Buddy/Ignore and Select Buddies interfaces. This allows attacker-controlled username data to alter client-side code execution paths, mapping to CWE-79: Improper Neutralization of Input During Web Page Generation.
Potential impact
- An attacker may execute JavaScript in a victim's browser
- The script could perform actions using the victim's authenticated session
- Sensitive information displayed in the affected origin could be exposed
- User-interface content or workflow behavior could be modified
- Additional accounts or users could be targeted through stored malicious usernames
General mitigation guidance
Mitigation generally focuses on treating usernames as untrusted data in every output context.
Common defensive patterns include:
- Applying context-appropriate output encoding for HTML text, HTML attributes, and JavaScript values
- Avoiding direct insertion of user-controlled data into inline event handlers
- Passing values through data attributes or structured DOM APIs instead of constructing code strings
- Enforcing server-side username validation and restricting unsafe characters where compatible with application requirements
- Using a restrictive Content Security Policy to reduce the impact of script injection
- Applying least privilege to authenticated sessions and sensitive user-management actions
How teams detect issues like this
Organizations can look for this class of issue through:
- Static analysis rules identifying user-controlled values inserted into HTML attributes, JavaScript strings, or inline event handlers
- Code review checks for encoding functions that do not match the output context
- Tests using usernames containing quotes and other delimiter characters across Buddy/Ignore and Private Messages workflows
- Dynamic testing that observes whether controlled usernames alter generated markup or execute as script in a browser
- Content Security Policy reporting and web-application monitoring for unexpected inline script activity
Automated security review tools may help identify unsafe output construction, but findings should be validated against the actual rendering context.

