Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
The server is hosting several domains and IP addresses all through a single ethernet interface.
Server is closed to relaying. People reporting my server as an abuser are giving me email headers like this:
Code:
Received: from <myserver> (<myserver> [<mymainip>]) by rly-mc05.mail.aol.com (v119.12) with ESMTP id MAILRELAYINMC52-124471819fd11d; Thu, 18 Oct 2007 22:44:14 -0400
Received: (qmail 4486 invoked from network); 18 Oct 2007 18:59:29 +0000
Received: from unknown (HELO User) (<abusingIP>) by <anotherofmyips> with SMTP; 18 Oct 2007 18:59:29 +0000
My interpretation of this is that people are connecting anonymously through one of my IPs, their email is being transferred internally on my server, then sent from my main IP.
well clearly your server is *NOT* closed to relaying otherwise thus wouldn't be happening would it? try scanning yourself at http://www.abuse.net/relay.html and see what they say you are vulnerable to. they'll also tell you how to fix it for your MTA. obviosuly we can't tell you exactly what to change on your MTA as you've not provided your config for us to check.
obviosuly we can't tell you exactly what to change on your MTA as you've not provided your config for us to check.
Thanks for your feedback. On my server PLESK controls qmail, and from PLESK I have specified that it should be closed to relaying. I've also checked the rcpthosts file [which I believe is managed through the PLESK interface], and it contains only the domains that are hosted on the server.
Please tell me what else you need to know about my config.
From what I have read, the config files seem to be the same as for standard qmail, but on a different path.
Given that I know there is a rcpthosts file, is there a setting somewhere that would override that? Where would that setting *normally* be stored please?
Due to my lack of knowledge, that's about as far as my diagnosis can get. How can I find out how these qmail-remote processes belonging to user qmailr are being started?
Connecting to mail.mydomain.com for anonymous test ...
<<< 220 host.mydomain.com ESMTP
>>> HELO www.abuse.net
<<< 250 host.mydomain.com
Relay test 1
>>> RSET
<<< 250 flushed
>>> MAIL FROM:<spamtest@abuse.net>
<<< 250 ok
>>> RCPT TO:<securitytest@abuse.net>
<<< 553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)
Relay test 2
>>> RSET
<<< 250 flushed
>>> MAIL FROM:<spamtest>
<<< 250 ok
>>> RCPT TO:<securitytest@abuse.net>
<<< 553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)
Relay test 3
>>> RSET
<<< 250 flushed
>>> MAIL FROM:<>
<<< 250 ok
>>> RCPT TO:<securitytest@abuse.net>
<<< 553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)
Relay test 4
>>> RSET
<<< 250 flushed
>>> MAIL FROM:<spamtest@mydomain.com>
<<< 250 ok
>>> RCPT TO:<securitytest@abuse.net>
<<< 553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)
Relay test 5
>>> RSET
<<< 250 flushed
>>> MAIL FROM:<spamtest@[xxx.xxx.xxx.xxx]>
<<< 250 ok
>>> RCPT TO:<securitytest@abuse.net>
<<< 553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)
Relay test 6
>>> RSET
<<< 250 flushed
>>> MAIL FROM:<spamtest@mydomain.com>
<<< 250 ok
>>> RCPT TO:<securitytest%abuse.net@mydomain.com>
<<< 550 sorry, no mailbox here by that name. (#5.7.17)
Relay test 7
>>> RSET
<<< 250 flushed
>>> MAIL FROM:<spamtest@mydomain.com>
<<< 250 ok
>>> RCPT TO:<securitytest%abuse.net@[xxx.xxx.xxx.xxx]>
<<< 553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)
Relay test 8
>>> RSET
<<< 250 flushed
>>> MAIL FROM:<spamtest@mydomain.com>
<<< 250 ok
>>> RCPT TO:<"securitytest@abuse.net">
<<< 553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)
Relay test 9
>>> RSET
<<< 250 flushed
>>> MAIL FROM:<spamtest@mydomain.com>
<<< 250 ok
>>> RCPT TO:<"securitytest%abuse.net">
<<< 250 ok
Relay test result
Hmmn, at first glance, host appeared to accept a message for relay.
THIS MAY OR MAY NOT MEAN THAT IT'S AN OPEN RELAY.
Some systems appear to accept relay mail, but then reject messages internally rather than delivering them, but you cannot tell at this point whether the message will be relayed or not.
You cannot tell if it is really an open relay without sending a test message; this anonymous user test DID NOT send a test message.
So "securitytest%abuse.net" seems to have got past the rcpthosts file? What should my next steps be please?
have you got the percenthack options disabled? I assume it would be appending your local domain to what is initially percieved to be a local user name, which could then be spun round and rewritten.
Now I have learned how to telnet onto port 25 and type in SMTP commands.
The sender "Security%abuse.net" is accepted, then the DATA command then some text and a '.' [period]. I get the SMTP response
250 ok 119xxxxx qp 12112
I quickly dived into the tail of the maillog file and saw that a message from spamtest@mydomain.com qp 12112 had been tried but delivery was deferred because the remote_host_could_not_complete_sender_verify_callout
Using the message id in the log message I then checked the recipient address which was "Security%abuse.net@host.mydomain.com"
So clearly my server is handling mail for badly formed email addresses that it shouldn't.
HOWEVER, my problem is the other away around. The above is deferred email is a sender in mydomain.com, but somehow an:
SMTP MAIL FROM:somebody@NOTmydomain.com command is getting injected into my mail queues, getting around my rcpthosts file, and is being sent from my server.
If I:
ps aux | grep qmail-remote I'm seeing lots of lines of mail being sent from email address "Service@ppl.com" such as:
Right now, qmail is handling just emails from service@ppl.com, no other addresses, but I also see entries where the sender field is blank, it doesn't contain any email addresses at all.
ok, so it looks like this could be percenthack related, and oddly i only found out that it existed the other day... so someone sent you an email to "Security%abuse.net" this contained no FQDN so qmail expanded it to "Security%abuse.net@your.domain.com" qmail then applies the percenthack "feature" to convert that to "Security@abuse.net" and off it goes.
Regarding the email to "security%abuse.net" that I built in a telnet session, described above, the qmail-send program has now sent a fail message to the server admin email address.
Quote:
Hi. This is the qmail-send program at host.mydomain.com.
I'm afraid I wasn't able to deliver your message to the following addresses.
This is a permanent error; I've given up. Sorry it didn't work out.
<securitytest%abuse.net@host.mydomain.com>:
Sorry. Although I'm listed as a best-preference MX or A for that host, it isn't in my control/locals file, so I don't treat it as local. (#5.4.6)
So the email address with the % sign in, is having the domain added to the end, and then the message is being rejected.
This doesn't explain then how MAIL TO:<somebody@not_in_my_rcpthosts_file.com> is getting past my rcpthosts file. I'm beginning to think that there must be some rogue script on the server that is bypassing the rcpthosts file, or that a genuine email address has been hijacked on the client side and is being used to piggy back sending these phishing emails.
Any advice of how to look for rogue scripts please?
It is very unlikely for qmail to be setup as open relay, since its default configuration is not suppose to be so. Can you check your mail log, not just one or two lines, is best to show more, say last 10 or 20 lines. It will be easier for us to understand the situation.
If you are using qmail-smtpd, you should check your qmail-smtpd startup script? If you are using qpsmptd, then you need to be careful to your plug-in configuration. If you are using other SMTP program, you will need to provide that information as well.
From the simulation of SMTP handshaking via telnet, it is possible, the party that spam email is one of your valid user. Which is why, those email able to get through.
I have used qmail-remove to remove any spamming/phishing email, or 'bouncing' messages from my mailer daemon. Doing this, I reduced the size of the mail queue from 3500 to 14!
I've added 'bad' email sending addresses [ ppl.com boa.com ] to the badmailfrom file.
I've changed the DNS A record for every mail.<domainX>.com on the server to be a single IP.
For all other IPs that the server uses I've firewalled port 25 [SMTP]
The combination of all of these things has the situaton under control. However, I still haven't found the root cause.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.