The "copy me" checkbox on the core drupal contact module is a bad thing, especially if you can't disable it. I've disabled it by hacking the code, but this makes updates more complicated since it's part of the core drupal distribution, easy to overwrite my changes on an upgrade.

The basic problem is that there's no way to make sure the submitted "from" email address belongs to the poster. So, an "evil spammer" could submit spam via a website with this feature enabled by putting in spam-to email addresses as their own. Then a "copy" of the spam email would be sent to somebody else, thus creating relay spam.

I would to see an easy patch to disable this feature in the admin moved up to a high priority -- so that we don't have to comment out the code. This is an easy fix and should not affect core at all. I don't want to use the 3rd party feedbak module since it's not part of core and really is no different except for this feature. The limiter of posts/per hour is great in contact, but you really can't set it to zero so some relay spam could occur on drupal websites.

A huge security hole in my opinion. Let's fix it in a point release!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

beginner’s picture

Version: 4.7.2 » x.y.z
Category: feature » bug

is this related to this one: http://drupal.org/node/34181 ?

chrisschaub’s picture

Status: Active » Closed (duplicate)

Yes, I'll mark a dupe and close. Thanks.

crunchywelch’s picture

Status: Closed (duplicate) » Active

This is not a dupe. You can relay spam, one at a time, using this method. It has nothing to do with header injection, it has to do with the fact that I can put in any email address in the 'Your e-mail address' field, click 'Send me a copy' and the form will send whatever you've placed in the message field to that address. Granted, its slow and probably would be noticed by a site admin, but once you notice how can you stop it besides shutting off the module?

I've commented out this code in our version for now because its been abused constantly over the past few days, someone has definitely built some bots to exploit this.

I would prefer a 'send me a confirmation' email that has admin configurable text to send so the user knows it was sent, but the message is not repeated as to completely remove any value in exploiting this. I'm happy to roll a patch if that sounds like a good plan.

webchick’s picture

Actually. A better plan might be to require re-validating ones' email address if they change it.

crunchywelch’s picture

The problem with that is anonymous users have no way of validating email. A possible hybrid solution would be to not allow copy sending, and only bland confirmation for anonymous users, and not allow logged in users to change thier email at all.

chx’s picture

Assigned: Unassigned » chx

Battle plan.

  1. Remove "copy me" for anonymous.
  2. When you change your email address on user edit it does not get changed but you get an email to the new address with a hashed link (note that we have code for such links already) and clicking that your email will change.
Gerhard Killesreiter’s picture

Sounds like a good plan to me.

Dries’s picture

Sounds good to me too.

matt@antinomia’s picture

I've taken care of part one of the equation (the simple part) as part of this patch: http://drupal.org/node/58224#comment-134542.

Regarding part two, I'd be happy to take a stab at coding it. What would be an appropriate location to store the user's new email address while pending verification? Do we need another field in the users table, or can we do this in conjunction with the 'init' field?

matt@antinomia’s picture

Component: contact.module » user.module

Seems this is also now fundamentally a user.module issue.

chx’s picture

Status: Active » Needs review
FileSize
5.64 KB

I think wording will need help and the code is absolutely untested but basically, this is it.

webchick’s picture

Just a note, I tried to test this tonight but there's currently a bug in HEAD where anon users can't view user profiles, so getting to the contact form is impossible. i will have another look tomorrow when i am less tired. :P

AjK’s picture

Comment to get me subscribed.

Apllied patch to test but, as webchick, can't properly test (and it's late here too! 1:36am)

chx’s picture

Title: contact module - copy me a bad thing, spam possible » Make sure the user's email is correct

I just tried to view user/1 as anon user and succeeded. What this has to do with my patch, that's a mystery. Adjusted title.

chx’s picture

Title: Make sure the user's email is correct » ontact module - copy me a bad thing, spam possible
FileSize
5.68 KB

Rolled back title (realized that I changed contact after al), rolled patch against HEAD.

chx’s picture

Title: ontact module - copy me a bad thing, spam possible » contact module - copy me a bad thing, spam possible
AjK’s picture

I just tried to view user/1 as anon user and succeeded. What this has to do with my patch, that's a mystery.

Doesn't your patch disable the checkbox for anon users?

+if ($user->uid) {
+      $form['copy'] = array('#type' => 'checkbox',
+        '#title' => t('Send yourself a copy.'),
+      );
+    }

That's what this had to do with your patch. Anyway, by enabling "access user profiles" perm for anon users, I can now see user/1 so getting access denied was a config problem in the test setup. However, despite enabling "access personal contact forms" for anon user, the contact tab doesn't show up for user/1 (untested for other users). And, trying to use the direct user/1/contact url just displays the "view" page. No contact form.

So, it's a little tricky to see if the "Send yourself a copy" checkbox has disappeared if can't get the contact form up to see. So, struggling to review this patch on that score (am I missing something on the setup somewhere?)

With regard to the part that attempts to provide a hash link to change the email address, the outgoing email fails to send and PHP barks fatally as user_mail() is being used as opposed to the new drupal_mail() function. I'll look at re-rolling that section unless I'm beaten to it (again, it's 1:30am here and I'm pretty tired now).

regards,
--AjK

AjK’s picture

Status: Needs review » Needs work
AjK’s picture

Status: Needs work » Needs review
FileSize
6.85 KB

Here's a modified patch that:

  • Uses drupal_mail() to send the email
  • Send's the email to the changed to address rather than the old address
  • adds in the timestamp to the URL
AjK’s picture

With regards to the anon user not being able to see user profiles, this issue relates to that http://drupal.org/node/84490

drumm’s picture

Status: Needs review » Needs work

I'm confused about what this actually does. Both new functions are completely undocumented. I think there are two separate patches actually in here- some sorta new menu item for "changing mails" and requiring logging in to see a copy me checkbox.

AjK’s picture

Assigned: chx » AjK
Status: Needs work » Needs review
FileSize
816 bytes

Ok, let's clean this up a bit. I'll start with the easy bit.

On site wide contact forms, there is no point showing the Send yourself a copy checkbox when the user is anon. The reason for this is, firstly an auto-reply is sent to the email address supplied by the anon user which is site configurable. This can't be set and therefore can't be abused. However, if you allow the Send yourself a copy checkbox an anon user could enter a malicious message and enter someone elses email address. The Send yourself a copy would then anon send to that unsusspecting third party the malicious message. An alternative use is spam (although spamming would soon be spotted).

The attached patch fixes this by checking the global $user->uid and if the user is anon then the Send yourself a copy checkbox is suppressed.

As for the rest of what this issue is trying to address, I will start a new issue thread to address that. I will come back to this thread and cross post a link to the new issue once I have created it for those that may wish to follow on.

AjK’s picture

Title: contact module - copy me a bad thing, spam possible » contact module - "Send yourself a copy" possible abuse prevention
Component: user.module » contact.module
beginner’s picture

Status: Needs review » Reviewed & tested by the community

indeed, that's the easy bit.

AjK’s picture

to whom it may concern : http://drupal.org/node/85494

drumm’s picture

Status: Reviewed & tested by the community » Needs work

You can't even access personal contact forms if you are anonymous:

          'access' => ($user->uid && user_access('access personal contact forms')),

line 109

That will have to be fixed with this patch.

AjK’s picture

Status: Needs work » Closed (works as designed)

then this patch is not required by design

drumm’s picture

Status: Closed (works as designed) » Needs work

Unless I'm mistaken, this applies to sitewide contact forms as well. I think we /do/ want anonymous users to be able to send messages via contact module if permission is given and we do not want them sending a copy to arbitrary email addresses. Lets get this fixed up.

AjK’s picture

OK, I'm not really sure what's being asked here as I thought I had achieved this target.

The patch in #22 acheives this workflow for anonymous users

  1. Anon users cannot contact registered users via thier contact form. It appears that for contacting registered users Drupal requires that the sender have a valid email address (contact.module, line 311) if (!valid_email_address($user->mail)) {
  2. which is impossible to be sure of for the anon user.

  3. Anon users can use the site wide contact forms but the patch in #22 disables/removes the Send yourself a copy so that anon users cannot insert a fake own email address and send an arbitrary message to that address.

Is the suggestion that [1] is wrong and anon users should be able to contact registered users? If so, what's this issue's real status, is it still a critical bug or is it suggested that the contact feature change here to allow anon users to contact registered users (thus changing this issue's status)?

regards,
--AjK

dopry’s picture

Status: Needs work » Needs review
FileSize
1.32 KB

@drumm, re: line 109. I think it was Dries original intention that anonymous users not be able to access personal contact forms, http://drupal.org/node/13040. The permission for 'access personal contact forms' is redundant, personal contact forms are opt-in by authenticated users and only accessible to authenticated users. Maybe someone meant to restrict which users can enable personal contact forms with that permission.

I've re-rolled the patch removing the 'access personal contact form' permission.

beginner’s picture

Title: contact module - "Send yourself a copy" possible abuse prevention » remove contact.module redundant permission.
Priority: Critical » Normal
Status: Needs review » Needs work

The title is no longer applicable.
The abuse is possible by
1) anonymous users -> this is a feature request at http://drupal.org/node/58224 for Drupal 6+.
Currently, anonymous users cannot access the contact form at all.
2) registered users who have changed their email address in their profile.
-> this is now handled in a separate issue: http://drupal.org/node/85494
so, what was the original object of this issue is now handled elsewhere.

the permission 'access personal contact forms' is indeed redundant (try giving anonymous users this permission: it is confusing at best because it doesn't work).

The third chunck of the latest patch is therefore not needed.

dopry’s picture

Title: remove contact.module redundant permission. » Send yourself a copy" possible abuse prevention && contact.module redundant permission.
Status: Needs work » Needs review

you missed #3 which is putting any email you want in site wide contact forms and using the 'copy me' function to send email to third parties. Which is the issue being reported here. The additional permission removal could be considered scope creep, but I feel it is related and simple enough to be a rider. The third chunk is in the site wide contact form not the user contact form

chx’s picture

Status: Needs review » Reviewed & tested by the community

Looks good.

Dries’s picture

Status: Reviewed & tested by the community » Needs work

Please add some code comments so we don't make this mistake again and so we remember why we choose to implement it this way. Thanks.

chx’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
1.26 KB

Sure.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)
Owen Barton’s picture

Title: Send yourself a copy" possible abuse prevention && contact.module redundant permission. » "Send yourself a copy" abuse prevention
Version: x.y.z » 4.7.x-dev
Assigned: AjK » Owen Barton
Priority: Normal » Critical
Status: Closed (fixed) » Needs review
FileSize
785 bytes

Recently we have noticed in our server logs that spammers have been utilizing compromised ('zombie') PCs to send spam through the Drupal public contact form, via the "Send yourself a copy" functionality.

It doesn't take a lot of maths to see that this is potentially a major problem: 3 messages/hour X 1000 zombies X 10,000 Drupal sites = 30,000,000 spam message per hour. Ouch.
Also, note that these e-mail are coming from servers that are also likely to be sending legitimate e-mail, and who (unlike mail sent directly from Zombies) are likely to be hurt by their IP address being banned for hosting an open spam relay.

Hence I am proposing that we backport this fix to 4.7, as a security update.
There will continue being a huge number sites not yet ready to upgrade to 5.0, and if we leave this vulnerability open it will damage Drupal's (currently very good) reputation with hosting companies and sysadmins.

Owen Barton’s picture

FileSize
2.15 KB

After discussions on IRC, Heine indicated that - because part to of http://drupal.org/node/69202#comment-128222 has not been implemented (which leaves authenticated users able to abuse the contact form) - it would be preferable to remove the feature altogether. Here is a 4.7 patch that does this - I can make one for 5.0 if required.

Either this, or my original patch would be acceptable to me. The important thing is that we do something about this fairly quickly, since it is actively being used for spamming!

Owen Barton’s picture

If occurred to me that a contrib module could quite easily add it back in with form_alter if someone feels strongly about it ;)

webchick’s picture

-1 for stripping out features in the middle of a stable release. I'd do a contrib module.

killes@www.drop.org’s picture

Version: 4.7.x-dev » 5.x-dev

I am not sure if we should remove it or if there is another way (maybe a seeting that defaults to off?).

Anyway this needs to be fixed in D5 before D4.7

killes@www.drop.org’s picture

I've applied the patch in #38 to 4.7.

Owen Barton’s picture

Status: Needs review » Fixed

Thanks killes :)

I am closing this issue, since the first part of this issue is now fixed for 4.7, 5.0 and HEAD, whilst the second part of the issue (user e-mail address change verification) is a separate issue over at http://drupal.org/node/85494. Please help get that one fixed, and we can be done with this issue for good!

Anonymous’s picture

Status: Fixed » Closed (fixed)
hickory’s picture

Version: 5.x-dev » 6.x-dev
Priority: Critical » Normal
Status: Closed (fixed) » Active
FileSize
1.12 KB

Forgive me for re-opening this issue, but I don't think it was completely solved: at the moment an authenticated user can put any email address they want in the 'from' email field and a copy of the email will be sent to that address.

When http://drupal.org/node/85494 is fixed, a user's email address should always be verified. The attached patch thus makes the contact form use that email address for the 'from' field. Anonymous users can still enter an email address, but are not allowed to send a copy of the message to themselves.

cburschka’s picture

Priority: Normal » Critical
Status: Active » Needs review

Patch looks good. Also, this closes a critical security issue where any authenticated account (which on sites with no admin approval is easy to obtain) can spam any unverified address. It's also illogical to do it the other way - the point of creating an account is to have a verified email address. Why allow entering a different email address?

I think the priority for this needs to be higher; and it also requires backporting to 5.x-dev.

The patch succeeds (with minor offset) for both 5.x and head.

ChrisKennedy’s picture

Status: Needs review » Needs work

Needs a re-roll. In cases like this it's better to open a new issue rather than piggyback on an old one - just post a link to the new issue.

chx’s picture

Status: Needs work » Closed (won't fix)

I already closed an issue which wanted to verify email addresses. Make a contrib module. New features might go into Drupal 7 if we want to.

chx’s picture

Also because of the flood control , contact is not an effective way to spam.

kwixson’s picture

I'm confused. The original issue here has nothing to do with what authenticated users can do. An anonymous user (a spam bot) can come to my site and submit a form to my site wide contact form, putting in a third party email address into the "from" field and check the "Send yourself a copy" control. The spam message goes to the third party who was entered in the "from" field.

It doesn't matter what flood control there is, it is still being used to send spam and as has been pointed out, with enough bots hitting your site from different servers your site can still send copious amounts of spam regardless. It doesn't matter that I know it's happening almost instantly if I can't do anything to stop the spam but take down site wide contact forms. I still want a contact form on my site. I just don't want spammers able to use it.

flaviovs’s picture

darumaki’s picture

how do we install this mod ? the info and site do not say much and it doesn't show up in the mod list either.

flaviovs’s picture

There are step-by-step instructions about how to install the contact_nocc module on the provided URL.

Basically, create a directory, download the two files into it, and enable the module on Drupal control panel.

All basic stuff. No additional tweaking needed -- after enabling the module the checkbox goes away.

Wesley Tanaka’s picture

contact_nocc has been modified to work with Drupal 6:
http://wtanaka.com/drupal/contact_nocc

You can also get it on github:
http://github.com/wtanaka/contact_nocc
http://wtanaka.github.com/contact_nocc