spoa-modsecurity icon indicating copy to clipboard operation
spoa-modsecurity copied to clipboard

forwarding Source IP as client IP

Open Rdago opened this issue 3 years ago • 7 comments
trafficstars

When using spoa on Haproxy the modproxy logs keep showing that the connected client is the haproxy itself (which in my case is 127.0.0.1, as I run the agent on the server in a docker) and modproxy logs this IP.

Is there a way to include the original source IP which connected to the HAproxy beforehand and pass it to modsecurity - in a forwarded for header for example?

The problem is that some features like geoip or ip reputation do not work on this scenario. Moreover when using siem-solution for logging the modsecurity logs and threats the connecting IP is always localhost.

Im looking forward to receive some tipps or even a solution how to handle this.

Thanks in advance.

Rdago avatar Jan 21 '22 21:01 Rdago

yah just ran into this now. basically white listing cannot work???? @Rdago did you find a solution?

jessequinn avatar Jul 11 '22 14:07 jessequinn

@Rdago i see your forked the repo and made some changes. But did you fix the forwardfor? I see something about UniqueID.

jessequinn avatar Jul 11 '22 14:07 jessequinn

@jessequinn I am also having the same issue, have you got any solution? how to get client-IP back on Modsecurity.

amitnarwal-sec avatar Jul 18 '22 03:07 amitnarwal-sec

I am also having the same issue, is there any solution for this?

mario-almeida avatar Oct 09 '22 19:10 mario-almeida

I also have the same problem. Any solution?

evasokolova1f avatar Oct 20 '22 10:10 evasokolova1f

same problem here.

the trick i use to match requests in haproxy and modsec is the uniqid header.

in /etc/haproxy/haproxy.cfg, add this in frontend section :

	# Add unique-id Header
	unique-id-format %{+X}o\ %ci:%cp_%fi:%fp_%Ts_%rt:%pid
	unique-id-header X-Unique-ID

and modify this in default section :

	#option	httplog
	log-format "%ci:%cp [%tr] %ft %b/%s %TR/%Tw/%Tc/%Tr/%Ta %ST %B %CC %CS %tsc %ac/%fc/%bc/%sc/%rc %sq/%bq %hr %hs %{+Q}r %ID"

Regards

CorentinS6 avatar Oct 20 '22 11:10 CorentinS6

Thank you @CorentinS6 It solved the problem.

amitnarwal-sec avatar Oct 21 '22 00:10 amitnarwal-sec