TCAT-AS-000170 - Tomcat servers behind a proxy or load balancer must log client IP.

Warning! Audit Deprecated

This audit has been deprecated and will be removed in a future update.

View Next Audit Version

Information

When running Tomcat behind a load balancer or proxy, default behavior is for Tomcat to log the proxy or load balancer IP address as the client IP. Desired behavior is to log the actual client IP rather than the proxy IP address. The RemoteIpValve logging component instructs Tomcat to grab the HTTP header X-Forwarded-For and use that for access logging.

Tomcat will identify 127.0.0.1, class A and class C RFC1918 addresses as internal proxy addresses; however, if the proxy has a routable IP or a class B private network address space (172.16.0.0/12), the user must also verify the 'internalProxies setting is configured to reflect the proxy IP address.

Solution

From the Tomcat server as a privileged user:

Edit the $CATALINA_BASE/conf/server.xml file.

Only execute this first step if the proxy server is using a routable IP address or an RFC 1918 Class B address space: Add or edit the RemoteIpValve and configure the internalProxies setting to reflect the proxy addresses.

Modify the AccessLogValve and configure the requestAttributesEnabled setting = 'True'.

EXAMPLE:

<Valve className='org.apache.catalina.valves.RemoteIpValve' internalProxies='172.16.0.10|172.16.0.11' />

<Valve className='org.apache.catalina.valves.AccessLogValve'
directory='logs'
prefix='access'
suffix='.log'
pattern='combined'
renameOnRotate='true'
requestAttributesEnabled='true'
/>

Restart Tomcat:
sudo systemctl restart tomcat
sudo systemctl tomcat daemon-reload

See Also

https://dl.dod.cyber.mil/wp-content/uploads/stigs/zip/U_Apache_Tomcat_Application_Server_9_V2R7_STIG.zip

Item Details

References: CAT|II, CCI|CCI-000169, Rule-ID|SV-222937r879559_rule, STIG-ID|TCAT-AS-000170, STIG-Legacy|SV-111405, STIG-Legacy|V-102457, Vuln-ID|V-222937

Plugin: Unix

Control ID: 9ec35af2f4e663d5916c444b04369896f0e40d4c385d64eb88de6221ca531031