Support » Fixing WordPress » Security: Someone uploaded bogus files to wp-content – 2.5

  • I installed the new version on my blog this past weekend. In process of doing so, I found something quite disturbing. In two recent (but pre-update) posts, I found “noscript” content referring to free online poker games. A further search revealed a folder under wp-content with lots of HTML documents related to that content–documents I didn’t place there.

    Everything on the installation was (and is) flagged as suggested in “Hardening WordPress.” The wp-content folder itself has 7-5-5 permissions. Visitors need to be registered and logged-in to comment, but the offending code was in a post. My username and password are good as far as security, and I have changed my password after this incident. This is a low-volume site, used primarily to support my business. It’s kind of frustrating to see that the site itself is ranked third on Google when I search for it. (Places 1 and 2, plus about ten pages of other links belong to the bogus code!!)

    I am about to install the AskApache Passsword Protection Plugin. At this point, I am using Akismet, Sem-Subscribe-me, and the All-In-One SEO Pack.

    My questions are:
    1) How was somebody able to get into a post of mine to modify it in the first place?
    2) How were they able to write to a directory with only user access?
    3) What can I do to prevent such invasions in the future–what was I doing wrong to begin with?


Viewing 13 replies - 1 through 13 (of 13 total)
  • Sigh.




    your post is unclear ..

    the topic title suggests that this occurred post 2.5 install, however, you say this:

    In two recent (but pre-update) posts, I found “noscript” content referring to free online poker games. A further search revealed a folder under wp-content with lots of HTML documents related to that content–documents I didn’t place there.

    Thats slightly contradictory.

    Change your administrator password.

    Look for any administrator level accounts you dont recognize.

    You also say this:

    How were they able to write to a directory with only user access?

    I have to ask you why you think thats the case?

    Thank you for your reply. I apologize for the lack of clarity.

    I discovered the “invasion” in process of preparing for my upgrade to the new version, which would have been late last Saturday or early Sunday. I ordinarily have a look at things every day, but a family emergency had occurred. The fact that it was “upgrade weekend” was, I believe, a coincidence.

    I changed the passwords immediately, and there aren’t any extra accounts with administrator access.

    The directory (wp-content) and all directories beneath it have their permissions set at 755. This seems to be the least I can get away with. If there are lesser permissions that would be workable, it would be very helpful to know this.

    Again, thanks for your reply.





    If you discovered this post-update and you are confident that you have no rogue admin. accounts, and no a brand new password..

    I would also change your MySQL password.

    You ought to let your host know as well, it’s a courtesy thing, at the very least.

    Make sure that your upgrade was a complete one — by that, I mean, hopefully you successfully replaced all of the files that were on your site with the new 2.5 ones.

    Also, make sure that you do not have any insecure plugins on your site. I usually check in at atleast once every 2 days. There’s a wordpress-related exploit on there that is as recent April 31.

    Searching milw0rm is very easy..go here:

    type in WordPress, and see what pops up, making sure that nothing on your site is also mentioned on their site.

    With that info, bear in mind, that a deactivated plugin is no more secure. If ever you find that something you are using is listed there, delete it completely, dont just deactivate it.

    755 is the necessary permissions for Apache to be able to serve content on most servers.

    Files should be chmod 644, at the very most.

    Post-upgrade, really all you can do is what I have mentioned.

    Yah, I redid all the passwords just after it happened, and since I am my own host, I have given myself a sternly worded lecture. At this point, when I have a few hours, I may be able to pinpoint via the logs exactly when the intrusion occurred. At that point I can also block any “unfortunate” IP addresses.

    Files and directories are as you suggest. I believe (but am not certain at this point) that the directory where the bogus files were located was a relic of an old photo album plugin long since deactivated. (Just as you have said about old plugins.)

    Your link is invaluable–I can use it regularly to check for all sorts of things. Thank you for posting it.

    Meanwhile, I feel encouraged that I’ve taken as many steps as I can to secure the installation, and I sincerely appreciate your taking the time to share this information with me.






    If your so inclined, I have provided a way of logging $_POST variables sent to WP.. you can read about it on my own blog. Follow the link that is my name here, and its the most recent post.

    I was initially hesitant to share that with you, but since you mentioned doing your own hosting, I’m guessing you would be comfortable with the necessary editing.

    If you need help, with anything, feel free to contact me off the forum — just remind me who you are, I get a lot of WordPress related e-mail.

    I’ll grab it immediately. It doesn’t look all that difficult to do the edits; I do a lot of modifications to osCommerce, though not many to WordPress–yet. I promise not to call my log, “LOG.” 🙂


    it could well be one of your plugins allowing an exploit… it’s not enough to disable them you have to junk them as well.

    Happened to a friend of mine recently who was using a forum plugin – nasty thing.

    It’s not enough to just get rid of the plugin either – once your site has been exploited you may have hidden files amongst the normal wordpress ones somewhere.

    Best bet?

    turn off all your plugins, delete everything on your hosted space except the jpg files you’ve uploaded for your posts… then upload a freshly downloaded wordpress and enable only the plugins you really MUST have – avoid any big ones for now.

    then go from there…

    I’d also suggest googling all your plugin names and reading people’s reports about them – if one of your plugins is suspect, chances are someone will be complaining about it.

    These are very fine suggestions, Ivovic, and I’ve added them to my little list.

    The culprit plugin is PhotoPress. It has taken me most of yesterday and this afternoon to figure that out. It required a world-writeable directory under wp-content for photographs to be uploaded, and that’s where all the poker fun-and-games were located. I have yet to determine how they wrote to two posts of mine, but the posts have been cleaned out as well. I also spend a long, tedious interlude with a dump of the database searching for any suspicious language–didn’t find any. I had deactivated the plugin quite a while back because I could not get it working with my theme. It’s my intention to go in and drop the table created by Photopress, as it’s no longer needed.

    At the moment I’m running a mere skeleton–Akismet of course, and SEM Subscribe-Me. I hope to install and activate the All in One SEO Pack, which seems sterling according to comments I’ve read. I’d also like to get Lightbox going. Actually, what I really need is a break from all this. Ugh.


    Can someone recommend a link where I can review what are dangerous chmod settings?

    I have used the NextGen Gallery plugin, which I believe requires a similar chmod level as what altelierbeads mentions above for PhotoPress. I also use the wp-backup plugin (but I don’t store database backups on the server).

    Anyway, although I’ve gained a lot of experience with various aspects of developing sites with WordPress, I feel that I need a stronger understanding of chmod settings, given that there seem to be a lot of exploits of WP sites via this route.

    You need to read this article from end to end:

    Then you need to understand, via your host or other documentation, what permissions your particular Web server requires to be set so that recommendations in that article can be put into effect within your installation. They will vary from one Web server to the next.

    If you go to Google and type in “man chmod” you will find a variety of pretty good explanations of file permissions, at least for unix/linux/*nix. The one at this site
    is particularly good if you are on a Linux server because it’s got a little practice grid that lets you try out the various permissions. You will learn from this site that you are dealing basically with three sorts of people: User (that’s you, the owner of the file), Group (not much used in these circumstances and should probably be set as for Other), and Other (that’s all the people, good and bad, who access your site and your blog). There are also, basically, three kinds of permission, and they’re pretty self-explanatory: Read, Write, and Execute. Learned users will be quick to correct me, because the whole thing is more complicated than what I’ve described. But if you can start out by understanding this much, you’ll be able to do what you need to do.

    If you gain access to your site via a “control panel” or “file manager” of some sort (such as cPanel), it will normally have a little utility similar to the one on that page that lets you evaluate and change the permissions on each file and directory. True aficionados can execute chmod from the command line via ssh or some FTP programs, but that can be daunting if you are just starting out. Contact your hosting provider to see how they suggest you do it.

    Potential problems arise with plugins that ask you to set up a directory somewhere where everybody can do everything–that is, User, Group, and Other can Read, Write, and Execute. Or, in the numeric setting-of-bits of chmod, 7-7-7. In a fit of temporary insanity, compounded by amnesia, this is what I did–then uninstalled the plug-in forgetting the vulnerable directory. I might as well have put up a sign saying COME ON IN!

    So to sum it all up you have several interesting tasks ahead of you:
    1) Read that article to understand how WordPress “wants” its permissions.
    2) Understand exactly which permissions are needed on your server to achieve what WordPress is asking for.
    3) Understand the three basic kinds of users and three basic permissions.
    4) Understand how to actually chmod files on your site, whether via a control panel, ssh, FTP, or whatever.
    5) Go ahead and do it–presumably backing-up and testing goes without saying.
    6) Remember that it is always, always best to give the least “amount” of permission possible–never give anybody more permission than they need to do whatever task it is you want them to do. In other words, the only permission that isn’t “dangerous” is no permission at all.
    7) Be dubious of plugins that want to set up places the whole world can write to.

    Whew. That should keep you busy for a few minutes. I believe I’ll take the rest of the evening off.





    you will find out rather quickly how they edited posts by doing that logging.. 🙂 trust me! I can probably tell you how, but it will be more fun for your to discover yourself —

    Anne / atelierbeads

    Thanks so much for that lengthy post on chmod and security issues. Some of that stuff I already know – or should — because I’m quite familiar with FTPing and some other backend stuff.

    But I’ve never been quite confident that I understand everything about potential security risks, and I really appreciate the time you took to supply the relevant links, and to lay out the basic tasklist.

    I’m sure it will benefit other people as well.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Security: Someone uploaded bogus files to wp-content – 2.5’ is closed to new replies.