feat(webserver): restrict the port rule by group or sources #57
No reviewers
Labels
No labels
bug
cannot reproduce
duplicate
enhancement
help wanted
invalid
need info
need triage
need verification
not a bug
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
claudiomaradonna/castrum!57
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/webserver-restricted-sources"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
webserver's port file is the only HTTP rulefirewall-applyrenders, andit always opened
webserver_portsto every source. A host that runs aforwarder on its own network (
network_mode: host) for a cluster's reverseproxy needs that port reachable from the cluster's nodes alone: today a
tenant can either open it to everyone or leave it shut, and the proxy then
answers 504.
Closes #56
What changed
Two host variables now restrict the webserver rule.
webserver_from_groupadmits the IPv4 addresses
firewall-applyderives from that group's othermembers, as
swarm_peers_groupdoes;webserver_sourcesadmits listedaddresses or CIDRs. With either set, the chain renders
ip saddr { … } tcp dport { … }, and a group that derives nobody, with nosources, drops the rule and shuts the ports, as every restricted rule does.
With neither set, or with
webserver_sources: []and no group, the rulestays open to every source, exactly as before. That is a deliberate
exception to the empty-source rule of the other port files; the port file
computes
openitself, sofirewall-applyis unchanged.docs/ARCHITECTURE.md§ Firewall names the exception and the webserverREADME owns it.
How to verify
From a checkout prepared as CONTRIBUTING
describes, render the table from
tests/fixtures/firewall_render/loader.ymlon base
607ddc0and branch9fe0d4b, and read thewebserverchain:-e607ddc09fe0d4bwebserver_sources: [192.0.2.30],webserver_ports: [8080]tcp dport { 8080 } ct state new acceptip saddr { 192.0.2.30 } tcp dport { 8080 } ct state new acceptwebserver_from_group: all(onlyself, which is excluded)tcp dport { 80, 443 } ct state new acceptwebserver: nothing admitted for webservertcp dport { 80, 443 } ct state new acceptAll three scenarios were run as written, on both revisions.
Checks run on the branch:
make checkpasses on every commit.branch: in
check_firewall_render.sh,webserver_sourcesrestrictingthe rule and a group that derives nobody dropping it; in
check_peer_derivation.sh, a grouped webserver admitting exactly thereachable peer. That last assertion also fails when
from_group:isdeleted from the port file.
webserver_sources: []stays open passes on bothrevisions.
Not run, because podman was absent:
make test, which covers themolecule scenarios and the
tag_propagationgate. That includesfirewall-apply'sdefaultscenario, which pins the unset case withnfton a real table. Expected result: unchanged, passing.Considerations
webserver_sources, for example a templated list that comesout empty, leaves the ports open to every source rather than dropping
the rule. This matches the base's behaviour and is the agreed semantics.
restricted webserver admits no IPv6 client.
webserver_portson a host. One hostcannot serve 80/443 publicly and keep another port restricted.
README paragraph (raised in the second round).