Skip to contentSkip to conversation

Possible to block ports by user group?

DISCUSSION Michael Frank 4 participants 7 messages Jul 4, 2004 – Jul 5, 2004

lore
Share & tools
lore
#0 lore raw

Would like to block ports depending on the group in use

For example:

group "browser" can only access port tcp 8118 so it _must_ talk through privoxy

group "wget" can access ports tcp 21 and 80

group "trusted" can access all ports

Searched and googled but could not find anything.

How can this be done?

Michael

#1 lore raw
Quoted 1 line · Michael Frank

Would like to block ports depending on the group in use

I don't understand what you mean by "group" (well, I understand what you mean by it, but I don't understand where this is specified, or what it's associated with).

Quoted 5 lines

For example:

group "browser" can only access port tcp 8118 so it _must_ talk through privoxy

Quoted 7 lines

group "wget" can access ports tcp 21 and 80

group "trusted" can access all ports

Searched and googled but could not find anything.

How can this be done?

Where / how are these groups defined? What identifies a PC as being part of
a specific group?

Regards,

Antony.

Signature · 5 lines
Abandon hope, all ye who enter here.
You'll feel much better about things once you do.

                                                     Please reply to the list;
                                                           please don't CC me.
#3 lore raw
In reply to Michael Frank
Quoted 1 line · Michael Frank

Would like to block ports depending on the group in use

See owner match :

cbr@anduril:~$ iptables -m owner --help
iptables v1.2.11
[...]
OWNER match v1.2.11 options:
[!] --uid-owner userid     Match local uid
[!] --gid-owner groupid    Match local gid
[!] --pid-owner processid  Match local pid
[!] --sid-owner sessionid  Match local sid
[!] --cmd-owner name       Match local command name

--gid-owner seems to satisfy your needs.

Signature · 2 lines
http://www.netexit.com/~sid/
PGP KeyID: 157E98EE FingerPrint: FA62226DA9E72FA8AECAA240008B480E157E98EE
Quoted 2 lines
Quoted 2 lines

Hi! I'm your friendly neighbourhood signature virus. Copy me to your signature file and help me spread!

#2 lore raw
In reply to Antony Stone
Quoted 15 lines · Antony Stone
Quoted 1 line · Michael Frank

Would like to block ports depending on the group in use

I don't understand what you mean by "group" (well, I understand what you mean by it, but I don't understand where this is specified, or what it's associated with).

Quoted 7 lines

For example:

group "browser" can only access port tcp 8118 so it _must_ talk through privoxy

group "wget" can access ports tcp 21 and 80

Quoted 8 lines
Quoted 5 lines

group "trusted" can access all ports

Searched and googled but could not find anything.

How can this be done?

Where / how are these groups defined? What identifies a PC as being part of
a specific group?

Linux machine user group or user id.

Regards
Michael

#4 lore raw
In reply to Cedric Blancher
Quoted 15 lines · Cedric Blancher
Quoted 1 line · Michael Frank

Would like to block ports depending on the group in use

See owner match :

cbr@anduril:~$ iptables -m owner --help
iptables v1.2.11
[...]
OWNER match v1.2.11 options:
[!] --uid-owner userid     Match local uid
[!] --gid-owner groupid    Match local gid
[!] --pid-owner processid  Match local pid
[!] --sid-owner sessionid  Match local sid
[!] --cmd-owner name       Match local command name
Quoted 3 lines

--gid-owner seems to satisfy your needs.

Thank you for the pointer. This works very well.

I think there is a problem though wrt ICMP requests. The following rule allows _everyone_ to ping, but I would expect only root to be able to.

ACCEPT all -- anywhere anywhere OWNER UID match root

This rule has no effect on ICMP i am mhf and can't ping.

ACCEPT all -- anywhere anywhere OWNER UID match mhf

This is with Vanilla kernel 2.4.24. Any know issue here?

No big deal, - I should try a later kernel soon.

Here is the whole list.

Chain INPUT (policy DROP)

target     prot opt source               destination
DROP       tcp  --  anywhere             anywhere           tcp flags:FIN,SYN,RST,PSH,ACK,URG/FIN,SYN,RST,PSH,ACK,URG
DROP       tcp  --  anywhere             anywhere           tcp flags:FIN,SYN,RST,PSH,ACK,URG/NONE
LOG        icmp --  anywhere             anywhere           icmp echo-request limit: avg 1/sec burst 5 LOG level warning prefix `ipt - Ping of Death Blocked: '
DROP       icmp --  anywhere             anywhere           icmp echo-request limit: avg 1/sec burst 5
syn-flood  tcp  --  anywhere             anywhere           tcp flags:SYN,RST,ACK/SYN
DROP       tcp  --  anywhere             anywhere           tcp flags:FIN,SYN,RST,PSH,ACK,URG/FIN,PSH,URG
DROP       tcp  --  anywhere             anywhere           tcp flags:FIN,SYN,RST,PSH,ACK,URG/FIN,SYN,RST,ACK,URG
DROP       tcp  --  anywhere             anywhere           tcp flags:SYN,RST/SYN,RST
DROP       tcp  --  anywhere             anywhere           tcp flags:FIN,SYN/FIN,SYN
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere           state RELATED,ESTABLISHED

Chain FORWARD (policy DROP)

target     prot opt source               destination
DROP       tcp  --  anywhere             anywhere           tcp flags:FIN,SYN,RST,PSH,ACK,URG/FIN,SYN,RST,PSH,ACK,URG
DROP       tcp  --  anywhere             anywhere           tcp flags:FIN,SYN,RST,PSH,ACK,URG/NONE
LOG        icmp --  anywhere             anywhere           icmp echo-request limit: avg 1/sec burst 5 LOG level warning prefix `ipt - Ping of Death Blocked: '
DROP       icmp --  anywhere             anywhere           icmp echo-request limit: avg 1/sec burst 5
syn-flood  tcp  --  anywhere             anywhere           tcp flags:SYN,RST,ACK/SYN
ACCEPT     all  --  anywhere             anywhere           state RELATED,ESTABLISHED
LOG        all  --  anywhere             anywhere           limit: avg 10/min burst 10 LOG level alert prefix `ipt - FORWARD dropped: '

Chain OUTPUT (policy DROP)

target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere           OWNER UID match root
ACCEPT     all  --  anywhere             anywhere           OWNER UID match mhf
ACCEPT     tcp  --  anywhere             anywhere           tcp dpt:domain OWNER GID match guest
ACCEPT     tcp  --  anywhere             anywhere           tcp dpt:smtp OWNER GID match guest
ACCEPT     tcp  --  anywhere             anywhere           tcp dpt:pop3 OWNER GID match guest
ACCEPT     tcp  --  anywhere             anywhere           tcp dpt:ftp OWNER GID match guest
ACCEPT     tcp  --  anywhere             anywhere           tcp dpt:http OWNER GID match guest
ACCEPT     tcp  --  anywhere             anywhere           tcp dpt:8118 OWNER GID match guest
ACCEPT     udp  --  anywhere             anywhere           udp dpt:domain OWNER GID match guest
ACCEPT     all  --  anywhere             anywhere           state RELATED,ESTABLISHED
LOG        all  --  anywhere             anywhere           limit: avg 10/min burst 10 LOG level alert prefix `ipt - OUTPUT dropped: '

Chain syn-flood (2 references)

target     prot opt source               destination
RETURN     all  --  anywhere             anywhere           limit: avg 1/sec burst 4
LOG        all  --  anywhere             anywhere           LOG level warning prefix `ipt - Blocked SYN Flood: '
DROP       all  --  anywhere             anywhere

Any comments?

Regards
Michael

#5 lore raw
Quoted 1 line · Michael Frank

On Sun, 04 Jul 2004 16:59:04 +0200, Cedric Blancher

Quoted 25 lines · <[email protected]> wrote:
Quoted 15 lines · Michael Frank
Quoted 1 line

Would like to block ports depending on the group in use

See owner match :

cbr@anduril:~$ iptables -m owner --help
iptables v1.2.11
[...]
OWNER match v1.2.11 options:
[!] --uid-owner userid     Match local uid
[!] --gid-owner groupid    Match local gid
[!] --pid-owner processid  Match local pid
[!] --sid-owner sessionid  Match local sid
[!] --cmd-owner name       Match local command name
Quoted 1 line

--gid-owner seems to satisfy your needs.

Thank you for the pointer. This works very well.

I think there is a problem though wrt ICMP requests. The following rule allows _everyone_ to ping, but I would expect only root to be able to.

ACCEPT all -- anywhere anywhere OWNER UID match
root

Quoted 7 lines

This rule has no effect on ICMP i am mhf and can't ping.

ACCEPT all -- anywhere anywhere OWNER UID match
mhf

This is with Vanilla kernel 2.4.24. Any know issue here?

	I would suggest that in all likelyhood your ping/traceroute are setuid root.
	*grin*

	Alistair.
#6 lore raw
Quoted 30 lines · Alistair Tonner
Quoted 1 line · Michael Frank

On Sun, 04 Jul 2004 16:59:04 +0200, Cedric Blancher

Quoted 27 lines · <[email protected]> wrote:
Quoted 15 lines · Michael Frank
Quoted 1 line

Would like to block ports depending on the group in use

See owner match :

cbr@anduril:~$ iptables -m owner --help
iptables v1.2.11
[...]
OWNER match v1.2.11 options:
[!] --uid-owner userid     Match local uid
[!] --gid-owner groupid    Match local gid
[!] --pid-owner processid  Match local pid
[!] --sid-owner sessionid  Match local sid
[!] --cmd-owner name       Match local command name
Quoted 1 line

--gid-owner seems to satisfy your needs.

Thank you for the pointer. This works very well.

I think there is a problem though wrt ICMP requests. The following rule allows _everyone_ to ping, but I would expect only root to be able to.

ACCEPT all -- anywhere anywhere OWNER UID match
root

This rule has no effect on ICMP i am mhf and can't ping.

Quoted 9 lines
Quoted 5 lines

ACCEPT all -- anywhere anywhere OWNER UID match
mhf

This is with Vanilla kernel 2.4.24. Any know issue here?

	I would suggest that in all likelyhood your ping/traceroute are setuid root.
	*grin*

ping must be root or suid root, the packet count of "UID match root" increases with ping and nmap does work non root.

Thank you :)

Michael