Skip to main content

Collection of Traffic Logs in case of Azure Application Gateway

Centralized collection and storage of traffic logs is one of the most important pieces of any enterprise security environment and it is crucial to have the information about the source (resource requester). In most cases this is as simple as installing an agent on the server and / or forwarding the log files to the log collector / SIEM etc. However, in some cases, it is not so straight forward.

Azure Application Gateway

Azure Application Gateway


Consider an Internet facing application that you have hosted in you Azure infrastructure. Just a quick refresher, an Azure Application Gateway:

  • is an OSI Layer-7 load-balancer
  • is capable of performing an SSL termination
  • is a reverse proxy (like any standard load balancer)
  • is capable of performing health checks of the backend servers (which host the actual application content) and thereby ensure that if one of the backend servers goes down, it automatically stops sending the traffic to this bad server and thereby save you from an outage

The following setup shows users enter the FQDN which resolves to the Frontend IP of the Application Gateway. 


Azure Application Gateway
                                                                        Azure Application Gateway


The HTTP/HTTPS listeners are the list of the URLs that you ask the Application Gateway to listen for.. For eg. if the listener configured is www.abc.com and if the user requests www.xyz.com (which is not configured as a listener on the Application Gateway, the traffic will be dropped there and then itself. 

The rules dictate which backend pool (which contains our servers) the traffic will be forwarded to.

Now, here is the catch.

When the traffic leaves Application Gateway - AG (and heads towards one of the servers depending on the rule), the AG performs a "source NAT" on the traffic. The source IP of the packet leaving the Application Gateway is now changed to the AG's Backend IP address (this IP address is derived from the Backend Subnet that is configured for the AG).

This implies the servers (present in the backend pool) can NOT see the original IP address of the user who is accessing the application. All it sees is the backend IP of the Application Gateway. This definitely cannot be used for log and threat analysis, forensics etc. and defeats the entire purpose of doing a log collection.

X-Forwarded-For
                                                                              X-Forwarded-For

However, Azure has a workaround for this.. Azure Application Gateway, while serving as the first termination point of the traffic, before changing the source IP to its backend IP, copies the original user IP address to X-Forwarded-For (acr. as XFF) header. 

All the current servers and most of the older servers have the ability to read these XFF headers and forward them to the remote log collection server.

This way, the original user IP address is still retained with our logs and all the relevant traffic from the particular user IP address can be retrieved and analyzed.



Comments

  1. Thanks, What exact header value to be enter for X-Forwarded-For to remains Client IP as source for backend pool.

    ReplyDelete

Post a Comment

Popular posts from this blog

MITRE ATT&CK - Kerberos Vulnerabilities and Security

From the previous post, the summary of Kerberos authentication process is as below: For the initial authentication, the user’s client machine sends a request to the KDC  Authentication Service (AS) . The request includes details like the user’s username, and the date and time. All information except the username is encrypted using the hash of the user’s password. The KDC AS uses the username to look up its copy of the user’s password hash and uses it to decrypt the rest of the request. If the decryption is successful, that means the client used the correct password hash and the user has successfully authenticated. Once the user is authenticated, the KDC AS sends the user’s client a  ticket granting ticket   (TGT) . The TGT includes a unique session key and a timestamp that specifies how long that session is valid (normally 8 or 10 hours). Importantly, before sending the TGT, the KDC encrypts it using the password hash for a special account, the  KRBTGT account. ...

Checkpoint - Exporting Objects in CSV format

Be it a Network Operations Manager, Security Architect or a Security Auditor, the people up the hierarchy always harangue the Security Engineers to compile the list of firewall objects or rules or policies or the traffic statistics and so on.. This can turn out to be quite hectic especially if there are no built in features to systematically provide the output in a "layman-readable" format. Come, Checkpoint's "Object Explorer..."  which not only provides the output in the "layman-readable" format, but also provides in-built filtering mechanisms, thereby ensuring that the Security Engineer doesn't have to rely on Google for building his scarce Microsoft Excel data filtering skills. The following screenshots will show how easy it is, with Checkpoint R80.10 to generate the firewall configuration inventory. On the SmartConsole Unified Portal, navigate to Menu >> Open Object Explorer... Select the Categories you wish to see in your output: Click o...

MITRE ATT&CK - Understanding Kerberos (for Golden Ticket Attack)

Kerberos = Network Authentication Protocol used by AD environments Provides authentication by issuing tickets to authenticate users and allow them access to the services Tickets are distibuted by KDC (Key Distribution Center), which is typically a Domain Controller (DC) During initial authentication, a TGT (Ticket Granting Ticket) is a ticket asigned to a user by KDC. TGT is later used to authenticate the user to the KDC in order to request a service ticket from TGS (Ticket Granting Service). Service tickets are granted for authentication against services. List of steps / negotiations for Kerberos authentication (of the user with the service): The user requests  (AS-REQ)  a TGT from the KDC and the KDC verifies and validates the credentials and user information. This request if often done automatically at login. After authenticating the user, the KDC sends an encrypted TGT back to the requester  (AS-REP) . The user presents the TGT to the DC and requests a TGS  (TGS-...