Skip to content

accept events seemingly with reversed client and server IP/ports #3620

Description

@dnwe

Describe the bug

Periodically we see a number of inbound accept events where the client and server IP and port in the connection tuple seem like they are the wrong way around and the static listener port (e.g., 443, 2040, 8081, 9090, 9091 etc.) is tracked as the client port (fd.cport) and the ephemeral range port is tracked as the server port (fd.sport).

Here's a dump of sysdig --modern-bpf -j 'evt.type in (accept,accept4,listen) and evt.dir=< and fd.sport>=32768' using the same bpf level as falco that seems to show these coming from the bpf driver:

{"evt.cpu":0,"evt.dir":"<","evt.info":"fd=36(<4t>172.20.0.1:2040->172.20.0.1:48693) tuple=172.20.0.1:2040->172.20.0.1:48693 queuepct=0 queuelen=0 queuemax=0","evt.num":1120567,"evt.outputtime":1750075498103591233,"evt.type":"accept","proc.name":"kubelet","proc.pid":8594,"thread.tid":8594}
{"evt.cpu":0,"evt.dir":"<","evt.info":"fd=68(<4t>172.30.31.146:9090->172.30.35.245:37786) tuple=172.30.31.146:9090->172.30.35.245:37786 queuepct=0 queuelen=0 queuemax=0","evt.num":4179273,"evt.outputtime":1750077601098514978,"evt.type":"accept","proc.name":"prometheus","proc.pid":105796,"thread.tid":105941}
{"evt.cpu":0,"evt.dir":"<","evt.info":"fd=47(<4t>172.30.31.148:9091->172.30.35.245:52250) tuple=172.30.31.148:9091->172.30.35.245:52250 queuepct=0 queuelen=0 queuemax=0","evt.num":4631781,"evt.outputtime":1750077911077389135,"evt.type":"accept","proc.name":"prometheus","proc.pid":105796,"thread.tid":105951}
{"evt.cpu":0,"evt.dir":"<","evt.info":"fd=48(<4t>172.30.102.133:8081->172.30.35.245:34032) tuple=172.30.102.133:8081->172.30.35.245:34032 queuepct=0 queuelen=0 queuemax=0","evt.num":4642001,"evt.outputtime":1750077918462537590,"evt.type":"accept","proc.name":"prometheus","proc.pid":105796,"thread.tid":105954}
{"evt.cpu":1,"evt.dir":"<","evt.info":"fd=7(<4t>172.21.0.1:443->172.30.35.234:54098) tuple=172.21.0.1:443->172.30.35.234:54098 queuepct=0 queuelen=0 queuemax=0","evt.num":5123972,"evt.outputtime":1750078248974904459,"evt.type":"accept","proc.name":"pod_nanny","proc.pid":12358,"thread.tid":12378}
{"evt.cpu":0,"evt.dir":"<","evt.info":"fd=33(<4t>172.21.225.209:9090->172.30.35.219:48134) tuple=172.21.225.209:9090->172.30.35.219:48134 queuepct=0 queuelen=0 queuemax=0","evt.num":5686812,"evt.outputtime":1750078633237538685,"evt.type":"accept","proc.name":"customer-metric","proc.pid":35913,"thread.tid":35918}
{"evt.cpu":0,"evt.dir":"<","evt.info":"fd=8(<4t>172.30.222.85:9090->172.30.35.245:51912) tuple=172.30.222.85:9090->172.30.35.245:51912 queuepct=0 queuelen=0 queuemax=0","evt.num":6424831,"evt.outputtime":1750079137273125101,"evt.type":"accept","proc.name":"prometheus","proc.pid":105796,"thread.tid":105951}
{"evt.cpu":1,"evt.dir":"<","evt.info":"fd=8(<4t>172.30.222.85:9090->172.30.35.245:55938) tuple=172.30.222.85:9090->172.30.35.245:55938 queuepct=0 queuelen=0 queuemax=0","evt.num":8058449,"evt.outputtime":1750080253497731940,"evt.type":"accept","proc.name":"prometheus","proc.pid":105796,"thread.tid":105941}
{"evt.cpu":1,"evt.dir":"<","evt.info":"fd=55834574866(<4t>172.30.12.69:9195->172.30.35.222:34134) tuple=172.30.12.69:9195->172.30.35.222:34134 queuepct=0 queuelen=0 queuemax=0","evt.num":8959420,"evt.outputtime":1750080868580866165,"evt.type":"accept4","proc.name":"hyperion","proc.pid":38060,"thread.tid":38060}
{"evt.cpu":0,"evt.dir":"<","evt.info":"fd=62(<4t>172.30.12.74:9090->172.30.35.245:57548) tuple=172.30.12.74:9090->172.30.35.245:57548 queuepct=0 queuelen=0 queuemax=0","evt.num":9430541,"evt.outputtime":1750081189555311594,"evt.type":"accept","proc.name":"prometheus","proc.pid":105796,"thread.tid":105941}
{"evt.cpu":0,"evt.dir":"<","evt.info":"fd=8(<4t>172.30.110.6:9091->172.30.35.245:55826) tuple=172.30.110.6:9091->172.30.35.245:55826 queuepct=0 queuelen=0 queuemax=0","evt.num":10722260,"evt.outputtime":1750082070794044987,"evt.type":"accept","proc.name":"prometheus","proc.pid":105796,"thread.tid":105951}

In falco terms these trigger our unexpected network traffic rules. Do you have any idea of what could be the cause of this behaviour?

How to reproduce it

Unknown

Expected behaviour

I'd expect the accept events to have the server port of the listener

Screenshots

N/A

Environment

  • Falco version: {"default_driver_version":"8.1.0+driver","driver_api_version":"8.0.0","driver_schema_version":"3.6.0","engine_version":"50","engine_version_semver":"0.50.0","falco_version":"0.41.0","libs_version":"0.21.0","plugin_api_version":"3.11.0"}
  • System info: Linux version 6.8.0-60-generic (buildd@lcy02-amd64-054) (x86_64-linux-gnu-gcc-13 (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0, GNU ld (GNU Binutils for Ubuntu) 2.42) #63-Ubuntu SMP PREEMPT_DYNAMIC Tue Apr 15 19:04:15 UTC 2025
  • Cloud provider or hardware configuration:
  • OS: Ubuntu 24.04.2 LTS (Noble Numbat)
  • Kernel: 6.8.0-60-generic

  • Installation method: from source

Additional context

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions