IPFW uid logging...

2008-09-08 Thread Dan Mahoney, System Admin

Hey all,

I have the following rule set up in ipfw to limit the exposure of bad php 
scripts and trojans that try to send mail directly.


allow tcp from any to any dst-port 25 uid root
deny log tcp from any to any dst-port 25 out

However, the log messages I get look like this:

Sep  8 13:21:11 security.info prime kernel: ipfw: 610 Deny TCP 
72.9.101.130:58117 209.85.133.114:25 out via em0
Sep  8 13:21:16 security.info prime kernel: ipfw: 610 Deny TCP 
72.9.101.130:56672 202.12.31.144:25 out via em0
Sep  8 13:21:16 security.info prime kernel: ipfw: 610 Deny TCP 
72.9.101.130:58131 209.85.133.27:25 out via em0
Sep  8 13:21:28 security.info prime kernel: ipfw: 610 Deny TCP 
72.9.101.130:58117 209.85.133.114:25 out via em0
Sep  8 13:21:32 security.info prime kernel: ipfw: 610 Deny TCP 
72.9.101.130:58131 209.85.133.27:25 out via em0
Sep  8 13:22:45 security.info prime kernel: ipfw: 610 Deny TCP 
72.9.101.130:65313 64.202.166.12:25 out via em0
Sep  8 13:22:45 security.info prime kernel: ipfw: 610 Deny TCP 
72.9.101.130:65313 64.202.166.12:25 out via em0
Sep  8 13:22:46 security.info prime kernel: ipfw: 610 Deny TCP 
72.9.101.130:65313 64.202.166.12:25 out via em0
Sep  8 13:22:49 security.info prime kernel: ipfw: 610 Deny TCP 
72.9.101.130:65313 64.202.166.12:25 out via em0


Which is to say, they don't include the UID -- and I have several hundred 
sites, each with its own UID.


Yes, I could go ahead and set up a thousand deny rules, one for each UID 
-- but being able to log this info (since it IS being checked) would be 
great.


Thoughts?

-Dan Mahoney

--

Dan Mahoney
Techie,  Sysadmin,  WebGeek
Gushi on efnet/undernet IRC
ICQ: 13735144   AIM: LarpGM
Site:  http://www.gushi.org
---

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: IPFW uid logging...

2008-09-08 Thread Dan Nelson
In the last episode (Sep 08), Dan Mahoney, System Admin said:
 I have the following rule set up in ipfw to limit the exposure of bad
 php scripts and trojans that try to send mail directly.
 
 allow tcp from any to any dst-port 25 uid root
 deny log tcp from any to any dst-port 25 out
 
 However, the log messages I get look like this:
 
 Sep  8 13:21:11 security.info prime kernel: ipfw: 610 Deny TCP 
 72.9.101.130:58117 209.85.133.114:25 out via em0
 Sep  8 13:21:16 security.info prime kernel: ipfw: 610 Deny TCP 
 72.9.101.130:56672 202.12.31.144:25 out via em0
 
 Which is to say, they don't include the UID -- and I have several hundred 
 sites, each with its own UID.
 
 Yes, I could go ahead and set up a thousand deny rules, one for
 each UID -- but being able to log this info (since it IS being
 checked) would be great.

It should be possible to add a couple more arguments to ipfw_log() so
that ipfw_chk() can pass it the ugid_lookup flag and a pointer to the
fw_ugid_cache struct.  Then you can edit ipfw_log to print the contents
of that struct if ugid_lookup==1.  That would result in the logging of
uid for any failed packet that had to go through a uid check on the way
to the deny rule.

-- 
Dan Nelson
[EMAIL PROTECTED]
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: IPFW uid logging...

2008-09-08 Thread Dan Mahoney, System Admin

On Mon, 8 Sep 2008, Dan Nelson wrote:


In the last episode (Sep 08), Dan Mahoney, System Admin said:

I have the following rule set up in ipfw to limit the exposure of bad
php scripts and trojans that try to send mail directly.

allow tcp from any to any dst-port 25 uid root
deny log tcp from any to any dst-port 25 out

However, the log messages I get look like this:

Sep  8 13:21:11 security.info prime kernel: ipfw: 610 Deny TCP 
72.9.101.130:58117 209.85.133.114:25 out via em0
Sep  8 13:21:16 security.info prime kernel: ipfw: 610 Deny TCP 
72.9.101.130:56672 202.12.31.144:25 out via em0

Which is to say, they don't include the UID -- and I have several hundred
sites, each with its own UID.

Yes, I could go ahead and set up a thousand deny rules, one for
each UID -- but being able to log this info (since it IS being
checked) would be great.


It should be possible to add a couple more arguments to ipfw_log() so
that ipfw_chk() can pass it the ugid_lookup flag and a pointer to the
fw_ugid_cache struct.  Then you can edit ipfw_log to print the contents
of that struct if ugid_lookup==1.  That would result in the logging of
uid for any failed packet that had to go through a uid check on the way
to the deny rule.


Okay, so if it's fairly easy to do, the question would be since I don't 
feel right hacking in this change myself -- how could I propose this as a 
feature?  It's not a BUG per-se, but I think it could be useful to others 
as well.


-Dan

--

Pika Pika Pika!

-Pikachu, of Pokemon fame.

Dan Mahoney
Techie,  Sysadmin,  WebGeek
Gushi on efnet/undernet IRC
ICQ: 13735144   AIM: LarpGM
Site:  http://www.gushi.org
---

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: IPFW uid logging...

2008-09-08 Thread Jeremy Chadwick
On Mon, Sep 08, 2008 at 04:03:29PM -0400, Dan Mahoney, System Admin wrote:
 On Mon, 8 Sep 2008, Dan Nelson wrote:

 In the last episode (Sep 08), Dan Mahoney, System Admin said:
 I have the following rule set up in ipfw to limit the exposure of bad
 php scripts and trojans that try to send mail directly.

 allow tcp from any to any dst-port 25 uid root
 deny log tcp from any to any dst-port 25 out

 However, the log messages I get look like this:

 Sep  8 13:21:11 security.info prime kernel: ipfw: 610 Deny TCP 
 72.9.101.130:58117 209.85.133.114:25 out via em0
 Sep  8 13:21:16 security.info prime kernel: ipfw: 610 Deny TCP 
 72.9.101.130:56672 202.12.31.144:25 out via em0

 Which is to say, they don't include the UID -- and I have several hundred
 sites, each with its own UID.

 Yes, I could go ahead and set up a thousand deny rules, one for
 each UID -- but being able to log this info (since it IS being
 checked) would be great.

 It should be possible to add a couple more arguments to ipfw_log() so
 that ipfw_chk() can pass it the ugid_lookup flag and a pointer to the
 fw_ugid_cache struct.  Then you can edit ipfw_log to print the contents
 of that struct if ugid_lookup==1.  That would result in the logging of
 uid for any failed packet that had to go through a uid check on the way
 to the deny rule.

 Okay, so if it's fairly easy to do, the question would be since I don't  
 feel right hacking in this change myself -- how could I propose this as a 
 feature?  It's not a BUG per-se, but I think it could be useful to 
 others as well.

send-pr it.  Category=kern, Class=change-request.

Reference this thread in the Fix section:

http://lists.freebsd.org/pipermail/freebsd-hackers/2008-September/025920.html

FWIW, I think it's also a good idea.  The output formatting of the log
line might need to be adjusted carefully though, since any programs
which grep on a very strict regex will start failing.  I'm inclined
to recommend the string , UID xxx be appended to the existing string,
e.g.

Sep  8 13:21:11 security.info prime kernel: ipfw: 610 Deny TCP 
72.9.101.130:58117 209.85.133.114:25 out via em0, UID 6592

-- 
| Jeremy Chadwickjdc at parodius.com |
| Parodius Networking   http://www.parodius.com/ |
| UNIX Systems Administrator  Mountain View, CA, USA |
| Making life hard for others since 1977.  PGP: 4BD6C0CB |

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]