Verdalia's passwords are stored properly, the panel requires two factors, and three fields are encrypted. All of it rests on an assumption that does not hold: that only those who should reach each service do so. The eight machines share a network on which they can all see one another on any port, the load balancer accepts administration connections from the internet, and internal traffic travels unencrypted. In this lesson you will learn how a network is protected with the classic perimeter model, why that model is not enough, and what Zero Trust proposes in its place. You will also see how the edge of the system, where internet traffic arrives, is protected. Verdalia will divide its network into three zones, close everything not explicitly allowed, and record in ADR-008 how far it goes and what it postpones.

One warning: the configurations in this lesson are didactic examples. A badly written firewall rule can leave a system exposed or unreachable. In a real system, they must be reviewed with a security professional and, when they affect personal data or payments, with legal and compliance advice (GDPR, PCI DSS).

Classic Perimeter Security

The classic model resembles a castle: a wall separates the trusted inside from the hostile outside. Its pieces are still necessary.

Piece What it is What it is for
Firewall A filter that allows or denies connections according to their source, their destination, and their port So that only the expected traffic flows
Access control list The ordered set of rules the firewall applies Expressing the network policy
Segmentation Dividing the network into subnets by function, with a filter between them So that a problem in one zone does not reach the others
Demilitarized zone, or DMZ The subnet where the services exposed to the internet are placed So that what is exposed does not share a network with what is valuable
Bastion host A minimal, closely watched machine, the only entry point for administration Reducing administration to a single door
Virtual private network, or VPN An encrypted, authenticated tunnel between a remote computer and the internal network Administering without exposing services to the internet

Two rules govern any firewall:

  • Default deny. The last rule denies everything. Only what is explicitly allowed flows. It is the fail-safe default from the first lesson, applied to the network.
  • Outbound too. Outgoing traffic is filtered just like incoming traffic. A database server has no reason to connect to the internet, and if it tries, something is wrong.

There are firewalls at two levels, which add up: the network firewall, which filters between zones, and each machine's local firewall, which filters what reaches it, including from its own zone.

Why the Perimeter Is Not Enough

The castle model has a flaw: inside the wall, everything trusts everything. A single entry point, such as a server with a vulnerability, an infected laptop, or a stolen credential, is enough to be inside. From there, the intruder moves from machine to machine until reaching what they are after. It is called lateral movement, and it is how a small intrusion becomes a serious one.

Besides, the perimeter has blurred. Users are no longer inside the office: they work from home and from their phones. Some of the services are at external providers, such as payments, email, storage, and the CDN. And incidents with an internal origin, by mistake or on purpose, are frequent.

Verdalia's data flow diagram showed it: a single inner boundary. Anyone who compromised the load balancer, which is the most exposed machine, would have Redis with no password and PostgreSQL right in front of them.

Zero Trust

Zero Trust is a model that eliminates trust based on position in the network. Being inside grants no rights.

Principle Meaning
Never trust, always verify Every request is authenticated and authorized, wherever it comes from
Least privilege Each identity accesses only what it needs, and for as long as necessary
Assume breach The design assumes the attacker is already inside: the reach is limited, traffic is encrypted, and everything is logged

Three ideas follow from that:

  • Identity is the new perimeter. What decides access is not the source IP address, but who the user or the service is, proven with strong credentials. People, with several factors; services, with certificates or tokens.
  • Microsegmentation. Instead of a few large zones, each service has its own perimeter, and only accepts connections from the specific services that need it.
  • Mutual TLS, or mTLS. In TLS, only the server presents a certificate. In mTLS, both ends do. The traffic is encrypted and each service knows for certain who is calling it. It is the robust version of the API key Verdalia adopted in the lesson on authentication.

Zero Trust is not a product and does not replace segmentation: it is a direction. It is adopted by degrees, and each degree has a cost. mTLS requires issuing, distributing, and renewing a certificate per service; doing it by hand on nine machines is a sure source of outages from expired certificates.

Protecting the Edge

The edge is the point where the system receives internet traffic. In Verdalia, the load balancers.

Measure What it does Limitation
Web application firewall, or WAF Inspects HTTP requests and blocks those that follow known attack patterns Does not fix the application; produces false positives and requires tuning
Denial-of-service protection Absorbs or discards traffic floods before they reach the system High-volume floods can only be stopped by the network provider or a CDN
Rate limiting Sets a maximum per client and period An attack from many addresses partly evades it
Security headers Tell the browser how to protect the user Depend on the browser honoring them
API gateway Single entry point to the APIs: authenticates, limits, and logs One more piece to operate. Verdalia still does not need it, with a single internal service

Security Headers

Header What it tells the browser
Strict-Transport-Security To always use HTTPS with this domain
Content-Security-Policy From which origins it may load code, images, and styles
X-Content-Type-Options: nosniff Not to guess the type of a file
X-Frame-Options, or frame-ancestors in the content policy Not to show the page embedded in another site
Referrer-Policy How much information about the current address it sends when following a link

TLS Termination and Internal Traffic

In Module 4 we left a question open. The load balancer terminates TLS and forwards the requests to the servers unencrypted. Is that acceptable?

Option Advantage Drawback
Terminate at the load balancer and continue in the clear Simple and fast Passwords and personal data travel readable over the internal network
Re-encrypt toward the servers Traffic is encrypted end to end; the load balancer can still inspect it Internal certificates to issue and renew; some latency
mTLS between all services Encryption and mutual authentication The highest operating cost

The answer depends on the data. The traffic between the load balancer and the store carries the customers' passwords on login. Under the assume-breach principle, it must be encrypted.

The X-Forwarded-For Header

The store needs the customer's IP address to limit login attempts and for auditing. Since the connection reaches it from the load balancer, it reads it from the X-Forwarded-For header. But a header is data the client sends, and the client can make it up. There are two measures, applied together:

  • The load balancer overwrites the header with the address of the real connection, instead of appending to whatever the request brings.
  • The store only honors the header when the connection comes from a load balancer:
LOAD_BALANCERS = {"10.0.0.11", "10.0.0.12"}


def client_ip(connection_ip, headers):
    """The header only counts if the request comes from a load balancer."""
    if connection_ip in LOAD_BALANCERS:
        return headers.get("X-Forwarded-For", connection_ip)
    return connection_ip


print(client_ip("10.0.0.11", {"X-Forwarded-For": "198.51.100.7"}))
print(client_ip("10.0.1.13", {"X-Forwarded-For": "127.0.0.1"}))

Output:

198.51.100.7
10.0.1.13

The second request comes from another machine on the internal network and claims to come from 127.0.0.1. The function ignores the header and records the real address.

Verdalia: Three Zones

The Design

flowchart TB
    internet["Internet"]
    team["Verdalia team"]
    subgraph public_zone["Public zone, 10.0.0.0/24"]
        lb["verdalia-lb-01 and verdalia-lb-02"]
        bastion["verdalia-bastion-01"]
    end
    subgraph app_zone["Application zone, 10.0.1.0/24"]
        app["verdalia-app-01, 02, and 03"]
    end
    subgraph data_zone["Data zone, 10.0.2.0/24"]
        db1[("verdalia-db-01")]
        db2[("verdalia-db-02")]
        aux["verdalia-aux-01"]
    end
    internet -->|"443"| lb
    team -->|"VPN"| bastion
    bastion -->|"8443, panel"| lb
    bastion -.->|"22"| app
    bastion -.->|"22"| aux
    lb -->|"8000, with TLS"| app
    app -->|"5432, with TLS"| db1
    app -->|"5432, with TLS"| db2
    db1 -->|"Replication"| db2
    app -->|"6379, 5672, and 5001"| aux
    app -->|"443"| payment["PagoRaíz"]
    aux -->|"587"| mail["Email provider"]
Zone Range Machines Addresses
Public 10.0.0.0/24 Load balancers, with the floating IP; bastion 10.0.0.11 and 10.0.0.12, floating 10.0.0.10; 10.0.0.21
Application 10.0.1.0/24 verdalia-app-01, -02, and -03 10.0.1.11 to 10.0.1.13, unchanged
Data 10.0.2.0/24 verdalia-db-01, verdalia-db-02, verdalia-aux-01 10.0.2.11, 10.0.2.12, and 10.0.2.21
VPN 10.0.9.0/24 The staff's computers, while they are connected Assigned by the bastion

The provider translates Verdalia's two public addresses, the store's and the bastion's, to their internal addresses. No other machine is reachable from the internet.

The Rules

No. Source Destination Port Action Reason
1 Internet Floating IP of the load balancers 443, and 80 to redirect Allow The store
2 Internet Bastion 51820, UDP Allow VPN
3 Load balancers Application zone 8000 Allow Store traffic
4 Application zone verdalia-db-01 and verdalia-db-02 5432 Allow PostgreSQL
5 verdalia-db-02 verdalia-db-01 5432 Allow Replication
6 Application zone verdalia-aux-01 6379, 5672, and 5001 Allow Redis, RabbitMQ, and notifications
7 VPN Bastion 22 Allow Administration
8 VPN Floating IP of the load balancers 8443 Allow Admin panel
9 Bastion The three zones 22 Allow SSH to each machine
10 Application zone PagoRaíz and object storage 443 Allow Outbound to external services
11 verdalia-aux-01 Email provider 587 Allow Sending email
12 Any Any Any Deny By default

What the rules do not allow is as important as what they allow. The load balancers do not reach the data zone. The notification-service does not reach PostgreSQL, as its design has required since Module 3. Nobody reaches Redis from the VPN. And a compromised machine cannot send data to just any server on the internet.

The Other Measures

  • Redis and RabbitMQ require credentials. Each has its own users: the store publishes to RabbitMQ and the notification-service consumes, with different permissions. The factory user is removed. The passwords are in the variables VERDALIA_REDIS_PASSWORD and VERDALIA_RABBITMQ_PASSWORD.
  • The panel is no longer on the internet. The /admin route responds 404 on the public address. The panel is served on port 8443, which only the VPN reaches. Customer support and warehouse staff connect the VPN before logging in.
  • SSH only from the bastion. Each person logs in with their own account and key; passwords are disabled, and there is no direct access as administrator. The bastion logs who logs in, when, and to which machine.
  • The bastion is a new machine, verdalia-bastion-01, size S at €30 a month. It hosts the VPN, with WireGuard, and nothing else.

The Nginx Configuration

# /etc/nginx/conf.d/verdalia.conf, on the load balancers (excerpt)

limit_req_zone $binary_remote_addr zone=general:10m rate=10r/s;
limit_req_zone $binary_remote_addr zone=search:10m  rate=2r/s;
limit_req_zone $binary_remote_addr zone=login:10m   rate=20r/m;
limit_req_status 429;
server_tokens off;

server {
    listen 443 ssl;
    server_name www.verdalia.example;

    ssl_certificate     /etc/nginx/certs/verdalia.crt;
    ssl_certificate_key /etc/nginx/certs/verdalia.key;
    ssl_protocols       TLSv1.2 TLSv1.3;
    ssl_session_cache   shared:TLS:10m;
    ssl_session_timeout 1d;
    ssl_session_tickets off;

    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header Referrer-Policy "strict-origin-when-cross-origin" always;
    add_header Content-Security-Policy "default-src 'self'; img-src 'self' https:; frame-ancestors 'none'" always;

    client_max_body_size 1m;

    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_ssl_verify on;
    proxy_ssl_trusted_certificate /etc/nginx/certs/internal-ca.crt;
    proxy_ssl_name store.verdalia.internal;

    location /admin           { return 404; }
    location = /account/login { limit_req zone=login   burst=5  nodelay; proxy_pass https://store; }
    location /search          { limit_req zone=search  burst=5  nodelay; proxy_pass https://store; }
    location /                { limit_req zone=general burst=20 nodelay; proxy_pass https://store; }
}

server {
    listen 8443 ssl;                      # panel: reachable only from the VPN
    server_name panel.verdalia.internal;
    allow 10.0.9.0/24;
    deny all;
    # certificates, headers, and proxy_pass, as in the previous block
}

Explanation, block by block:

Directive What it does
limit_req_zone Defines a limiter. $binary_remote_addr creates one bucket per IP address; 10m is the reserved memory; rate is the sustained rate
limit_req ... burst=5 nodelay Applies the limiter to a route. burst is the tolerated burst, the capacity of the TokenBucket from Module 4
limit_req_status 429 Responds 429 to rejected requests
server_tokens off Does not announce the Nginx version
ssl_protocols Accepts only TLS 1.2 and 1.3
ssl_session_tickets off Avoids a session resumption mechanism that weakens the encryption if its keys are not rotated
add_header ... always Sends the security headers on error responses too
client_max_body_size Rejects request bodies over 1 MB
X-Forwarded-For $remote_addr Overwrites the header. In Module 4, $proxy_add_x_forwarded_for was used, which keeps whatever the client sends
proxy_pass https://store Re-encrypts toward the application servers
proxy_ssl_verify and proxy_ssl_trusted_certificate Verify the server's certificate against Verdalia's internal certificate authority. Without them, the traffic would be encrypted, but toward anyone
allow and deny Second barrier for the panel, in addition to firewall rule 8

The limit of 20 logins per minute and address is the one we set in the lesson on authentication. The one of 2 searches per second comes from Module 4. The content policy in the example is a starting point: a real policy is tuned page by page and tested first in report-only mode.

A Rule Validator in Python

A table of rules is a program, and it deserves tests. This validator answers two questions: what happens to a specific connection, and which rules are too broad.

import ipaddress
from dataclasses import dataclass

ZONES = {
    "public": ipaddress.ip_network("10.0.0.0/24"),
    "application": ipaddress.ip_network("10.0.1.0/24"),
    "data": ipaddress.ip_network("10.0.2.0/24"),
    "vpn": ipaddress.ip_network("10.0.9.0/24"),
}
INTERNET = ipaddress.ip_network("0.0.0.0/0")


@dataclass(frozen=True)
class Rule:
    source: str
    target: str
    port: int              # 0 means any port
    action: str            # "allow" or "deny"
    reason: str

    def matches(self, source, target, port):
        return (ipaddress.ip_address(source) in ipaddress.ip_network(self.source)
                and ipaddress.ip_address(target) in ipaddress.ip_network(self.target)
                and self.port in (0, port))


def decide(rules, source, target, port):
    """The first matching rule applies. If none matches, the connection is denied."""
    for rule in rules:
        if rule.matches(source, target, port):
            return rule.action, rule.reason
    return "deny", "default deny"


def warnings(rules):
    """Allow rules that are too broad."""
    for rule in rules:
        if rule.action != "allow":
            continue
        source = ipaddress.ip_network(rule.source)
        target = ipaddress.ip_network(rule.target)
        if rule.port == 0:
            yield rule, "allows all ports"
        if source == INTERNET and not target.subnet_of(ZONES["public"]):
            yield rule, "opens a non-public zone to the internet"
        if not any(source == INTERNET or source.subnet_of(zone) for zone in ZONES.values()):
            yield rule, "the source spans more than one zone"


BEFORE = [
    Rule("0.0.0.0/0", "10.0.1.1/32", 443, "allow", "store"),
    Rule("0.0.0.0/0", "10.0.1.1/32", 22, "allow", "administration"),
    Rule("10.0.0.0/8", "10.0.0.0/8", 0, "allow", "internal network"),
]
NOW = [
    Rule("0.0.0.0/0", "10.0.0.10/32", 443, "allow", "store, via the floating IP"),
    Rule("0.0.0.0/0", "10.0.0.21/32", 51820, "allow", "VPN, on the bastion"),
    Rule("10.0.0.11/32", "10.0.1.0/24", 8000, "allow", "load balancer to store"),
    Rule("10.0.0.12/32", "10.0.1.0/24", 8000, "allow", "load balancer to store"),
    Rule("10.0.1.0/24", "10.0.2.11/32", 5432, "allow", "store to PostgreSQL primary"),
    Rule("10.0.1.0/24", "10.0.2.12/32", 5432, "allow", "store to PostgreSQL replica"),
    Rule("10.0.2.12/32", "10.0.2.11/32", 5432, "allow", "replication"),
    Rule("10.0.1.0/24", "10.0.2.21/32", 6379, "allow", "store to Redis"),
    Rule("10.0.1.0/24", "10.0.2.21/32", 5672, "allow", "store to RabbitMQ"),
    Rule("10.0.1.0/24", "10.0.2.21/32", 5001, "allow", "store to notifications"),
    Rule("10.0.9.0/24", "10.0.0.21/32", 22, "allow", "VPN to bastion"),
    Rule("10.0.9.0/24", "10.0.0.10/32", 8443, "allow", "VPN to panel"),
    Rule("10.0.0.21/32", "10.0.0.0/22", 22, "allow", "bastion to the three zones"),
    Rule("10.0.1.0/24", "192.0.2.50/32", 443, "allow", "store to PagoRaiz"),
    Rule("10.0.2.21/32", "192.0.2.80/32", 587, "allow", "notifications to email provider"),
]
CONNECTIONS = [
    ("Customer to the store", "198.51.100.7", "10.0.0.10", 443),
    ("Internet to PostgreSQL", "198.51.100.7", "10.0.2.11", 5432),
    ("Internet to load balancer SSH", "198.51.100.7", "10.0.0.11", 22),
    ("Load balancer to app-02", "10.0.0.11", "10.0.1.12", 8000),
    ("Load balancer to Redis", "10.0.0.11", "10.0.2.21", 6379),
    ("app-04, new, to PostgreSQL", "10.0.1.14", "10.0.2.11", 5432),
    ("Notifications to PostgreSQL", "10.0.2.21", "10.0.2.11", 5432),
    ("Laptop via VPN to Redis", "10.0.9.5", "10.0.2.21", 6379),
    ("Bastion to db-01 SSH", "10.0.0.21", "10.0.2.11", 22),
    ("app-01 to PagoRaiz", "10.0.1.11", "192.0.2.50", 443),
    ("app-01 to an unknown server", "10.0.1.11", "198.51.100.99", 443),
]

for name, rules in (("BEFORE", BEFORE), ("NOW", NOW)):
    print(f"{name}: {len(rules)} rules")
    for rule, warning in warnings(rules):
        print(f"  WARNING {rule.source} -> {rule.target}:{rule.port or '*'} {warning}")

print()
for description, source, target, port in CONNECTIONS:
    action, reason = decide(NOW, source, target, port)
    print(f"{description:34} {action:9} {reason}")

Output:

BEFORE: 3 rules
  WARNING 0.0.0.0/0 -> 10.0.1.1/32:443 opens a non-public zone to the internet
  WARNING 0.0.0.0/0 -> 10.0.1.1/32:22 opens a non-public zone to the internet
  WARNING 10.0.0.0/8 -> 10.0.0.0/8:* allows all ports
  WARNING 10.0.0.0/8 -> 10.0.0.0/8:* the source spans more than one zone
NOW: 15 rules

Customer to the store              allow     store, via the floating IP
Internet to PostgreSQL             deny      default deny
Internet to load balancer SSH      deny      default deny
Load balancer to app-02            allow     load balancer to store
Load balancer to Redis             deny      default deny
app-04, new, to PostgreSQL         allow     store to PostgreSQL primary
Notifications to PostgreSQL        deny      default deny
Laptop via VPN to Redis            deny      default deny
Bastion to db-01 SSH               allow     bastion to the three zones
app-01 to PagoRaiz                 allow     store to PagoRaiz
app-01 to an unknown server        deny      default deny

Explanation:

  • The ipaddress module, from the standard library, understands addresses and networks. 10.0.1.0/24 is the network of the 256 addresses that start with 10.0.1; /32 is a single address; 0.0.0.0/0 is all of them.
  • matches checks the three conditions of a rule. decide walks the list in order and returns the first one that matches. If none does, it denies: rule 12 of the table does not need to be written.
  • warnings looks for three defects: rules that allow all ports, rules that open to the internet something that is not in the public zone, and rules whose source does not fit within one zone. yield hands out the warnings one at a time.
  • The three rules from March produce four warnings. The first two were correct in their intent, but the load balancer, open to the internet, lived on the same network as the database. The third is the flat network.
  • The 15 rules from April are the 11 in the table, broken down by port and by machine. For simplicity, the model does not distinguish TCP from UDP.
  • The connection from app-04 is allowed even though that machine does not exist yet: the rules refer to the zone, not to each server. Adding a fourth server will not require touching the firewall.

The eleven connections are tests. Kept in the repository, they run every time someone changes a rule.

ADR-008

ADR-008: Divide the network into three zones with default deny, administer through a bastion host with VPN, and adopt Zero Trust partially

Status: Accepted

Date: 2027-04-07

Participants: Marta decides; Íker and Lucía consulted; Andrés informed, and he approves the expense and accepts the residual risks.

Context

The eight machines share an internal network on which they can all reach one another on any port. The load balancer accepts SSH from the internet with a shared account. Redis asks for no password, the panel is reachable from the internet, and internal traffic travels unencrypted. The risk register lists threats TH-03, TH-05, TH-06, and TH-10. The team is three people, the infrastructure is administered by hand, and the campaign is under way.

Options considered

  • A. Keep the single network and add passwords to the services. Minimal cost. Does not limit lateral movement or solve administration.
  • B. Three zones with default deny, bastion host with VPN, credentials on every internal service, and encryption of the internal traffic that carries passwords and personal data in volume.
  • C. Full Zero Trust: mTLS between all services, per-service microsegmentation, and verification of every device. The greatest protection. Requires a certificate authority with automatic renewal and tools the team cannot operate by hand.

Decision

We adopt option B. The network is divided into the public, application, and data zones. Every internal service requires credentials. The traffic between the load balancers and the store, and between the store and PostgreSQL, including replication, is encrypted with TLS. Administration goes through verdalia-bastion-01, with VPN and personal accounts. The panel is served only from the VPN.

Consequences

Positive:

  • From the internet, only two services are reachable: the store and the VPN.
  • Compromising a load balancer no longer gives access to the data.
  • Every administration access is tied to a person.

Negative:

  • €30 more a month, and a ninth machine to maintain.
  • Customer support and warehouse staff must connect the VPN to work.
  • The internal certificates, valid for one year, are issued and renewed by hand.
  • The catalog's 95th percentile rises from 560 to 590 ms with 1,000 users, because of the internal encryption, according to the April 6 load test.

Accepted risks and postponed measures:

  • The traffic to Redis and RabbitMQ is still unencrypted, inside the segmented network. In testing, encrypting Redis raised the 95th percentile to 640 ms.
  • There is no mTLS: the store identifies itself to the notification-service with an API key.
  • verdalia-aux-01 hosts three services, and the notification-service lives in the data zone. Separating them requires another machine.
  • There is no web application firewall or intrusion detection.
  • The bastion is a single point of failure for administration, not for the store.

Review conditions

It will be reviewed when the store moves to a cloud platform, where segmentation, certificates, and encryption can be managed services; if a second independent service is added; and after any security incident.

The Rollout

Date Change
Tuesday, April 13 Bastion and VPN in service. SSH closed to the internet. Personal accounts; the shared account is removed. Credentials on Redis and RabbitMQ
Tuesday, April 20 Three zones with default deny. Panel only through the VPN. Headers and limits in Nginx
Tuesday, April 27 TLS between the load balancers and the store, and between the store and PostgreSQL

Lucía avoided downtime with a gradual method: she added the new networks to each machine as a second connection, moved the services one by one, and removed the old network a week later.

There was one incident. On the 20th, when default deny was enabled, the notification-service could no longer send emails: nobody had written down that it talked to the provider on port 587, and rule 11 did not exist. Lucía saw it at 9:40 a.m., while reviewing the queues, with 212 messages waiting in emails.confirmation. She added the rule and the emails went out 50 minutes late. None was lost, thanks to the queue from ADR-004. Default deny has that effect: it brings to light the connections nobody had documented. It is best to enable it first in logging mode, recording what would be denied without denying it yet.

Common Mistakes and Tips

  • Trusting the internal network. It is the assumption that turns a minor intrusion into a serious one.
  • Leaving “temporary” rules. A broad rule added for a test is still there two years later. Every rule carries a reason, an author, and a review date.
  • Filtering only inbound traffic. Outbound is the path the data leaves by.
  • Encrypting without verifying the certificate. It protects against whoever listens, not against whoever impersonates.
  • Treating the WAF as a substitute for fixing the application. It is one more layer, not the first.
  • Setting the headers in one block and redefining them in another. In Nginx, an add_header inside a location overrides the inherited ones. The real responses must be checked.
  • Buying Zero Trust. It is a way of designing, not a product.
  • Practical tip. Before enabling default deny, log every connection for a week. The resulting list is your first table of rules.

Exercises

Exercise 1: A New Rule

Andrés hires an external sales analytics tool, which needs to read the orders. The vendor asks to “open port 5432 of the database to our addresses.” Explain which principles the request violates and propose an alternative.

Exercise 2: Test the Validator

Íker, to debug a problem, adds the rule Rule("10.0.0.0/16", "10.0.2.0/24", 0, "allow", "test") at the beginning of NOW. State which warnings the validator produces and how the results of the eleven connections change.

Solutions

Solution to Exercise 1

It would open the data zone to the internet, against the zone design; it would give access to the entire database, against least privilege; it would trust an IP address as an identity, against Zero Trust; and it would send personal data to a third party, which requires a contract and a compliance review. Alternatives, from most to least recommended:

  • Have the store generate a file every night with aggregated, pseudonymized data, and send it to the vendor. Verdalia initiates the connection, outbound, and the data is the minimum.
  • A read-only API, with authentication, that exposes only the necessary data.

In no case should PostgreSQL be exposed. Common mistake: accepting the request because “it is only open to their addresses.”

Solution to Exercise 2

The validator produces two warnings: the rule allows all ports, and its source, 10.0.0.0/16, spans more than one zone. Since the rule is at the beginning, it applies before the others. Three results change, from deny to allow: “Load balancer to Redis,” “Notifications to PostgreSQL,” and “Laptop via VPN to Redis.” Three others remain allowed, but now by the test rule and not by their own. The connections from the internet remain denied, because 198.51.100.7 does not belong to the source. A single rule undoes the whole segmentation. That is why the warnings must block the change, and not just report it.

Conclusion

In this lesson you have learned the pieces of perimeter security: firewall, segmentation, demilitarized zone, bastion host, and VPN, with default deny as the basic rule. You have seen why the perimeter is not enough: whoever gets in moves around inside unobstructed. You have met the principles of Zero Trust, which replaces trust in the network with the verification of every identity, and you have learned that it is adopted by degrees. And you have gone over the protection of the edge: rate limiting, security headers, encryption of internal traffic, and an X-Forwarded-For header that is trusted only when it comes from the load balancer.

In Verdalia, the network has three zones and twelve rules, from the internet only the store and the VPN are reachable, the panel is behind the VPN, and Redis asks for a password. ADR-008 puts in writing what is postponed: mTLS, encryption toward Redis and RabbitMQ, and the separation of the services on verdalia-aux-01. The cost rises to €469 a month during the campaign, with nine machines.

We have devoted five lessons to keeping things from going wrong. The opposite question remains: what happens when, despite everything, they do. An accidental deletion, a disk that fails, a deployment that corrupts a table. Since Module 1, Verdalia has made a copy of its database every night that nobody has ever restored. It is time to test it, in the next lesson: “Backups and Disaster Recovery.”

© Copyright 2026. All rights reserved