Description
An unauthenticated SQL injection vulnerability exists in miniBB through insufficient validation of the X-Forwarded-For HTTP header in the getIP() function (bb_functions.php). The function accepts the header value if it matches an IPv4 or an IPv6 regular expression. The IPv4 pattern is anchored with ^ and $, but the IPv6 pattern is not, and PHP's preg_match() succeeds when the pattern matches anywhere inside the subject. The IPv6 pattern contains an alternative that matches a bare ::, so any header value containing :: anywhere passes validation and becomes the visitor's "IP address".
The resulting value reaches SQL queries unescaped, because the database helpers (db_simpleSelect(), db_ipCheck(), insertArray(), updateArray()) build their statements by direct string concatenation. Reachable pre-authentication locations include:
bb_func_fla.phplines 24, 50, 63 and 68 (failed-login handling,POST mode=login)index.phpline 362 (db_ipCheck(), any POST request)bb_func_ptopic.phpline 66 (anonymous new topic)bb_func_pthread.phpline 81 (anonymous reply)
Proof of Concept:
curl -H "X-Forwarded-For: 1' or sleep(5)-- ::" -H "Referer: http://HOSTNAME/" \
--data "mode=login&user_usr=user&user_pwd=wrong" \
http://HOSTNAME/index.php
The response is delayed by 5 seconds, confirming injection into WHERE forced_ip='...'. The Referer header must contain the forum URL to pass the built-in POST filter.
Impact
An unauthenticated remote attacker can execute arbitrary SQL against the forum database, including time-based or error-based blind extraction of member records and password hashes, and can forge the ban-check query to bypass IP bans.
CVSS 3.1 base score: 8.2 High (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:N).
Solution
Fixed in miniBB 3.8. Upgrade to 3.8 or later. To patch an older install by hand, anchor the IPv6 pattern with ^ and $ exactly like the IPv4 pattern, or replace both checks with filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) / FILTER_FLAG_IPV6.
Timeline
- 2026-09-25: Reported to the miniBB maintainer, together with the other miniBB 3.7.2 issues.
- 2026-10-01: The maintainer sent a pre-release with the fix (
getIP()now validates addresses withinet_pton()instead of the unanchored IPv6 pattern). Fix verified. - 2026-11-20: Fixed in miniBB 3.8. Report published.