LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 02-05-2015, 08:19 PM   #1
joeyda3rd
LQ Newbie
 
Registered: Feb 2015
Posts: 5

Rep: Reputation: Disabled
EC2 instance relaying spam through sendmail, can't figure out how to stop it


I must mention that email hosting protocols are very foreign to me, so please bare with me if I don't really know what I'm talking about.

I am running an Amazon Web Services EC2 Instance for a dedicated web server among other services. I received an email about spam coming from my server and so I check my mail log. Sure enough, I am getting what appears to be SMTP relays from my server's "Private DNS" using my server's www account name with spoofed addresses from my domains that are pointed to this server. I turn off sendmail service and I'm still getting relay requests which are denied. See the current log messages below.

I'd really like to turn sendmail back on for the websites to be able to send email, but don't want this relaying to continue. What should I do to stop this? Can you help me understand what's going on here?

I've changed the IPs, domains and emails below.
Quote:
**MAIL LOG**
Feb 5 20:45:28 ip-(private IP) sendmail[9251]: t15KjSdo009251: Authentication-Warning: ip-(private IP).ec2.internal: www set sender to ******@my-domain.com using -f
Feb 5 20:45:28 ip-(private IP) sendmail[9251]: t15KjSdo009251: from=******@my-domain.com, size=516, class=0, nrcpts=1, msgid=<201502052045.t15KjSdo009251@ip-(private IP).ec2.internal>, relay=www@localhost
Feb 5 20:45:28 ip-(private IP) sendmail[9251]: t15KjSdo009251: to=****@hotmail.com, ctladdr=******@my-domain.com (501/503), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30516, relay=[127.0.0.1] [127.0.0.1], dsn=4.0.0, stat=Deferred: Connection refused by [127.0.0.1]
 
Old 02-05-2015, 10:14 PM   #2
ceyx
Member
 
Registered: May 2009
Location: Fort Langley BC
Distribution: Kubuntu,Free BSD,OSX,Windows
Posts: 342

Rep: Reputation: 59
For us to help you, it is always best to indicate what 'flavor' your EC2 instance is ( Centos, Ubuntu etc ) the verson number, and the contents of the config files for sendmail and whatever else you use for mail.

What are your webservers built on ? Apache ? and what do you use them for ?

What are the 'other services' you are using ?

The more RELEVANT info you can give, the better.

No guarantee of a reply, but your chances are better this way.
 
Old 02-05-2015, 11:27 PM   #3
joeyda3rd
LQ Newbie
 
Registered: Feb 2015
Posts: 5

Original Poster
Rep: Reputation: Disabled
Quote:
[root ~]# cat /etc/*-release
NAME="Amazon Linux AMI"
VERSION="2014.09"
ID="amzn"
ID_LIKE="rhel fedora"
VERSION_ID="2014.09"
PRETTY_NAME="Amazon Linux AMI 2014.09"
ANSI_COLOR="0;33"
CPE_NAME="cpe:/o:amazon:linux:2014.09:ga"
HOME_URL="http://aws.amazon.com/amazon-linux-ami/"
Amazon Linux AMI release 2014.09
http://aws.amazon.com/amazon-linux-a...release-notes/

Apache 2 PHP 5
MySQL

The nature of the websites are CMS based sites and all outgoing mail logs for all published sites have no leaks. All CMS versions are up to date.

My other service is an HTTP based custom application that only communicates with one other server and ssh shell of course. I checked SSH logins, there's no logging in by any user but me.

Only ports 22 and 80 are open to all IPs on the AWS security group. (so I'm not sure how they're getting past no open port 25)

Running Services
Quote:
]# service --status-all
acpid is stopped
atd (pid 1251) is running...
auditd (pid 1061) is running...
cfn-hup is stopped
Stopped
cgred is stopped
Checking for service cloud-init:Checking for service cloud-init:Checking for ser vice cloud-init:Checking for service cloud-init:conmand is stopped
crond dead but subsys locked
htcacheclean is stopped
httpd (pid 1234) is running...
ip6tables: Firewall is not running.
iptables: Firewall is not running.
irqbalance is stopped
lvmetad is stopped
mdmonitor is stopped
messagebus (pid 1095) is running...
mysqld (pid 4543) is running...
netconsole module not loaded
Configured devices:
lo eth0
Currently active devices:
lo eth0
ntpd (pid 1201) is running...
Process accounting is disabled.
quota_nld is stopped
racoon is stopped
rdisc is stopped
rngd is stopped
rsyslogd (pid 1074) is running...
saslauthd is stopped
sendmail is stopped
sm-client is stopped
spamd is stopped
openssh-daemon (pid 1182) is running...
vsftpd is stopped
Webmin (pid 1294) is running
yum-updatesd (pid 1289) is running...
 
Old 02-06-2015, 08:39 AM   #4
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by joeyda3rd View Post
from my domains that are pointed to this server.
What do these domains "server up"? CMS-type boards, Wordpress, Joomla, e107?

Is there an EIP attached to the instance?
 
Old 02-06-2015, 02:19 PM   #5
joeyda3rd
LQ Newbie
 
Registered: Feb 2015
Posts: 5

Original Poster
Rep: Reputation: Disabled
Looked at he mail files under /var/spool/mail and both root and www accounts have large mail files. And the mail queues fill fast when I enable sendmail.

There is an EIP attached and all the domains are pointed to this, correct.

CMS wordpress and drupal websites. I did just find a bunch of odd files and users in one of my drupal installations that gave write permissions on the directory to the www. I took that site down and the queue seemed to stop growing. This might be it. I'll monitor the problem and report back if it continues.

How does giving write permission to the www user allow someone to add files?

I could just attach an SES account to all the sites, but this will create more headaches. I'd rather just stop this intrusion.
 
Old 02-06-2015, 04:36 PM   #6
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by joeyda3rd View Post
how they're getting past no open port 25)
localhost has no such restriction.
 
1 members found this post helpful.
Old 02-07-2015, 09:51 AM   #7
joeyda3rd
LQ Newbie
 
Registered: Feb 2015
Posts: 5

Original Poster
Rep: Reputation: Disabled
So the rogue files in my drupal installation are not the problem, maybe the point of entry, but removing them did not stop the attack. What should I be looking for?

Here's the mail log when it's running
Quote:
Feb 7 15:44:02 ip-10-4-87-157 sendmail[3412]: STARTTLS=client, relay=aspmx.l.google.com., version=TLSv1/SSLv3, verify=FAIL, cipher=ECDHE-RSA-AES128-GCM-SHA256, bits=128/128
Feb 7 15:44:02 ip-10-4-87-157 sendmail[3412]: t17Ff2K9003320: to=<support@my-domain.org>, delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=124578, relay=aspmx.l.google.com. [64.233.171.27], dsn=5.1.1, stat=User unknown
Feb 7 15:44:02 ip-10-4-87-157 sendmail[3412]: t17Ff2K9003320: t17Fi2Jt003412: postmaster notify: User unknown
Feb 7 15:44:02 ip-10-4-87-157 sendmail[3412]: t17Fi2Jt003412: to=root, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=35817, dsn=2.0.0, stat=Sent
 
Old 02-07-2015, 03:59 PM   #8
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
is the Wordpress installation(s) up to date and are all the plugins up to date as well?
Is it just one Wordpress install or > 1?
 
Old 02-07-2015, 06:36 PM   #9
ceyx
Member
 
Registered: May 2009
Location: Fort Langley BC
Distribution: Kubuntu,Free BSD,OSX,Windows
Posts: 342

Rep: Reputation: 59
IMHO this is the tip of the iceburg :
Quote:
Authentication-Warning: ip-(private IP).ec2.internal: www set sender to ******@my-domain.com using -f
There is a problem with the hosts file ? ( /etc/hosts )
or the sendmail 'sender access' db.
 
Old 02-08-2015, 09:56 AM   #10
joeyda3rd
LQ Newbie
 
Registered: Feb 2015
Posts: 5

Original Poster
Rep: Reputation: Disabled
All the wordpress and drupal sites are up to date.

I don't know about hosts and access, but it looks default to me.

Quote:
~]# cat /etc/mail/access
...
# By default we allow relaying from localhost...
Connect:localhost.localdomain RELAY
Connect:localhost RELAY
Connect:127.0.0.1 RELAY

[root@ip-10-190-117-70 ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain
I do want to continue to relay from localhost so my sites can email me or users, right?
 
Old 02-08-2015, 10:47 AM   #11
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Wordpress installs may be up to date.
What about the plugins they use?
 
Old 02-08-2015, 11:41 AM   #12
ceyx
Member
 
Registered: May 2009
Location: Fort Langley BC
Distribution: Kubuntu,Free BSD,OSX,Windows
Posts: 342

Rep: Reputation: 59
The hosts file is the problem. There is plenty of documentation on how to set it up from Amazon.
Same with sender access.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is my sendmail relaying spam? Getting postmaster error emails... KrisRoberts Linux - Server 5 08-24-2014 08:58 PM
Sendmail relaying spam? Dancingmoose Linux - Server 1 09-25-2010 08:16 AM
Sendmail Relaying Spam resende Linux - Server 2 11-28-2009 10:56 AM
I think I may be relaying with sendmail, gotta stop it. How? WorldBuilder Linux - Networking 4 09-20-2003 04:47 PM
Sendmail SPAM and relaying magyartoth Linux - General 0 05-02-2002 07:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 05:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration