Skip to content

Locking down outbound egress on PaaS containers

Your app should only call the APIs it actually needs. Here is how to enforce that at the platform edge — egress allow-lists, DNS filtering, and the failure modes when you get them wrong.

A customer’s PaaS bill shows two terabytes of outbound traffic to an IP range nobody recognized. The investigation finds a vulnerable npm package quietly exfiltrating environment variables to a server in a country the company has never done business in. The technical post-mortem is straightforward — supply-chain compromise. The harder question from the board is: why was a billing application allowed to make HTTP calls to an arbitrary internet address in the first place? Default-open egress is the most common security gap on PaaS environments, and it’s also the easiest to close once you know what your app actually talks to.

What’s happening

PaaS containers, by default, can call anything on the internet. The platform’s security model is focused on inbound — what can reach your app — and treats outbound as the application’s concern. Most apps need to reach a handful of services: a database (private network), a third-party SaaS API or two (Stripe, SendGrid, an analytics endpoint), an object storage endpoint, and the PaaS metadata service. Anything else is either a feature you forgot to inventory or a problem.

The threat model: a vulnerable dependency, a misconfigured admin panel, or a credentialed log-shipper that gets compromised should not be able to reach an attacker-controlled C2 server. If the container’s egress is filtered to your actual destinations, an exfiltration attempt fails at the network layer regardless of what the attacker has on the inside.

The cost dimension also matters. Egress traffic is the line item that surprises operators on cloud bills — and a runaway outbound process can rack up an unfortunately large bill before anyone notices. Egress controls double as a budget guard.

Three implementations, in order of preference:

  • Platform-native egress policy (where supported). Jelastic, Render, Fly, and most Kubernetes-based PaaS platforms expose either a “firewall” or NetworkPolicy primitive that takes a list of allowed destinations.
  • Application-layer egress proxy. Every outbound call goes through a configured HTTP proxy (Squid, Envoy, an in-house service) that enforces the allow-list and produces a log. Slower to set up, but works on platforms with no native control.
  • DNS-based filtering. Point the container’s resolver at an internal DNS that only resolves names in your allow-list. Easy to deploy, easy to bypass (the attacker uses an IP directly), but useful as a defense-in-depth layer.

Get egress controls wrong and the failure mode is silent: a deploy that “worked” but where one of your third-party integrations is now timing out instead of resolving. The verification step exists precisely because of this.

How to verify

Inventory what your app actually calls, before you write a single rule. Run a packet capture during a representative load period:

# From a Jelastic node with platform access, or via tcpdump in a sidecar
sudo tcpdump -i any -n -w /tmp/app-egress.pcap 'not net 10.0.0.0/8 and not net 172.16.0.0/12 and not net 192.168.0.0/16' &
TCPDUMP_PID=$!

# Run your normal traffic for an hour, then stop
sleep 3600
sudo kill ${TCPDUMP_PID}

# Pull unique destination hosts
tshark -r /tmp/app-egress.pcap -T fields -e ip.dst -e tcp.dstport \
  | sort -u

Cross-check with application logs — the HTTP client library probably already logs the hosts it dials:

# Example: Node.js app with axios logging enabled
grep -E '"(axios|http|fetch).*\bhost\b' /var/log/app/*.log \
  | jq -r '.host' | sort -u

You should end up with a short list of fully-qualified domain names. If you can’t account for one, that’s where the investigation starts.

After you apply the egress policy, verify it from inside the container:

# This SHOULD succeed (your real destination)
curl -fsS --max-time 5 https://api.stripe.com/healthcheck || echo "FAIL allowed dest"

# This SHOULD fail (a destination you did not allow)
curl -fsS --max-time 5 https://example.com/ && echo "FAIL: egress is open" || echo "OK: blocked"

The fix

The four-step rollout. Do this in staging first. Egress filtering breaks things in non-obvious ways, and “break it on staging on Tuesday” is much better than “break it on production on Friday”.

1. Write the allow-list as code, not as a dashboard click. YAML version-controlled in your IaC repo:

# egress-allowlist.yml — checked into infrastructure repo
environment: prod-app
defaultPolicy: deny
allow:
  - name: stripe-api
    fqdn: api.stripe.com
    port: 443
    protocol: tcp
    notes: "Billing — payment intents"
  - name: sendgrid-api
    fqdn: api.sendgrid.com
    port: 443
    protocol: tcp
    notes: "Transactional email"
  - name: aws-s3-bucket
    fqdn: assets-prod.s3.amazonaws.com
    port: 443
    protocol: tcp
    notes: "Static assets upload"
  - name: paas-metadata
    cidr: 169.254.0.0/16
    port: 80
    protocol: tcp
    notes: "Platform metadata — required"
  - name: dns
    cidr: 0.0.0.0/0
    port: 53
    protocol: udp
    notes: "Resolved through internal DNS"

2. Apply via the platform’s policy primitive. For Jelastic, configure firewall rules in the environment’s “Endpoints” section, or via API:

# Default-deny + per-destination allow
curl -sS -H "Authorization: Bearer ${PAAS_TOKEN}" \
  -X POST "https://app.paas.example/1.0/environment/control/rest/setfirewallrules" \
  -d "envName=prod-app&direction=OUT&defaultAction=DENY"

# Add allow rules from the YAML — pseudo-code, adapt to your platform's API
yq '.allow[]' egress-allowlist.yml -o=json | jq -c '.' | while read -r rule; do
  curl -sS -H "Authorization: Bearer ${PAAS_TOKEN}" \
    -X POST "https://app.paas.example/1.0/environment/control/rest/addfirewallrule" \
    -d "envName=prod-app&direction=OUT&action=ALLOW&payload=$(echo $rule | jq -r '.fqdn // .cidr')"
done

3. Add a per-request egress proxy as belt-and-braces. Even with a platform firewall, deploy an Envoy or Squid sidecar that enforces the same allow-list and produces a structured log:

# envoy egress proxy config — short snippet, paste into your envoy.yaml
static_resources:
  listeners:
    - name: egress
      address: { socket_address: { address: 127.0.0.1, port_value: 3128 } }
      filter_chains:
        - filters:
            - name: envoy.filters.network.http_connection_manager
              typed_config:
                "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
                stat_prefix: egress
                route_config:
                  virtual_hosts:
                    - name: allowed
                      domains:
                        - "api.stripe.com"
                        - "api.sendgrid.com"
                        - "assets-prod.s3.amazonaws.com"
                      routes:
                        - match: { prefix: "/" }
                          route: { cluster: passthrough }
                    - name: denied
                      domains: ["*"]
                      routes:
                        - match: { prefix: "/" }
                          direct_response:
                            status: 403
                            body: { inline_string: "egress denied" }

Set HTTP_PROXY=http://127.0.0.1:3128 in the application’s environment.

4. Alert on egress denials. A burst of denied egress is either a misconfiguration (an integration you forgot to allow) or an active compromise. Either way you want to hear about it:

# prometheus alert against the egress proxy's metrics
groups:
  - name: paas-egress
    rules:
      - alert: EgressDeniedBurst
        expr: increase(envoy_egress_denied_total[5m]) > 50
        for: 2m
        labels: { severity: warning }
        annotations:
          summary: "Egress denials spiking on {{ $labels.env }}"
          runbook: "https://kb.example.com/paas-sec-egress-controls/"

For a managed PaaS where egress is default-deny, allow-listed per environment, and reviewed alongside every new integration, see our Cloud PaaS — we configure egress as part of the deployment management handoff, not as an afterthought.