antispambot does not always escape <, >, &, " and '
The antispambot function randomly escapes characters, including sensitive ones like <, >, &, ", and ', so it may output them unescaped. An attacker could inject client-side code if a plugin passes untrusted input to antispambot, though success is probabilistic.
- Disclosed after 21 months
The antispambot function escapes some randomly selected characters from its first argument, for example:
<?php
echo antispambot( '[email protected]' );
This would print out:
example@example.com
Since this returns HTML, developers are not going to use esc_html with the return value of antispambot, since that would double-escape the result. Developers will assume that this function can be safely used with untrusted email addresses, which is a fair assumption. However, it turns out that antispambot cannot be trusted. Whether a character is escaped is randomly selected, even if the character is <, >, &, ", or '. These last five characters should always be escaped.
There is a chance that this will print out unescaped:
<?php
echo antispambot( '<script>console.log("hello");</script>');
Even though the chance of this happening is low, with enough repetitions this could happen eventually.
antispambot should always escape the five sensitive characters.
Impact
If antispambot is being used by a plugin that passes to it untrusted input, an attacker could cause arbitrary client-side code to run. Since the probability of all of the characters remaining unescaped is low, only a small fraction of the attacks would succeed, and the attacker would need the ability to attack many times to see a few successes.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
If a plugin passes untrusted input to antispambot, an attacker could cause arbitrary client-side code to run, but only a small fraction of attacks would succeed and many attempts are needed.
What the attacker needed
Plugin uses antispambot on untrusted input; attacker can make many attempts
The fix
antispambot should always escape the five sensitive characters.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A function meant to hide email addresses from spammers randomly decides which characters to encode. It sometimes leaves dangerous characters like < and > as they are, so if a developer uses it on untrusted input, malicious code could run in a visitor's browser. The chance is low per attempt, but repeated tries could eventually succeed.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.