Malware issues with phpBB

As I do work for lots of different clients, I see patterns that others may not. Recently I’ve been seeing frequent malware issues on mostly older phpBB 3.0 forums. Since it’s malware, it’s often hard to know that you have malware. The malware may not be doing anything malicious to your web site, but it is trying to infect the computers of the users of your forum.

Do you have malware?

There is no way to really know if you have malware or not without comparing the version of phpBB you have installed with a reference version. If your forum seems to be operating normally, you will have no reason to check for malware. But if a forum that was recently running optimally now seems slower, particularly when loading pages, this might point to a malware problem. You or users accessing your forum might have antivirus tools installed that may detect malware.

Is phpBB software introducing your malware?

Almost certainly not. Rest assured that the phpBB Group spends considerable time and effort to check software it releases for security issues. In fact, it uses some of the best software available to find potential issues so they don’t occur. So it’s unclear to me how this malware is being introduced, but rest assured it’s not an issue with anything the phpBB group has done.

That said, the phpBB group has improved its security practices over time. One thing that has changed is it is judicious about using PHP eval() statements. They have not all been removed but where they are used they are marked as exceptions in the code. PHP eval() statements are dangerous because any code placed inside the parentheses is evaluated and executed. Since you don’t know what the code will be in advance, any use of eval() introduces a potential vulnerability to phpBB.

How is malware getting on a forum?

It’s hard to say definitively how this malware is getting introduced. Most likely it is being introduced by wrong permissions on phpBB folders and files. In phpBB only the files, images/avatars/upload and store folders should be publicly writable (0777 permissions). It’s critically important to make sure that your forum’s config.php file is not publicly writeable. You can use tools like your web host’s File Manager or an FTP program like Filezilla to check your folder and file permissions and correct as necessary.

Malware could also be introduced by sloppy server management by your web host.

Possible malware symptoms

If your forum comes to a halt rather unexpectedly, malware may be the cause. For example if you cannot login and you were previously able to login, this may be due to malware. What I often see are HTTP 500 (Application errors) reported. HTTP errors are usually written to a log. Sometimes you will find that your web server puts a file named error_log in your phpBB root folder, or in your web root folder. Examine the error log at the time the error occurred and see if there are any messages. In particular if there is an error message saying a PHP eval() statement failed, this may point to a malware issue.

How do I know if my forum’s files have malware?

As I mentioned, the only way to know for sure is to compare your forum’s files with a phpBB reference. I usually find malware at the top of certain or all .php files. You can use these procedures. This is obviously a lot of work. If you prefer, I can do this and fix most issues found for 1-2 hours of labor ($30 – $60). Contact me.

  1. Determine the version of phpBB you are using. If you can get into your Administration Control Panel, it will show the phpBB version on the main screen. If you can’t this SQL query using a tool like phpMyAdmin will tell you. You must be in the database containing your forum. If you are unsure what the name of the database is, you can see it in your config.php file. On the SQL tab execute paste the following SQL. (Change the table suffix if necessary to what you are using):
    select config_value from phpbb_config where config_name = ‘version’;
  2. Download a copy of the official version of phpBB that you have installed and expand the archive. All versions can be found here. For phpBB 3.0, you can also find it here.
  3. Install a tool that can compare files and directories. If you are using Windows, WinMerge is an obvious choice. For the Mac, if you know Unix there is the Unix diff command but it’s not easy to use. For Mac or Linux, I recommend kdiff3 which is also available for Windows and most Unix variants.
  4. Use FTP to download your phpBB forum files to your local computer. Keep it in its own directory. Note: this can be quite time consuming particularly if you allow users to upload files and images. You might want to skip downloading the files, images and cache folders.
  5. Compare your phpBB programs with the referenced version. If introduced, malware it is most likely in .php files, but could possible be in .html or .js files too. The tool will highlight files and folders with differences. Malware is most likely to be seen at the top of the file probably inside of a long PHP eval() statement. They should stick out like sore thumbs as the malware code will look odd and different. Note: some differences could be due to installing phpBB 3.0 modifications.  phpBB 3.0 modifications work by changing phpBB’s source files.
  6. Upload clean versions of uninfected files from your reference, Make sure you are replacing the old programs. Note: if there is malware in config.php remove it manually using the File Manager’s edit function. You want to preserve the lines that are critical to integration of the database.
  7. If most files are infected, you might want to replace all the files. If you do this:
    1. Backup your files and the database just in case.
    2. Do not replace the config.php file, but edit as in Step 6.
    3. If you see no malware in the style folder, don’t upload that as it’s unnecessary and you may overwrite changes made to your style for your logo, unique colors, etc. If you have to remove malware from a style folder, it’s best to do it carefully and edit out the malware on a file-by-file basis.
    4. Do not remove valid files such as uploaded images and documents in the files and images folders.
    5. If you are using phpBB 3.0 and have modifications installed, you will have to edit any files that the mod changes to regain the functionality of the mods. The install.xml file for the mod should detail all the file changes needed. You should also be able to see these changes using your file difference program.
  8. Run and test phpBB. Everything should behave normally.

Preventing malware

  1. Make sure your forum’s file and folder permissions are set correctly. See above.
  2. Upgrade or update your forum to the latest version of phpBB.
  3. Make a practice of updating your forum soon after new releases of phpBB are announced. Releases contain fixes for any security issues found.
  4. Many web hosts offer Apache ModSecurity that can be enabled in the web host control panel. Sometimes it is enabled by default. While enabling ModSecurity can prevent a lot of problems, my experience is that phpBB and ModSecurity don’t work well together. It may introduce its own HTTP 500 errors. You can try enabling it and see if it doesn’t cause issues. Disable it or add code to your forum’s .htaccess file to disable inside your forum if issues occur.


Setting up your forum, part four (picking, installing and enabling extensions)

(Read parts 1, 2 and 3.)

Once you have installed your phpBB forum, created the forums you need, installed and configured a style, and set up your user groups, generally the next thing to do is install any needed extensions.

What are extensions?

Extensions apply to phpBB 3.1 and higher. They are somewhat analogous to WordPress plugins and allow you to somewhat easily add additional functionality to phpBB beyond what comes “out of the box”. While not as numerous as the 44,000+ plugins available for WordPress, the number of extensions for phpBB grows regularly over time and should continue to do so. Note: phpBB 3.0 does not support extensions, but does support modifications.

Why are there so few extensions?

One reason there are fewer extensions for phpBB than there are plugins for WordPress is that extensions are a relatively new feature of phpBB. phpBB 3.1 was the first version to support extensions and it is about two years old. Another reason is that extensions are harder to write than WordPress plugins. I should know as I am the author of the Digests and Smartfeed extensions. As of this posting, only my Smartfeed extension has been approved. There is a lot to learn to write an extension and arguably it takes a senior PHP developer to write an extension, as it has a complex framework and a lot of onerous coding standards that must be adhered to. Only approved extensions are released in phpBB’s extension database. Just getting a review can take months, as I discovered.

Official extensions

Do you need to install extensions? If so, which ones? phpBB out of the box is quite feature rich. But there are common things that forum administrators want to do beyond what is available by default. Take for example some of the official phpBB extensions. These are so common that they are developed and maintained by the phpBB group. These include;

  • Pages – creates static pages that convey common information, such as a news page for your site
  • Board Rules – similar to pages, used to convey your policies for use of your forum
  • Auto groups – eases group management by setting up rules for putting people in and taking them out of groups
  • Board announcements – puts a “no way can you miss this” announcement at the top of every page viewed
  • Collapsible forum categories – allows users to collapse and minimise forum categories with a simple click, so they see only categories and forums that interest them
  • Google analytics – Provides a field for an administrator to enter their Google Analytics tracking code, so all web page usage is reported to Google Analytics. This way you can watch usage of your site, see popular pages and gain insight into how your forum is being used inside Google Analytics.

Finding extensions

phpBB’s extensions database contains a list of all approved extensions. Extensions are categorized and searchable but even so it can be hard to find an extension that meets your need. The extension you want may not exist. You can propose it and hope someone will take it up as a project. If someone does, don’t expect it to be something simple to do. At best it takes months to develop, test and get an extension approved.

Installing, updating and deleting extensions

Installing an extension is not as simple as installing a WordPress plugin, at least for phpBB 3.1. This is likely to be more intuitive in future releases of phpBB. Right now you must download the extension, unzip it then upload it to your forum’s ext directory. Here are the steps for installing, updating and removing extensions. An extension is actually a directory inside of another directory. The extensions architecture requires it be placed in a vendor directory. This allows one vendor to write multiple extensions but keep them separate. For example, for my two extensions, Digests is placed in ext/phpbbservices/digests and Smartfeed is placed in /ext/phpbbservices/smartfeed.

Recommended extensions

Let your requirements dictate which extensions you install. Don’t install extensions that you don’t plan to actively use.

Based on extensions I have installed for clients, these extensions tend to be particularly useful:

  • Google analytics (see above)
  • Pages (see above)
  • Share on – allows topics and posts to be easily shared on various popular social media platforms
  • PayPal Donation – allows you to ask for donations via PayPal
  • phpBB Gallery – allows users to have their own photo gallery inside of phpBB
  • Stop forum spam – checks the username, email address and IP of posters against blacklists, to reduce spam posts
  • AJAX shoutbox – Allows users to leave short tweet-like messages when they are on the forum, separate from phpBB’s forum and post system. Users on the forum at the same time can chat this way.
  • Copyright in footer – adds a copyright statement to the bottom of each page if you claim copyright on your forum’s content.
  • Board3 Portal – Provides a portal-like experience for phpBB, allowing sidebars for additional content to be seen on a portal page. With an additional change to your .htaccess file, you can redirect the forum to go to the portal page by default.
  • Sortables CAPTCHA – Provides a new spambot countermeasure where “correct” content must be dragged into an appropriate column. This can be used during registration to add greater assurance that a human is registering.
  • AdSense – Serves a horizontal Google Adsense ad immediately after the first post of a topic on a page. You have to get a Google Adsense account and set up the ads on that site first.
  • Recent topics – display topics with recent posts and replies on the index
  • Smartfeed – This is my extension. It makes your forum accessible to news readers. Since phpBB has an Atom feature built in for public forums, this extension is most useful if you want to support RSS feeds or for users that want to access protected forums securely using their newsreader using services like Feedly. This is done through creating an authentication key using the Smartfeed user interface.

New extensions are regularly added, so make sure to check the current extension database periodically. Many extensions are in development and when approved they will be added and widely used.

Extensions issues with upgrades to phpBB

When you move between one major version of phpBB and another (such as from 3.1 to 3.2) some of your extensions may not work. You can see the versions of phpBB that the extension supports in the Administration Control Panel: ACP > Customize > Extensions Management > Manage extensions. Click on the details link for the extension. If a given extension is critical to your forum, do not upgrade to a new major version until the extension is updated to work for the new major version.

November 2016 work summary

Here is some of the work I did for clients in November. I also released version 3.0.7 of my digests extension that involved a considerable amount of time and effort during November.

  • Some non-phpBB work. I worked on refining a WordPress widget to show a picture of current snow conditions for a client’s WordPress site. Since the client has a retinal device and found the picture uploaded a bit fuzzy, I found and installed a WordPress plugin that creates retinal images and intelligently serves them if it detects the device supports retinal images. I also edited the widget’s stylesheet to reduce the margins so it fits the sizing of other content. I also changed media library medium image setting to 332 pixels width to fit the image container optimally. I also provided instructions on how the client can do this himself in the future so images can be swapped in and out based on current conditions.
  • Digest troubleshooting. Digests stopped going out for a client that had version 3.0.6 of my digests extension installed. It appears this was due to incorrectly programming a system cron. After testing I used my “shared hosting” approach for doing a system cron which recognizes that on shared hosting where cron’s with multiple commands don’t work. This involved changing the cron to call curl instead and turning off the system cron capability inside phpBB. I filed a bug report on about what I think is insufficient explanation text for the system cron control in the ACP.
  • A client upgraded his forum to phpBB 3.1 but there were dead modules in the ACP. Installed us_en language pack to fix certain issues. I deleted bad module links for digests mod and the advanced block mod. I installed Digests 3.0.6 but had to manually change the database to get it to install on 3.1.10. I installed Cleantalk but waiting on activation key. I manually tested digests and it worked. Client chose to defer the cron installation until after rehosting. Days later I ended up redoing the work due to the client moving to a new host running Linux, not Windows. I upgraded forum from 3.0.12 to 3.1.10. I changed email settings to turn off SMTP since client is not on Windows anymore. To get the forum to come up I had to edit the config.php file and change the value of $dbms and $acm_type, which had namespace syntax in it that was triggering an error. I installed the American English language pack again. I installed the Cleantalk extension again. I installed and tested the digests extension. This took quite a bit of time because of known issues with the 3.1.10 migrator. I had to make a number of database changes manually. I then did a manual test of the mailer and it worked. I then created a cron job and verified that it sent digests. I found a peculiar quirk: clicking on the extensions tab generates a HTTP 500 error if debug is not turned on in the config.php file.
  • I programmed a scheduled cron for digests because users like to receive digests in hour requested. As with the other client, I ended up with a scheduled phpBB cron due to shared hosting issues not allowing multiple statement in a cron.
  • I replaced an ad at top of the page with one provided that had slightly different dimensions.
  • I moved a forum from to shared hosting. I upgraded the forum from 3.0.14 to 3.1.10. I installed Cleantalk. Later I patched a bug in 3.1.10 that didn’t allow custom profile fields or search engine settings to be changed.
  • I fixed a malware issue for a client. Most directories had a new .php file in it, consisting of six random letters, with an eval statement likely injecting malware. A routing error occurred when accessing the forum. I eventually figured out a bad .htaccess file was the reason the forum did not come up, so I copied in a standard .htaccess file. I then compared his software with 3.1.5 and saw the malware problem by comparing client’s files with a reference. I carefully removed all software files, uploaded a referenced version of these files and manually deleted malware files in some directories that should not be deleted. It solved the problem. I then upgraded the forum to 3.1.10.
  • Client attempted upgrade from 3.1.7-PL1 and it failed with a HTTP 500 error. I puzzled through it but eventually deleted all files but the files, images, store directories and config.php and uploaded 3.1.10. I then ran install/database_update.php and upgrade completed. I re-uploaded the backup I had of his black style and the forum came up. However, I couldn’t login with his old credentials. So I created my own account and gave myself founder permissions in the database. Client could not login either. I provided instructions to use the lost password link.
  • Client with my digest extension said it was sending out duplicate digests. I upgraded digests from 3.0.5 to 3.0.6 but that did not solve the problem. After some debugging I determined this was due to digest exception being thrown if there are no bookmarked topics. This stops remaining digests from going out for the hour and the hour will not mark as completed. I fixed this bug in version 3.0.7 and didn’t charge the client for my work.
  • Client was concerned that the public saw a “no forums” message. His new forum was created without using the copy permissions function. I added these permissions so public could see forums.
  • Issue with using advanced BBCode extension and creating and editing BBCodes so that tables, table rows and table columns could appear in a post. I fixed client’s BBCodes to substitute the correct HTML when creating tables, table rows, table columns and to properly align text.