Location Research Breakthrough Possible @S-Logix pro@slogix.in

Detecting Man-in-the-Middle (MITM) Attacks Against HAProxy Reverse Proxy Infrastructure Through Secure TLS Communication Architecture

Description

Enterprise applications commonly use reverse proxies to control access between users and backend application services. Reverse proxies can provide centralized TLS termination, traffic routing, access control, and security enforcement.

If encrypted communication is not properly designed or certificate validation is weak, an attacker positioned between a client and the reverse proxy may attempt a Man-in-the-Middle (MITM) Attack to intercept or modify application traffic.

In this use case, HAProxy is deployed on Ubuntu Linux as the controlled enterprise reverse-proxy infrastructure inside an isolated VirtualBox laboratory. A backend web application is placed behind HAProxy to represent an enterprise application architecture.

A controlled Man-in-the-Middle (MITM) Attack is simulated from Kali Linux against the isolated environment.

The assessment focuses on determining whether the enterprise communication architecture properly protects traffic between clients, the HAProxy reverse proxy, and backend application services.

HAProxy, OpenSSL, Bettercap, Wireshark, and nftables are used to establish, test, monitor, and secure the TLS communication architecture.

The proposed defensive architecture implements TLS encryption, certificate validation, secure TLS configuration, controlled communication paths, network segmentation, and traffic monitoring.

After implementing the security controls, the MITM assessment is repeated to verify that intercepted or modified communication cannot be successfully substituted or trusted while legitimate encrypted application communication continues to function.

Existing Security Problem

Application: HAProxy Reverse Proxy

HAProxy provides the controlled reverse-proxy infrastructure used to represent an enterprise application-access architecture. The laboratory environment contains Client Endpoint → Encrypted HTTPS Connection → HAProxy Reverse Proxy → Backend Application Server → Enterprise Application. The HAProxy layer is intended to provide a trusted communication boundary between clients and backend application services.

A Man-in-the-Middle (MITM) Attack attempts to position an attacker between two communicating systems and intercept, observe, or modify their communication.

Existing Problem:

The security problem can occur when TLS encryption is not properly enforced, weak TLS protocols or cipher configurations are allowed, certificates are not properly validated, clients accept untrusted certificates, certificate trust is not centrally managed, backend communication is unnecessarily unencrypted, network segmentation is weak, security monitoring does not identify unexpected interception behavior, or reverse-proxy communication paths are not properly controlled. If these architectural weaknesses exist, an attacker may attempt to intercept HTTPS communication and present an unauthorized certificate or modify traffic between the client and the reverse proxy.

The security problem is therefore:

Client Endpoint → HTTPS Communication → HAProxy Reverse Proxy → Backend Application Server → Enterprise Application

The proposed solution introduces mandatory TLS communication, strong TLS configuration, certificate-based trust, controlled certificate management, secure client-to-proxy communication, secure proxy-to-backend communication where required, network segmentation, firewall-based communication control, and TLS traffic monitoring.

Attack

Specific Attack: Man-in-the-Middle (MITM) Attack

A Man-in-the-Middle (MITM) Attack attempts to place an unauthorized system between a legitimate client and the destination service. In this controlled assessment, the attacker attempts to intercept communication between the test client and the HAProxy reverse proxy. The assessment is performed exclusively within the isolated laboratory.

The assessment focuses on identifying unexpected TLS certificates, certificate trust failures, weak TLS configuration, unencrypted communication paths, unexpected network intermediaries, modified application traffic, unauthorized communication paths, and TLS negotiation weaknesses.

Attack Behavior:
Legitimate Client
HTTPS Communication
Attacker Positioned Between Systems
Traffic Interception Attempt
Unauthorized Certificate / Traffic Modification
HAProxy / Client Trust Validation
Attack Detected or Prevented
TLS Architecture Hardened
Post-Remediation Validation

Security Concept

Secure TLS Communication Architecture:

Enterprise applications should use a trusted encrypted communication architecture between clients, reverse proxies, and backend services.

The security architecture follows: Client → TLS Encryption → HAProxy → Controlled Backend Connection → Application.

The secure processing flow is:

Client
TLS Encryption
HAProxy
Controlled Backend Connection
Application

Defensive Mechanism

Mandatory HTTPS/TLS

The reverse proxy requires encrypted HTTPS communication for protected application access.

Purpose

Prevent sensitive application traffic from being transmitted through insecure plaintext channels.

Certificate Validation

Clients validate the certificate presented by HAProxy against the trusted certificate authority or controlled laboratory trust store.

Purpose

Prevent clients from automatically trusting unauthorized certificates.

Strong TLS Configuration

HAProxy is configured to use approved TLS versions and cryptographic settings.

Purpose

Reduce exposure to weak encryption and insecure protocol configurations.

Certificate Trust Management

Trusted certificates and certificate authorities are explicitly managed.

Purpose

Establish a controlled cryptographic trust boundary between clients and the reverse proxy.

Secure Proxy-to-Backend Communication

HAProxy-to-backend communication is protected with TLS where required by the security architecture.

Purpose

Prevent an attacker who gains access to the internal network from intercepting unprotected backend traffic.

Network Segmentation

Client, reverse-proxy, and backend application systems are placed into separate network segments.

Purpose

Reduce opportunities for an attacker to position themselves within trusted communication paths.

Firewall-Based Communication Control

Only required communication paths are permitted between the client, HAProxy, and backend application.

Purpose

Prevent unauthorized systems from directly accessing protected services.

TLS Traffic Monitoring

TLS connections and network traffic are monitored for abnormal behavior.

Purpose

Identify unexpected certificates, communication paths, and suspicious connection behavior.

Security Event Logging

Relevant TLS and reverse-proxy security events are recorded. Information can include source address, destination address, TLS connection result, certificate validation result, TLS version, connection timestamp, request identifier, and security decision. Sensitive application data and private-key material should not be unnecessarily stored in logs.

Purpose

Support investigation of suspected MITM activity.

Security Tools

Reverse Proxy Infrastructure: HAProxy

HAProxy provides the controlled enterprise reverse-proxy layer.

Purpose
  • Terminate HTTPS connections.
  • Provide TLS configuration.
  • Route requests to backend services.
  • Establish the reverse-proxy security boundary.
  • Support certificate-based communication.
  • Validate secure communication after remediation.

TLS Cryptography and Certificate Tool: OpenSSL

OpenSSL is used to create and inspect certificates and validate TLS configuration.

Purpose
  • Generate laboratory certificates.
  • Establish a controlled certificate authority.
  • Inspect certificates.
  • Test certificate validity.
  • Inspect TLS versions and cryptographic parameters.
  • Support post-remediation TLS validation.

MITM Testing Tool: Bettercap

Bettercap is used from the controlled Kali Linux environment to simulate network interception behavior.

Purpose
  • Perform authorized MITM security testing.
  • Test network interception conditions.
  • Observe communication-path behavior.
  • Validate whether TLS trust controls detect unauthorized interception.
  • Support post-remediation security assessment.

Network Traffic Analysis Tool: Wireshark

Wireshark provides detailed packet-level analysis.

Purpose
  • Capture TLS traffic.
  • Inspect TLS handshakes.
  • Analyze certificates exchanged during TLS negotiation.
  • Identify unexpected communication behavior.
  • Compare legitimate and suspicious traffic.
  • Support post-remediation validation.

Network Security Control: nftables

nftables provides host-level firewall enforcement.

Purpose
  • Restrict access to HAProxy.
  • Limit backend communication.
  • Block unauthorized network paths.
  • Enforce client-to-proxy communication boundaries.
  • Support network segmentation.

TLS Testing Tool: curl

curl is used to generate legitimate HTTPS requests and validate TLS behavior.

Purpose
  • Test HTTPS connectivity.
  • Validate certificate verification.
  • Confirm TLS configuration.
  • Establish normal application communication.
  • Verify legitimate access after remediation.

Security Testing Platform: Kali Linux

Kali Linux provides the controlled security-testing environment.

Purpose
  • Run Bettercap.
  • Perform authorized MITM testing.
  • Run OpenSSL and curl.
  • Capture and analyze network traffic.
  • Validate TLS security controls.

Target Platform: Ubuntu Linux

Ubuntu Linux hosts HAProxy and the controlled backend application environment.

Purpose
  • Host HAProxy.
  • Configure TLS.
  • Host backend services.
  • Apply nftables controls.
  • Maintain security logs.
  • Support post-remediation validation.

Virtualization Platform: VirtualBox

VirtualBox provides the isolated laboratory environment.

Purpose
  • Host Ubuntu systems.
  • Host Kali Linux.
  • Create isolated network segments.
  • Reproduce the enterprise reverse-proxy architecture.
  • Prevent testing activity from affecting external networks.

Process

STEP 01

Step 1: Prepare the Isolated Enterprise Security Architecture Laboratory

  • Create an isolated laboratory using VirtualBox.
  • Configure Ubuntu Linux as the reverse-proxy server.
  • Configure a separate Ubuntu system as the backend application server.
  • Configure Kali Linux as the security-testing system.
  • Create the required network segments.
  • Verify connectivity between the required laboratory systems.
Tools: VirtualBox + Ubuntu Linux + Kali Linux
STEP 02

Step 2: Deploy the Backend Application

  • Install a controlled web application on the backend Ubuntu server.
  • Configure the application to listen only on the required interface.
  • Verify that the backend application is operational.
  • Confirm that direct access is restricted according to the architecture.
Tools: Ubuntu Linux
STEP 03

Step 3: Deploy HAProxy

  • Install HAProxy on the reverse-proxy Ubuntu server.
  • Configure HAProxy to receive client requests.
  • Configure the backend application as the destination service.
  • Start the HAProxy service.
  • Verify that requests can reach the backend through HAProxy.
Tools: HAProxy + Ubuntu Linux
STEP 04

Step 4: Design the Secure Communication Architecture

  • Define the intended communication paths: Client Network → HTTPS / TLS → HAProxy Reverse Proxy → Controlled Backend Connection → Backend Application.
  • Identify trusted communication paths.
  • Identify protected network segments.
  • Document which systems are allowed to communicate.
Tools: HAProxy + VirtualBox
STEP 05

Step 5: Establish the Laboratory Certificate Authority

  • Create a controlled laboratory certificate authority.
  • Generate the certificate required by HAProxy.
  • Configure the certificate with the appropriate server identity.
  • Protect the laboratory private-key material.
  • Verify the certificate structure.
Tools: OpenSSL + Ubuntu Linux
STEP 06

Step 6: Configure TLS on HAProxy

  • Configure HAProxy for HTTPS.
  • Install the laboratory server certificate.
  • Configure the approved TLS versions.
  • Configure secure cryptographic parameters.
  • Disable unnecessary insecure TLS configurations.
  • Restart HAProxy safely.
Tools: HAProxy + OpenSSL
STEP 07

Step 7: Establish the TLS Security Baseline

  • Connect to HAProxy using curl.
  • Verify that HTTPS communication is established.
  • Validate the server certificate.
  • Inspect the TLS handshake.
  • Record the negotiated TLS version.
  • Establish the normal secure communication baseline.
Tools: curl + OpenSSL + Wireshark
STEP 08

Step 8: Validate Legitimate Application Communication

  • Send normal HTTPS requests through HAProxy.
  • Verify that the backend application responds correctly.
  • Confirm that legitimate requests are routed through the reverse proxy.
  • Verify that protected application functionality remains available.
  • Record normal request and response behavior.
Tools: curl + HAProxy
STEP 09

Step 9: Configure Network Security Boundaries

  • Separate client, reverse-proxy, and backend systems into controlled network segments.
  • Configure nftables on the relevant Ubuntu systems.
  • Allow only required communication paths.
  • Block unnecessary direct access to the backend.
  • Verify the intended communication boundaries.
Tools: nftables + Ubuntu Linux
STEP 10

Step 10: Prepare the Controlled MITM Assessment

  • Configure Kali Linux as the authorized security-testing system.
  • Prepare the isolated network environment for the assessment.
  • Configure Bettercap for controlled interception testing.
  • Confirm that only laboratory systems are within the testing scope.
  • Verify that the assessment cannot affect external networks.
Tools: Kali Linux + Bettercap
STEP 11

Step 11: Perform the Controlled MITM Attack Simulation

  • Initiate the controlled MITM assessment within the isolated laboratory.
  • Attempt to position the testing system within the communication path.
  • Generate HTTPS requests from the controlled client.
  • Observe the resulting communication behavior.
  • Monitor whether the client detects certificate or TLS trust changes.
Tools: Bettercap + curl
STEP 12

Step 12: Analyze TLS Communication

  • Capture the TLS communication.
  • Inspect the TLS handshake.
  • Review the certificate presented to the client.
  • Compare the certificate with the trusted laboratory certificate.
  • Identify any unexpected certificate or communication-path change.
Tools: Wireshark + OpenSSL
STEP 13

Step 13: Establish the MITM Security Finding

  • Correlate network traffic with certificate information.
  • Identify whether the communication path was successfully intercepted.
  • Determine whether the client accepted or rejected the unexpected certificate.
  • Identify any TLS or trust-architecture weakness.
  • Document the MITM security finding.
Tools: Wireshark + OpenSSL + Bettercap
STEP 14

Step 14: Implement TLS Security Hardening

  • Enforce HTTPS on HAProxy.
  • Remove insecure TLS configurations.
  • Enforce approved TLS versions and cryptographic settings.
  • Verify certificate configuration.
  • Ensure clients validate the trusted certificate authority.
  • Reload the HAProxy configuration.
Tools: HAProxy + OpenSSL
STEP 15

Step 15: Strengthen Network Communication Boundaries

  • Review nftables rules.
  • Restrict access to HAProxy to authorized client networks.
  • Restrict backend access to HAProxy.
  • Prevent unnecessary direct client-to-backend communication.
  • Verify the revised network architecture.
Tools: nftables + Ubuntu Linux
STEP 16

Step 16: Re-Test the MITM Attack After Remediation

  • Repeat the controlled MITM assessment.
  • Generate HTTPS traffic through the protected architecture.
  • Monitor the TLS handshake.
  • Inspect the presented certificate.
  • Verify that the client rejects unauthorized certificate or interception conditions.
  • Compare the post-remediation result with the original assessment.
Tools: Bettercap + curl + Wireshark + OpenSSL
STEP 17

Step 17: Validate Legitimate Secure Communication

  • Stop the controlled MITM assessment.
  • Restore the normal network path.
  • Connect to HAProxy using the legitimate client.
  • Validate the trusted certificate.
  • Send normal HTTPS requests.
  • Confirm that the backend application remains accessible through the authorized reverse-proxy path.
Tools: curl + HAProxy + OpenSSL
STEP 18

Step 18: Perform Final Security Architecture Validation

  • Review the complete TLS security assessment.
  • Review HAProxy TLS configuration.
  • Review certificate trust configuration.
  • Review nftables communication controls.
  • Review captured TLS traffic.
  • Confirm that unauthorized interception conditions are detected or prevented.
  • Confirm that unauthorized direct backend access is restricted.
  • Confirm that legitimate HTTPS communication continues to function.
  • Verify the final reverse-proxy security architecture.
  • Document the MITM detection, TLS hardening, network-boundary enforcement, and post-remediation validation results.
Tools: HAProxy + OpenSSL + Bettercap + Wireshark + nftables + curl + Ubuntu Linux + Kali Linux

Outcome

  1. An enterprise-style HAProxy reverse-proxy architecture is successfully deployed within an isolated VirtualBox security laboratory.
  2. Separate client, reverse-proxy, and backend application communication boundaries are established.
  3. Secure HTTPS communication is configured using TLS and a controlled certificate trust architecture.
  4. A controlled Man-in-the-Middle (MITM) Attack is simulated using Bettercap within the authorized laboratory environment.
  5. TLS handshakes and certificate information are captured and analyzed using Wireshark and OpenSSL.
  6. TLS configuration, certificate trust, and network communication paths are assessed to identify MITM-related architectural weaknesses.
  7. Secure communication controls are implemented through TLS enforcement, certificate validation, strong TLS configuration, network segmentation, and firewall-based communication restrictions.
  8. Post-remediation testing confirms that unauthorized interception or certificate-substitution conditions are detected or rejected according to the configured security architecture.
  9. Legitimate HTTPS communication through HAProxy and access to the authorized backend application continue to function after remediation.
  10. The use case demonstrates Enterprise Security Architecture through secure reverse-proxy design, TLS communication architecture, certificate-based trust, network segmentation, communication-boundary enforcement, MITM detection, and post-remediation security validation.