Skip to content

Introduce an ACL for blocking on tcp layer#882

Draft
hoffmaen wants to merge 1 commit intocloudfoundry:masterfrom
sap-contributions:tcp-blocking
Draft

Introduce an ACL for blocking on tcp layer#882
hoffmaen wants to merge 1 commit intocloudfoundry:masterfrom
sap-contributions:tcp-blocking

Conversation

@hoffmaen
Copy link
Contributor

@hoffmaen hoffmaen commented Feb 26, 2026

TCP-Level CIDR Blocking

Introduces a new property ha_proxy.cidr_blocklist_tcp that enables blocking client connections at the TCP layer, before TLS negotiation occurs.

Implementation

  • Property: ha_proxy.cidr_blocklist_tcp (optional array of CIDRs or base64-encoded gzipped string)
  • Configuration File: /var/vcap/jobs/haproxy/config/blocklist_cidrs_tcp.txt
  • Behavior: CIDRs in the blocklist are rejected immediately after TCP connection establishment
  • Dynamic Updates: CIDRs can be added or removed on-the-fly via the HAProxy socket without reloading:
    # Add CIDR to blocklist
    echo 'add acl /var/vcap/jobs/haproxy/config/blocklist_cidrs_tcp.txt 10.0.1.1/24' | socat - /var/vcap/sys/run/haproxy/stats.sock
    
    # Remove CIDR from blocklist
    echo 'del acl /var/vcap/jobs/haproxy/config/blocklist_cidrs_tcp.txt 10.0.1.1/24' | socat - /var/vcap/sys/run/haproxy/stats.sock

Connection Flow for Blocked Clients

For HTTPS connections:

  1. Client establishes TCP connection to HAProxy
  2. Client initiates TLS handshake (Client Hello)
  3. HAProxy terminates connection (TCP FIN)

This approach blocks clients before the expensive TLS handshake completes, improving performance and reducing resource consumption.

Limitations

  • No logging available for connections rejected at this stage
  • The ACL and rejection rule are always present in the HAProxy configuration, even when the blocklist is empty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-ci Allow this PR to be tested on Concourse

Projects

Development

Successfully merging this pull request may close these issues.

4 participants