Secrets Manager - Self Hosted Requires IPv4 Forwarding to be Enabled
Symptom
Summary:
CyberArk's AAM-DAP is deployed as a Docker container and requires IPv4 forwarding to be enabled. IPv4 forwarding is used by the host operating system to route traffic between the host's physical network interface (ex: eth1) and the Docker bridge network interface (docker0) so that containers can communicate with the other systems on the network by traversing the host's physical network interfaces.
Symptoms:
All network traffic destined for the ports exposed by DAP on the host will stop responding, and
User's may open a case stating that the downstream nodes are reporting connectivity errors:
FATAL: could not connect to the primary server: could not connect to server: Connection refused Is the server running on host "master.example.fqdn" (172.16.73.5) and accepting TCP/IP connections on port 5432
User is unable to query the health API of the node (https://node/health), and
User sees the container and the services it hosts are still running
Environment
Conjur Server
This affects Application Access Manager - Dynamic Access Provider hosted on Linux servers.
NOTE - AAM-DAP, Application Access Manager - Dynamic Access Provider and Conjur Enterprise are old names for Secrets Manager - Self Hosted
Cause
IPv4 forwarding is typically only enabled in devices that function as routers, and many security/vulnerability scanners will incorrectly flag the setting as dangerous when found on standard Linux operating systems that is running Docker containers. In some cases, automatic remediation efforts are taken to disable this functionality, resulting in loss of network connectivity for the Docker containers running on that host. This causes the AAM-DAP services to become unavailable.
Docker and IPv4 Forwarding
Docker uses iptables in order to manage traffic destined for the containers running on a particular host using the 'bridge' network driver, which creates the docker0 network interface and effectively makes the host a router. Security scanners flag IP forwarding because Linux hosts are typically not supposed to be acting as routers. However, docker is doing just that for the containers running on that host. It needs to route traffic between the docker0 network interface and the host's network interfaces. Here are the related iptables entries from a fresh install with comments added inline to explain what they do, and why forwarding is required.
[root@ip-172-31-52-213 ec2-user]# iptables -S
# Default policy for inbound traffic is to accept it.
-P INPUT ACCEPT
# The default policy for the FORWARD chain is DROP.
# Rules must be added to explicitly override this behavior,
# which is done below with the -A FORWARD rules.
-P FORWARD DROP
# Default policy for outbound traffic is ACCEPT.
-P OUTPUT ACCEPT
# Docker creates new chains for the bridge networks (DOCKER)
# so that containers with networking enabled can communicate.
-N DOCKER
# Containers that run on the 'host' network by default are isolated and fall into these two chains
-N DOCKER-ISOLATION-STAGE-1
-N DOCKER-ISOLATION-STAGE-2
# This is a chain providing users an extension to implement container-specific rules
-N DOCKER-USER
# These are the FORWARD chain "jump" rules that send traffic into these DOCKER* chains first.
# If you notice below, the default action for these chains is to return execution back to the calling chain.
# ex: -A DOCKER-ISOLATION-STAGE-1 -j RETURN
# Process all user specific rules first, then isolation rules, then forwards.
-A FORWARD -j DOCKER-USER
-A FORWARD -j DOCKER-ISOLATION-STAGE-1
# These rules do affect traffic routing and this is where IPv4 Forwarding is required. Any existing connections
# outbound TO the docker0 interface are ACCEPTed first.
-A FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
# Traffic TO the container network should be sent to the DOCKER chain first
-A FORWARD -o docker0 -j DOCKER
# Container to container traffic is FORWARDED by the host to the ACCEPT chain. Note that this is only processed
# after the rule above, which actually accepts any traffic bound for the DAP containers. On your DAP hosts,
# for the ports used by DAP (443, 1999, 5432), these two rules will never be processed.
-A FORWARD -i docker0 ! -o docker0 -j ACCEPT
-A FORWARD -i docker0 -o docker0 -j ACCEPT
# These are the rules added to the chains when we defined the container port mappings (-p 443:443).
# This is where traffic headed to the DAP containers get accepted and sent to the container.
-A DOCKER -d 172.17.0.2/32 ! -i docker0 -o docker0 -p tcp -m tcp --dport 5432 -j ACCEPT
-A DOCKER -d 172.17.0.2/32 ! -i docker0 -o docker0 -p tcp -m tcp --dport 1999 -j ACCEPT
-A DOCKER -d 172.17.0.2/32 ! -i docker0 -o docker0 -p tcp -m tcp --dport 444 -j ACCEPT
-A DOCKER -d 172.17.0.2/32 ! -i docker0 -o docker0 -p tcp -m tcp --dport 443 -j ACCEPT
# These are used for "host" isolation networks. See the docker documentation for more information.
# The default action here is ultimately to DROP anything outbound TO these docker interfaces.
# https://docs.docker.com/network/iptables/
-A DOCKER-ISOLATION-STAGE-1 -i docker0 ! -o docker0 -j DOCKER-ISOLATION-STAGE-2
-A DOCKER-ISOLATION-STAGE-1 -j RETURN
-A DOCKER-ISOLATION-STAGE-2 -o docker0 -j DROP
-A DOCKER-ISOLATION-STAGE-2 -j RETURN
# This is the user's extension chain, but right now the default rule is to simply return. The DOCKER-USER chain can
# be used to implement container based firewall rules that apply separately from those of the host's firewall
# rules.
# See https://docs.docker.com/network/iptables/#restrict-connections-to-the-docker-host
-A DOCKER-USER -j RETURN
Resolution
Determine if IPv4 forwarding is enabled (1) or disabled (0)
# As root... # sysctl net.ipv4.ip_forward net.ipv4.ip_forward=0If it is disabled, re-enable it in the running configuration first:
# sysctl -w net.ipv4.ip_forward=1 net.ipv4.ip_forward = 1
Reload the sysctl.conf file and check the value again. If it is disabled again, edit the /etc/sysctl.conf file and update the value to 1 in the file.
# sysctl -p /etc/sysctl.conf # sysctl net.ipv4.ip_forward net.ipv4.ip_forward = 0