kube-ovn icon indicating copy to clipboard operation
kube-ovn copied to clipboard

"portRangeMax" Configuration Does Not Work When "all" Protocol is Set in Security Group

Open wfnuser opened this issue 10 months ago • 12 comments

Bug Report

"portRangeMax" Configuration Does Not Work When "all" Protocol is Set in Security Group

Expected Behavior

For "tcp" protocol... image

Actual Behavior

For "all" protocol... image

Steps to Reproduce the Problem

  1. create a kube-virt virtual machine (Not sure if it works correctly in normal pod)
  2. create a sg like following and bind it to the virtual machine
apiVersion: kubeovn.io/v1
kind: SecurityGroup
metadata:
  creationTimestamp: "2024-04-16T03:10:32Z"
  generation: 28
  name: user-2355-i-njwpuvj7k528-firewall-sg
  resourceVersion: "558026169"
  uid: 53d72488-993e-4c73-ad44-6a13421f2559
spec:
  ingressRules:
  - ipVersion: ipv4
    policy: allow
    portRangeMax: 8000
    portRangeMin: 8000
    priority: 101
    protocol: all
    remoteAddress: 0.0.0.0/0
    remoteType: address
  1. you will find if you set protocol as "all", the portRangeMax/Min seems not working.

Additional Info

  • Kubernetes version:

    Output of kubectl version:

Server Version: v1.26.9


- kube-ovn version:

```bash
v1.12.8
  • operation-system/kernel version:

5.15.0-71-generic


<!-- Any other additional information -->

wfnuser avatar Apr 16 '24 06:04 wfnuser

could you please show the telnet ip:8000?

bobz965 avatar Apr 16 '24 07:04 bobz965

image

apiVersion: kubeovn.io/v1 kind: SecurityGroup metadata: creationTimestamp: "2024-04-16T03:10:32Z" generation: 29 name: user-2355-i-njwpuvj7k528-firewall-sg resourceVersion: "558092262" uid: 53d72488-993e-4c73-ad44-6a13421f2559 spec: ingressRules:

  • ipVersion: ipv4 policy: allow portRangeMax: 8000 portRangeMin: 8000 priority: 101 protocol: all remoteAddress: 0.0.0.0/0 remoteType: address
  • ipVersion: ipv4 policy: deny priority: 161 protocol: ALL remoteAddress: 0.0.0.0/0 remoteType: address
  • ipVersion: ipv4 policy: allow priority: 160 protocol: ALL remoteAddress: 172.16.0.0/11 remoteType: address
  • ipVersion: ipv4 policy: allow priority: 160 protocol: ALL remoteAddress: 10.0.0.0/8 remoteType: address status: allowSameGroupTraffic: false egressLastSyncSuccess: true egressMd5: d751713988987e9331980363e24189ce ingressLastSyncSuccess: true ingressMd5: e4fc8be826456f64c73f9a848abb560f portGroup: ovn.sg.user.2355.i.njwpuvj7k528.firewall.sg

wfnuser avatar Apr 16 '24 07:04 wfnuser

The same time I can ssh connect to 22 port, which should be blocked by the ingress rules. However, if you change "all" to "tcp", the ssh will be disconnected immediately.

wfnuser avatar Apr 16 '24 07:04 wfnuser

could you please show the telnet ip:8000?

your image means the 8000 port is ok , which is works, do i miss something ?

bobz965 avatar Apr 16 '24 07:04 bobz965

could you please show the telnet ip:8000?

your image means the 8000 port is ok , which is works, do i miss something ?

The real problem is if you set a server listen to port 7000, it works either. I just do telnet ip 8000 as you demand.

wfnuser avatar Apr 16 '24 07:04 wfnuser

could you please show the telnet ip:8000?

your image means the 8000 port is ok , which is works, do i miss something ?

The real problem is if you set a server listen to port 7000, it works either. I just do telnet ip 8000 as you demand.

ok, i get it.

bobz965 avatar Apr 16 '24 07:04 bobz965

if you do not set the 8000 allow ingressRules, do ip:8000 could be accessed?

bobz965 avatar Apr 16 '24 07:04 bobz965

if you do not set the 8000 allow ingressRules, do ip:8000 could be accessed?

No. Because I have a rule with lower priority to deny all ingress traffic.

ipVersion: ipv4
policy: deny
priority: 161
protocol: ALL
remoteAddress: 0.0.0.0/0
remoteType: address

I wish to only allow port 8000 ingress traffic by set another rule, however, it seems to allow all ports. But if you set "udp" or "tcp", it will work as expected.

wfnuser avatar Apr 16 '24 07:04 wfnuser

it looks like it is a OVN bug

bobz965 avatar Apr 16 '24 07:04 bobz965

Interesting. So shall we open an issue to OVN? Is there any way to fix it temprorally? BTW, if there are some interested issue you think I can help, you can assign it to me. I would like to help. Recently, I'm hoping to get more familiar with kube-ovn.

wfnuser avatar Apr 16 '24 07:04 wfnuser

Is there any way to fix it temprorally? use TCP or udp, not all, as you said.

bobz965 avatar Apr 16 '24 08:04 bobz965

you can try to attach this issue in ovn GitHub issues for some help.

bobz965 avatar Apr 16 '24 08:04 bobz965

After gaining some background knowledge, I think the standard security group simply don't allow "all" protocol work with port range. Since "ICMP" isn't related to any port.

wfnuser avatar May 09 '24 08:05 wfnuser