diff --git a/.bake.toml b/.bake.toml new file mode 100644 index 0000000000..2adc00dfd2 --- /dev/null +++ b/.bake.toml @@ -0,0 +1,2 @@ +[formatter] +ensure_final_newline = true diff --git a/.github/workflows/call-validation.yml b/.github/workflows/call-validation.yml index 05e395339b..79155629e2 100644 --- a/.github/workflows/call-validation.yml +++ b/.github/workflows/call-validation.yml @@ -109,12 +109,13 @@ jobs: PR_SCOPE: ${{ inputs.pr_scope }} run: ./scripts/meta/resolve/pr/branch_prefix.sh - - name: πŸ”€ Assert the base branch is fully merged into the PR head + - name: πŸ”€ Assert the event's base commit is merged into the PR head if: ${{ github.event_name == 'pull_request' && inputs.pr_scope != '' }} working-directory: pr-head env: INFINITO_MAIN_REMOTE: origin INFINITO_MAIN_BRANCH: ${{ github.event.pull_request.base.ref }} + INFINITO_MAIN_COMMIT: ${{ github.event.pull_request.base.sha }} run: bash "${GITHUB_WORKSPACE}/.base-tooling/scripts/git/assert/main_merged.sh" - name: πŸ”§ Set up Python diff --git a/TODO.md b/TODO.md index e5edb52ecf..273e3021a6 100644 --- a/TODO.md +++ b/TODO.md @@ -4,7 +4,7 @@ - Implement rbac administration interface - Enable IP6 for docker. - backup docker to local fΓΌr ca optimieren -- Drop `memory_limit = -1` from [hardening.ini](roles/sys-svc-compose-php/files/hardening.ini) once every PHP image ships PHP 8.2.35, 8.3.36, 8.4.27, 8.5.12 or later. It is the interim mitigation for CVE-2026-109618 and overrides the per-role `service_memory_mb` share, so a single request can exhaust the container instead of hitting a PHP limit. `web-app-joomla` keeps its own `memory_limit` because its media API compares uploads against it, and `web-app-magento` keeps the 756M its `nginx.conf.sample` (`PHP_VALUE`) and `pub/.user.ini` set; both keep `post_max_size` below a quarter of that limit. While the override is in place, `web-app-nextcloud` (`upload_limit` 5G at 3g) accepts POST bodies above a quarter of its container memory, `web-app-friendica` caps account imports at 64 MiB instead of half the memory limit, EspoCRM's System Requirements page flags `memory_limit` as failed, and Pixelfed (`InstanceService`), phpMyAdmin (import and export) and Snipe-IT (imports and LDAP sync) set a finite limit again via `ini_set` after the request has started. +- Drop the `php_memory_unlimited` mount ([memory-unlimited.ini](roles/sys-svc-compose-php/files/memory-unlimited.ini), `memory_limit = -1`) from each role whose image ships PHP 8.2.35, 8.3.36, 8.4.27, 8.5.12 or later, and the file, its install task and `FILE_PHP_MEMORY_UNLIMITED_INI` once no role mounts it. It is the interim mitigation for CVE-2026-109618 and overrides the per-role `service_memory_mb` share, so a single request can exhaust the container instead of hitting a PHP limit. Still mounted by `web-app-magento` (`markoshust/magento-php:8.4-fpm`, PHP 8.4.21), `web-app-mailu` (`ghcr.io/heviat/webmail:2024.06`, the OIDC flavor, built 2025-04-04), `web-app-phpldapadmin` (`phpldapadmin/phpldapadmin:2.3.11`, built 2026-05-15) and `web-app-shopware` (`ghcr.io/shopware/docker-base:8.3`, PHP 8.3.25). `web-app-magento` keeps the 756M its `nginx.conf.sample` (`PHP_VALUE`) and `pub/.user.ini` set and keeps `post_max_size` below a quarter of that limit. - Fork [rpardini/docker-registry-proxy](https://github.com/rpardini/docker-registry-proxy) and teach the bundled nginx to handle GCP Artifact Registry redirect URLs (`/artifacts-downloads/namespaces//repositories//downloads/`). Currently `gcr.io` blob pulls are bypassed via `NO_PROXY=…,gcr.io,storage.googleapis.com,googleusercontent.com` in [compose/registry-cache/proxy.conf](compose/registry-cache/proxy.conf), which is a workaround that disables caching for those registries. Long-term: rebase upstream's `proxy.conf` / `sub_filter` rules to recognise the new redirect shape, ship the fix in our fork, point `compose/registry-cache/Dockerfile` (or its image tag) at the fork, and drop the `NO_PROXY` bypass. ## Testing diff --git a/group_vars/all/04_webserver.yml b/group_vars/all/04_webserver.yml index b0af51f9eb..5168689cb9 100644 --- a/group_vars/all/04_webserver.yml +++ b/group_vars/all/04_webserver.yml @@ -24,3 +24,13 @@ WEBSERVER_WORKER_CONNECTIONS: >- (lookup('applications') | resource_filter(application_id, 'pids_limit', service_name | default(''), RESOURCE_PIDS_LIMIT)) | int ] | min }} + +# Response security headers of every vhost; an app overrides any key under `security_headers` in its meta/server.yml. +WEBSERVER_SECURITY_HEADERS: + nosniff: false # X-Content-Type-Options: nosniff + referrer_policy: "" # Referrer-Policy, sent only when the upstream sends none; "" sends none + permissions_policy: "" # Permissions-Policy on HTML documents; "" sends none + hsts: + max_age: 31536000 # Strict-Transport-Security max-age in seconds + include_subdomains: false # adds includeSubDomains, which covers every subdomain of the vhost + preload: false # adds preload; requires include_subdomains and a max_age of one year diff --git a/group_vars/all/05_paths.yml b/group_vars/all/05_paths.yml index 9683796ccf..50b755f85e 100644 --- a/group_vars/all/05_paths.yml +++ b/group_vars/all/05_paths.yml @@ -31,8 +31,10 @@ DIR_METRICS_TEXTFILE: "{{ [DIR_VAR_LIB, 'metrics'] | path_join }}" DIR_PHP_HARDENING: "/etc/{{ SOFTWARE_DOMAIN }}/php" PHP_HARDENING_INI_DIGEST: "{{ (lookup('file', lookup('path_absolute', 'roles/sys-svc-compose-php/files/hardening.ini')) | hash('sha1'))[:8] }}" +PHP_MEMORY_UNLIMITED_INI_DIGEST: "{{ (lookup('file', lookup('path_absolute', 'roles/sys-svc-compose-php/files/memory-unlimited.ini')) | hash('sha1'))[:8] }}" PHP_FPM_HARDENING_CONF_DIGEST: "{{ (lookup('template', lookup('path_absolute', 'roles/sys-svc-compose-php/templates/fpm-hardening.conf.j2')) | hash('sha1'))[:8] }}" FILE_PHP_HARDENING_INI: "{{ [DIR_PHP_HARDENING, 'hardening-' ~ PHP_HARDENING_INI_DIGEST ~ '.ini'] | path_join }}" +FILE_PHP_MEMORY_UNLIMITED_INI: "{{ [DIR_PHP_HARDENING, 'memory-unlimited-' ~ PHP_MEMORY_UNLIMITED_INI_DIGEST ~ '.ini'] | path_join }}" FILE_PHP_FPM_HARDENING_CONF: "{{ [DIR_PHP_HARDENING, 'fpm-hardening-' ~ PHP_FPM_HARDENING_CONF_DIGEST ~ '.conf'] | path_join }}" DIR_RESCUE_DIAGNOSTICS: "/tmp/infinito-rescue-diagnostics" diff --git a/plugins/filter/README.md b/plugins/filter/README.md index 7312a1d39a..ccea48bcfe 100644 --- a/plugins/filter/README.md +++ b/plugins/filter/README.md @@ -33,13 +33,14 @@ flowchart TD grant["csp_filters.py:354
logout grant"] wl["csp_filters.py:123
get_csp_whitelist"] inj["sys-front-inj-dashboard,
-javascript, -matomo, -logout
add_csp_hash"] - gate["csp_filters.py:365
hash gate"] + gate["csp_filters.py:366
hash gate"] build["csp_filters.py:203
build_csp_header"] header["set $csp
nginx vhost"] decl -->|"1. flags read by"| flags flags -->|"2. tokens"| build svc -->|"3. read by"| grant + decl -->|"3a. unsafe-inline: false
on -elem or -attr vetoes"| grant grant -->|"4. adds 'unsafe-inline'
to script-src-elem and -attr"| build decl -->|"5. whitelist read by"| wl wl -->|"6. tokens"| build @@ -52,7 +53,7 @@ flowchart TD grant -.->|"TRIP-WIRE: absent from the
smart-defaults docstring, which
names logout only for frame-ancestors"| build ``` -Styles carry `'unsafe-inline'` by default; scripts do not. The logout grant is the only path that puts it into a script directive. +Styles carry `'unsafe-inline'` by default; scripts do not. The logout grant is the only implicit path that puts it into a script directive. An application keeps it out of `script-src-elem` or `script-src-attr` by setting `unsafe-inline: false` on that directive in its `meta/csp.yml`. ## Further Reading diff --git a/plugins/filter/csp_filters.py b/plugins/filter/csp_filters.py index 3ff788bb42..aa1111722d 100644 --- a/plugins/filter/csp_filters.py +++ b/plugins/filter/csp_filters.py @@ -351,10 +351,11 @@ class FilterModule: ) ) - if directive in ( - "script-src-attr", - "script-src-elem", - ) and self.is_feature_enabled(applications, "logout", application_id): + if ( + directive in ("script-src-attr", "script-src-elem") + and self.is_feature_enabled(applications, "logout", application_id) + and explicit_flags.get("unsafe-inline") is not False + ): tokens.append("'unsafe-inline'") tokens += self.get_csp_whitelist( diff --git a/plugins/filter/security_headers.py b/plugins/filter/security_headers.py new file mode 100644 index 0000000000..78af696964 --- /dev/null +++ b/plugins/filter/security_headers.py @@ -0,0 +1,10 @@ +"""Expose the response security headers of one application to templates.""" + +from __future__ import annotations + +from utils.roles.applications.security_headers import security_headers + + +class FilterModule: + def filters(self): + return {"security_headers": security_headers} diff --git a/pyproject.toml b/pyproject.toml index 506f1e25d2..16e198c3b2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,7 +33,7 @@ deploy = [ "requests", ] dev = [ - "ruff==0.17.2", + "ruff==0.17.3", "import-linter", "pre-commit", "git-maintainer-tools", diff --git a/roles/pkgmgr/meta/services.yml b/roles/pkgmgr/meta/services.yml index 079f44d0e8..ea3a8c7739 100644 --- a/roles/pkgmgr/meta/services.yml +++ b/roles/pkgmgr/meta/services.yml @@ -3,4 +3,4 @@ pkgmgr: lifecycle: beta repository: https://github.com/kevinveenbirkenbach/package-manager.git - ref: v2.0.4 + ref: v2.0.5 diff --git a/roles/svc-ai-ollama/meta/services.yml b/roles/svc-ai-ollama/meta/services.yml index 1c39365e90..2089464ef3 100644 --- a/roles/svc-ai-ollama/meta/services.yml +++ b/roles/svc-ai-ollama/meta/services.yml @@ -13,7 +13,7 @@ ollama: backup: no_stop_required: true image: ollama/ollama - version: 0.40.12 + version: 0.40.13 name: ollama min_storage: 3473MB cpus: "4.0" diff --git a/roles/svc-net-tor/files/test/onion_ports.py b/roles/svc-net-tor/files/test/onion_ports.py index adb6a81c66..7b06449a63 100755 --- a/roles/svc-net-tor/files/test/onion_ports.py +++ b/roles/svc-net-tor/files/test/onion_ports.py @@ -25,12 +25,13 @@ Env (rendered into test.env from templates/test.env.j2): ONION_HOST the node onion host ONION_PORTS space-separated forwarded ports; empty means there is nothing to check - ONION_PORT_TIMEOUT seconds per connect attempt. 60 for the same reason the - domain probe uses it: Tor's SocksTimeout default is 120s - and abandoning earlier is destructive, because the next - attempt opens a fresh SOCKS connection and throws away - the descriptor fetches and rendezvous retries the last - one was still working through + ONION_PORT_TIMEOUT seconds per connect attempt, above Tor's SocksTimeout + (120s by default; torrc does not set it). Every attempt + builds a fresh rendezvous, which Tor keeps working on + until SocksTimeout and then ends itself with reply 0x06 + and a "Giving up" notice in its log. An attempt abandoned + earlier throws away a rendezvous Tor may still complete + and leaves Tor's log without a trace of the failure ONION_PORT_RETRIES passes over the failing ports. Below the domain probe's RETRIES because this phase multiplies by the port count, and meta/tests.yml caps the whole CLI test @@ -148,7 +149,7 @@ def main() -> int: retries = int(_required("ONION_PORT_RETRIES", "passes over the failing ports")) sleep_seconds = float(_required("SLEEP_SECONDS", "wait between passes")) timeout = float( - _required("ONION_PORT_TIMEOUT", "seconds per connect, flavor-dependent") + _required("ONION_PORT_TIMEOUT", "seconds per connect, above Tor's SocksTimeout") ) ports = [int(entry) for entry in os.environ.get("ONION_PORTS", "").split()] diff --git a/roles/svc-net-tor/meta/tests.yml b/roles/svc-net-tor/meta/tests.yml index 272c1e148d..036f2dec6c 100644 --- a/roles/svc-net-tor/meta/tests.yml +++ b/roles/svc-net-tor/meta/tests.yml @@ -1,3 +1,3 @@ --- cli: - timeout: 7200 + timeout: 9000 diff --git a/roles/svc-net-tor/templates/test.env.j2 b/roles/svc-net-tor/templates/test.env.j2 index 51288356b2..0788bce017 100644 --- a/roles/svc-net-tor/templates/test.env.j2 +++ b/roles/svc-net-tor/templates/test.env.j2 @@ -2,7 +2,7 @@ NGINX_SERVERS_DIR={{ lookup('nginx', 'directories.configuration.servers') }} ONION_HOST={{ lookup('config', 'svc-net-tor', 'services.tor.node') }} ONION_PORTS={{ lookup('tor_ports') | map(attribute='onion_port') | unique | sort | join(' ') | dotenv_quote }} ONION_PORT_RETRIES=2 -ONION_PORT_TIMEOUT=60 +ONION_PORT_TIMEOUT=130 RETRIES=5 SLEEP_SECONDS=10 TOR_CONTAINER={{ lookup('container_address', application_id, 'tor') }} diff --git a/roles/sys-front-tls/templates/nginx_ssl_header.j2 b/roles/sys-front-tls/templates/nginx_ssl_header.j2 index 6fc4b4f1a7..00526b0318 100644 --- a/roles/sys-front-tls/templates/nginx_ssl_header.j2 +++ b/roles/sys-front-tls/templates/nginx_ssl_header.j2 @@ -11,7 +11,7 @@ ssl_session_timeout 1d; ssl_session_cache shared:SSL:50m; ssl_session_tickets on; -add_header Strict-Transport-Security max-age=31536000 always; +add_header Strict-Transport-Security "{{ (lookup('applications') | security_headers(application_id, WEBSERVER_SECURITY_HEADERS)).hsts }}" always; ssl_stapling on; ssl_stapling_verify on; diff --git a/roles/sys-svc-compose-php/README.md b/roles/sys-svc-compose-php/README.md index c908bc9196..bef096f408 100644 --- a/roles/sys-svc-compose-php/README.md +++ b/roles/sys-svc-compose-php/README.md @@ -8,11 +8,14 @@ configs from their own `meta/volumes.yml`. ## Overview -This role installs one PHP ini (`FILE_PHP_HARDENING_INI`) and one PHP-FPM pool -drop-in (`FILE_PHP_FPM_HARDENING_CONF`). A PHP role opts in by declaring a +This role installs one PHP ini (`FILE_PHP_HARDENING_INI`), one interim PHP ini +(`FILE_PHP_MEMORY_UNLIMITED_INI`) and one PHP-FPM pool drop-in +(`FILE_PHP_FPM_HARDENING_CONF`). A PHP role opts in by declaring a `type: config` entry with that file as `source` and a file inside the scan dir of its image as `target`, e.g. `conf.d/zz-infinito-hardening.ini` or, for the -pool, `php-fpm.d/zz-infinito-hardening.conf`. +pool, `php-fpm.d/zz-infinito-hardening.conf`. Only roles whose image still +ships a PHP release without the CVE-2026-109618 fix also mount +`FILE_PHP_MEMORY_UNLIMITED_INI`, as `conf.d/zz-infinito-memory-unlimited.ini`. ## Cosmos @@ -29,7 +32,8 @@ Solid `1:1` edges are fixed relationships; dashed `0..1` edges are conditional ( ## Features -- **PHP ini hardening:** `expose_php` off; `session.upload_progress.enabled = 0` and, on PHP 8.5 only, `fatal_error_backtraces = 0` against CVE-2026-109619; the interim `memory_limit = -1` against CVE-2026-109618. +- **PHP ini hardening:** `expose_php` off; `session.upload_progress.enabled = 0` and, on PHP 8.5 only, `fatal_error_backtraces = 0` against CVE-2026-109619. +- **Interim CVE-2026-109618 mitigation:** `memory_limit = -1` for images that predate PHP 8.2.35, 8.3.36, 8.4.27 and 8.5.12. - **PHP-FPM worker recycling:** `pm.max_requests` from `PHP_FPM_MAX_REQUESTS` for images whose `[www]` pool reads `php-fpm.d/*.conf`. ## Credits diff --git a/roles/sys-svc-compose-php/files/hardening.ini b/roles/sys-svc-compose-php/files/hardening.ini index 2e5a25ec09..20ac81b037 100644 --- a/roles/sys-svc-compose-php/files/hardening.ini +++ b/roles/sys-svc-compose-php/files/hardening.ini @@ -1,4 +1,3 @@ expose_php = Off session.upload_progress.enabled = 0 fatal_error_backtraces = 0 -memory_limit = -1 diff --git a/roles/sys-svc-compose-php/files/memory-unlimited.ini b/roles/sys-svc-compose-php/files/memory-unlimited.ini new file mode 100644 index 0000000000..7999e96156 --- /dev/null +++ b/roles/sys-svc-compose-php/files/memory-unlimited.ini @@ -0,0 +1 @@ +memory_limit = -1 diff --git a/roles/sys-svc-compose-php/tasks/00_core.yml b/roles/sys-svc-compose-php/tasks/00_core.yml index c974b5eee9..fb69a45693 100644 --- a/roles/sys-svc-compose-php/tasks/00_core.yml +++ b/roles/sys-svc-compose-php/tasks/00_core.yml @@ -17,6 +17,15 @@ owner: root group: root +- name: "πŸ›‘οΈ PHP hardening | install interim memory ini" + become: true + stack_host_copy: + src: "memory-unlimited.ini" + dest: "{{ FILE_PHP_MEMORY_UNLIMITED_INI }}" + mode: "0444" + owner: root + group: root + - name: "πŸ›‘οΈ PHP hardening | render FPM pool" become: true stack_host_template: diff --git a/roles/sys-svc-proxy/README.md b/roles/sys-svc-proxy/README.md index 65120388ba..d284cf5588 100644 --- a/roles/sys-svc-proxy/README.md +++ b/roles/sys-svc-proxy/README.md @@ -31,11 +31,35 @@ The goal of this role is to deliver a **hassle-free, production-ready reverse pr - **Automatic TLS & HSTS**: integrates with the *sys-svc-webserver-https* role for certificate management. - **Flexible vHost templates**: *basic* and *ws_generic* flavours cover standard HTTP and WebSocket applications. -- **Security headers**: sensible defaults plus optional X-Frame-Options / CSP based on application settings. +- **Security headers**: CSP from each role's `meta/csp.yml`, plus the per-role headers described in [Security Headers](#security-headers). - **WebSocket & HTTP/2 aware**: upgrades, keep-alive tuning, and gzip already configured. - **OAuth2 gating**: drop-in support when *web-app-keycloak's SSO-proxy sidecar* is present. - **Modular includes**: headers, locations, and global snippets are factored for easy extension. +## Security Headers + +`WEBSERVER_SECURITY_HEADERS` in [04_webserver.yml](../../group_vars/all/04_webserver.yml) holds the platform values. A role overrides any key under `security_headers` in its `meta/server.yml`; an inventory overrides it at `applications..server.security_headers`. + +```yaml +# roles//meta/server.yml +security_headers: + nosniff: true + referrer_policy: strict-origin-when-cross-origin + permissions_policy: 'camera=(self "https://meet.example.org"), microphone=(self)' + hsts: + include_subdomains: true + preload: true +``` + +| Key | Header | Where it is rendered | +|---|---|---| +| `nosniff` | `X-Content-Type-Options: nosniff` | every response of a location that includes [content_security_policy.conf.j2](templates/headers/content_security_policy.conf.j2) | +| `referrer_policy` | `Referrer-Policy` | the same locations, only when the upstream sends none | +| `permissions_policy` | `Permissions-Policy` | HTML documents of the same locations | +| `hsts.*` | `Strict-Transport-Security` | the server block of every TLS vhost, via [nginx_ssl_header.j2](../sys-front-tls/templates/nginx_ssl_header.j2); an onion vhost has no TLS and gets none | + +The `security_headers` filter rejects unknown keys, wrong types, unknown `Referrer-Policy` tokens, and `preload` without `include_subdomains` or below a one-year `max_age`. + ## Credits Implemented by **[Kevin Veen-Birkenbach](https://www.veen.world)**. diff --git a/roles/sys-svc-proxy/templates/headers/content_security_policy.conf.j2 b/roles/sys-svc-proxy/templates/headers/content_security_policy.conf.j2 index 80d3b05a73..e1aeca87e3 100644 --- a/roles/sys-svc-proxy/templates/headers/content_security_policy.conf.j2 +++ b/roles/sys-svc-proxy/templates/headers/content_security_policy.conf.j2 @@ -19,6 +19,8 @@ header_filter_by_lua_block { ngx.header["Content-Security-Policy-Report-Only"] = nil end +{% include 'roles/sys-svc-proxy/templates/headers/security_headers.lua.j2' %} + -- If you'll modify the body later, drop Content-Length on HTML if is_html then ngx.ctx.is_html = true diff --git a/roles/sys-svc-proxy/templates/headers/security_headers.lua.j2 b/roles/sys-svc-proxy/templates/headers/security_headers.lua.j2 new file mode 100644 index 0000000000..58dd96ed17 --- /dev/null +++ b/roles/sys-svc-proxy/templates/headers/security_headers.lua.j2 @@ -0,0 +1,14 @@ +{% set _security_headers = lookup('applications') | security_headers(application_id, WEBSERVER_SECURITY_HEADERS) %} +{% if _security_headers.nosniff %} + ngx.header["X-Content-Type-Options"] = "nosniff" +{% endif %} +{% if _security_headers.referrer_policy %} + if not ngx.header["Referrer-Policy"] then + ngx.header["Referrer-Policy"] = {{ _security_headers.referrer_policy | to_json }} + end +{% endif %} +{% if _security_headers.permissions_policy %} + if is_html then + ngx.header["Permissions-Policy"] = {{ _security_headers.permissions_policy | to_json }} + end +{% endif %} diff --git a/roles/web-app-bluesky/meta/services.yml b/roles/web-app-bluesky/meta/services.yml index 47083d70fa..0720d92266 100644 --- a/roles/web-app-bluesky/meta/services.yml +++ b/roles/web-app-bluesky/meta/services.yml @@ -62,7 +62,7 @@ web: view: enabled: false repository: https://github.com/bluesky-social/social-app.git - ref: "1.136.0" + ref: "1.137.0" ports: local: http: 8051 diff --git a/roles/web-app-bookwyrm/meta/services.yml b/roles/web-app-bookwyrm/meta/services.yml index fcee76585f..544d79cf7c 100644 --- a/roles/web-app-bookwyrm/meta/services.yml +++ b/roles/web-app-bookwyrm/meta/services.yml @@ -62,7 +62,7 @@ bookwyrm: version: 3.11-slim custom: true repository: https://github.com/bookwyrm-social/bookwyrm.git - ref: v0.9.3 + ref: v0.9.4 min_storage: 579MB registration_open: false allow_invite_request: false diff --git a/roles/web-app-dashboard/files/playwright/test-csp-canonical-domain.js b/roles/web-app-dashboard/files/playwright/test-csp-canonical-domain.js index 3edfdebcaf..63f1448081 100644 --- a/roles/web-app-dashboard/files/playwright/test-csp-canonical-domain.js +++ b/roles/web-app-dashboard/files/playwright/test-csp-canonical-domain.js @@ -23,6 +23,12 @@ exports.register = function (shared) { const directives = assertCspResponseHeader(response, "dashboard landing"); await assertCspMetaParity(page, directives, "dashboard landing"); + for (const directive of ["script-src", "script-src-elem"]) { + expect( + directives[directive], + `dashboard landing: ${directive} MUST NOT carry 'unsafe-inline', inline scripts run by hash` + ).not.toContain("'unsafe-inline'"); + } const documentHtml = await response.text(); const documentUrl = response.url(); diff --git a/roles/web-app-dashboard/meta/csp.yml b/roles/web-app-dashboard/meta/csp.yml index 71a188495c..a93a209457 100644 --- a/roles/web-app-dashboard/meta/csp.yml +++ b/roles/web-app-dashboard/meta/csp.yml @@ -15,5 +15,9 @@ whitelist: frame-src: - "*.{{ DOMAIN_PRIMARY }}" flags: + script-src: + unsafe-inline: false + script-src-elem: + unsafe-inline: false script-src-attr: - unsafe-inline: true # nocheck: csp-unsafe Reason: historical, TODO: re-verify it is really required and does not open attack surface + unsafe-inline: true # nocheck: csp-unsafe Reason: port-ui 2.2.2 renders inline event handlers (menu onclick entries, openDynamicPopup, closeAllModals, card image onerror) diff --git a/roles/web-app-fider/README.md b/roles/web-app-fider/README.md index e88980fe4e..d2c3c56ec3 100644 --- a/roles/web-app-fider/README.md +++ b/roles/web-app-fider/README.md @@ -8,7 +8,7 @@ This role deploys Fider as part of the Infinito.Nexus stack using a single Docker Compose container backed by PostgreSQL. It configures SSO via Keycloak automatically on first deploy, optional email notifications via Mailu, and HTTPS via NGINX reverse proxy. -The setup tasks handle the full first-deploy bootstrap automatically: +The setup tasks handle the full first-deploy bootstrap automatically. Steps 1 to 3 run on every deploy, with or without SSO; step 4 runs only when `services.sso.enabled` is `true`: 1. **Tenant bootstrap:** calls Fider's `POST /_api/tenants` API to create the initial tenant. 2. **Admin user creation:** inserts the admin user directly into the `users` table, bypassing email verification. Idempotent via `WHERE NOT EXISTS`. diff --git a/roles/web-app-fider/tasks/00_core.yml b/roles/web-app-fider/tasks/00_core.yml index b50ce78c4c..890de3447d 100644 --- a/roles/web-app-fider/tasks/00_core.yml +++ b/roles/web-app-fider/tasks/00_core.yml @@ -20,8 +20,12 @@ - name: "🚿 Flush compose handlers for {{ application_id }}" ansible.builtin.meta: flush_handlers +- name: "πŸ₯Ύ Fider | Tenant bootstrap" + include_tasks: 01_tenant.yml + when: IS_STACK_HOST | bool + - name: "πŸ”§ Fider | OIDC setup" - include_tasks: 01_setup_oidc.yml + include_tasks: 02_setup_oidc.yml when: - FIDER_OIDC_ENABLED | bool - IS_STACK_HOST | bool diff --git a/roles/web-app-fider/tasks/01_setup_oidc.yml b/roles/web-app-fider/tasks/01_tenant.yml similarity index 73% rename from roles/web-app-fider/tasks/01_setup_oidc.yml rename to roles/web-app-fider/tasks/01_tenant.yml index 2985fc2793..68cd7f47a8 100644 --- a/roles/web-app-fider/tasks/01_setup_oidc.yml +++ b/roles/web-app-fider/tasks/01_tenant.yml @@ -41,19 +41,29 @@ body_format: json body: "{{ FIDER_TENANT_BOOTSTRAP_BODY }}" status_code: [200, 201] + no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}" when: - DEPLOYMENT_MODE == 'compose' - (fider_tenant_count.rows[0][0] | int) == 0 -- name: "πŸ₯Ύ Fider | Bootstrap initial tenant via API (swarm, routing-mesh port)" - uri_retry: - url: "http://127.0.0.1:{{ lookup('config', application_id, 'services.fider.ports.local.http') }}/_api/tenants" - method: POST - body_format: json - body: "{{ FIDER_TENANT_BOOTSTRAP_BODY }}" - status_code: [200, 201] +- name: "πŸ₯Ύ Fider | Bootstrap initial tenant via API (swarm in-container)" + ansible.builtin.shell: + cmd: >- # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node + container exec -i {{ FIDER_LOCAL_CID | quote }} + timeout {{ lookup('timeout', 30) | int }} bash -c + 'set -e; body=$(cat); length=$(printf %s "$body" | wc -c); + exec 3<>"/dev/tcp/127.0.0.1/$1" || exit 75; + printf "POST /_api/tenants HTTP/1.0\r\nContent-Type: application/json\r\nContent-Length: %d\r\n\r\n%s" "$length" "$body" >&3; + read -r _ status _ <&3; printf %s "$status"; + case $status in 5*) exit 75;; esac' _ {{ FIDER_INTERNAL_PORT | quote }} + stdin: "{{ FIDER_TENANT_BOOTSTRAP_BODY | to_json }}" register: fider_tenant_bootstrap changed_when: true + failed_when: fider_tenant_bootstrap.rc != 0 or (fider_tenant_bootstrap.stdout | trim) not in ['200', '201'] + retries: 30 + delay: 2 + until: fider_tenant_bootstrap.rc != 75 + no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}" delegate_to: "{{ FIDER_HOST_NODE }}" when: - DEPLOYMENT_MODE == 'swarm' @@ -75,17 +85,3 @@ query_file: "{{ role_path }}/files/sql/activate-tenants.sql" mask_values: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}" changed_when: true - -- name: "πŸ”§ Fider | Configure Keycloak as OIDC provider in database" - database_query: - config: "{{ lookup('database', application_id) }}" - query_file: "{{ role_path }}/files/sql/configure-oidc-provider.sql" - named_args: - display_name: "{{ SOFTWARE_NAME }} SSO" - client_id: "{{ OIDC.CLIENT.ID }}" - client_secret: "{{ OIDC.CLIENT.SECRET }}" - authorize_url: "{{ OIDC.CLIENT.AUTHORIZE_URL }}" - token_url: "{{ OIDC.CLIENT.TOKEN_URL }}" - profile_url: "{{ OIDC.CLIENT.USER_INFO_URL }}" - mask_values: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}" - changed_when: true diff --git a/roles/web-app-fider/tasks/02_setup_oidc.yml b/roles/web-app-fider/tasks/02_setup_oidc.yml new file mode 100644 index 0000000000..d8327ba53f --- /dev/null +++ b/roles/web-app-fider/tasks/02_setup_oidc.yml @@ -0,0 +1,14 @@ +--- +- name: "πŸ”§ Fider | Configure Keycloak as OIDC provider in database" + database_query: + config: "{{ lookup('database', application_id) }}" + query_file: "{{ role_path }}/files/sql/configure-oidc-provider.sql" + named_args: + display_name: "{{ SOFTWARE_NAME }} SSO" + client_id: "{{ OIDC.CLIENT.ID }}" + client_secret: "{{ OIDC.CLIENT.SECRET }}" + authorize_url: "{{ OIDC.CLIENT.AUTHORIZE_URL }}" + token_url: "{{ OIDC.CLIENT.TOKEN_URL }}" + profile_url: "{{ OIDC.CLIENT.USER_INFO_URL }}" + mask_values: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}" + changed_when: true diff --git a/roles/web-app-fider/vars/main.yml b/roles/web-app-fider/vars/main.yml index 3cd44bb98f..2297ea2a8e 100644 --- a/roles/web-app-fider/vars/main.yml +++ b/roles/web-app-fider/vars/main.yml @@ -3,6 +3,7 @@ application_id: "web-app-fider" FIDER_CONTAINER: "{{ lookup('config', application_id, 'services.fider.name') }}" +FIDER_INTERNAL_PORT: "{{ lookup('config', application_id, 'services.fider.ports.internal.http') }}" FIDER_OIDC_ENABLED: "{{ lookup('config', application_id, 'services.sso.enabled') }}" @@ -20,7 +21,7 @@ FIDER_MCP_PORT: "{{ lookup('config', application_id, 'services.fidermcp.ports.in FIDER_MCP_BEARER: "{{ lookup('config', application_id, 'secrets.credentials.mcp_bearer') }}" FIDER_MCP_INSTANCE_DIR: "{{ [lookup('container', application_id, 'directories.instance'), 'mcp'] | path_join }}" FIDER_MCP_UPSTREAM_HOST: "{{ lookup('config', application_id, 'services.fider.name') }}" -FIDER_MCP_UPSTREAM_PORT: "{{ lookup('config', application_id, 'services.fider.ports.internal.http') }}" +FIDER_MCP_UPSTREAM_PORT: "{{ FIDER_INTERNAL_PORT }}" FIDER_MCP_UPSTREAM_URL: "http://{{ FIDER_MCP_UPSTREAM_HOST }}:{{ FIDER_MCP_UPSTREAM_PORT }}" FIDER_MCP_CONTRACT: provider: "{{ application_id }}" diff --git a/roles/web-app-fusiondirectory/TODO.md b/roles/web-app-fusiondirectory/TODO.md index dc647a5fa8..f20419e2c3 100644 --- a/roles/web-app-fusiondirectory/TODO.md +++ b/roles/web-app-fusiondirectory/TODO.md @@ -1,4 +1,4 @@ # To-dos - Move off PHP 7.4. The pinned `nfrastack/fusiondirectory:1.5` image builds on `ghcr.io/nfrastack/container-nginx-php-fpm` with PHP 7.4 on Alpine 3.15, which is end of life and gets no fix for CVE-2026-109618 and CVE-2026-109619. -- Mount the shared PHP hardening ini (`FILE_PHP_HARDENING_INI`) once the image's scan dir is verified. The nfrastack init scripts manage `conf.d` at runtime, so a read-only mount there has to be tested before it ships. + - No FusionDirectory release runs on a supported PHP yet: upstream certifies 1.4 to 1.6 for PHP 7.4 only, `nfrastack/container-fusiondirectory` builds its image only on PHP 7.4 and Alpine 3.15, and the PHP 8 port lives on upstream's unreleased `php8` branch. Until then the shared hardening ini mounted at `/etc/php7/conf.d/zz-infinito-hardening.ini` carries the mitigations for both CVEs. Options: rebuild the image on upstream's first `php8` release, or build `nfrastack/container-fusiondirectory` against a pinned `php8` commit on `container-nginx-php-fpm` 8.4 before that release. diff --git a/roles/web-app-fusiondirectory/meta/volumes.yml b/roles/web-app-fusiondirectory/meta/volumes.yml index 8f7f900245..ed9d3576c1 100644 --- a/roles/web-app-fusiondirectory/meta/volumes.yml +++ b/roles/web-app-fusiondirectory/meta/volumes.yml @@ -1,4 +1,11 @@ --- +php_hardening: + type: config + source: "{{ FILE_PHP_HARDENING_INI }}" + mode: "0444" + mounts: + - service: fusiondirectory + target: /etc/php7/conf.d/zz-infinito-hardening.ini # nocheck: embedded-state-on-nfs generated asset cache; the authoritative state lives in LDAP data: type: volume diff --git a/roles/web-app-gitea/tasks/01_manager_ops.yml b/roles/web-app-gitea/tasks/01_manager_ops.yml index 2eb113d931..9c4754fe17 100644 --- a/roles/web-app-gitea/tasks/01_manager_ops.yml +++ b/roles/web-app-gitea/tasks/01_manager_ops.yml @@ -1,11 +1,4 @@ --- -- name: ⏳ Wait for Gitea HTTP endpoint - wait_for: - host: "{{ DOCKER_REACH_HOST }}" - port: "{{ lookup('config', application_id, 'services.gitea.ports.local.http') }}" - delay: 5 - timeout: "{{ lookup('timeout', 300) | int }}" - - name: "πŸ” Resolve {{ application_id }} hosting node + container id" ansible.builtin.include_tasks: "{{ lookup('path_absolute', 'roles/sys-svc-compose/tasks/utils/swarm/resolve_host_cid.yml') }}" vars: @@ -13,6 +6,17 @@ resolve_output_prefix: GITEA resolve_compose_cid: "{{ GITEA_CONTAINER_ADDRESS }}" +- name: ⏳ Wait for Gitea HTTP endpoint + ansible.builtin.shell: >- # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node + container exec {{ GITEA_LOCAL_CID | quote }} + {{ 10 | curl(retries=0) }} -S -o /dev/null {{ GITEA_LOOPBACK_VERSION_URL | quote }} + delegate_to: "{{ GITEA_HOST_NODE }}" + register: gitea_http_ready + changed_when: false + retries: "{{ ((lookup('timeout', 300) | int) / 5) | round(0, 'ceil') | int }}" + delay: 5 + until: gitea_http_ready.rc == 0 + - name: "⏳ Wait for Gitea app.ini to be present after redeploy" shell: | # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node container exec -i --user {{ GITEA_USER }} {{ GITEA_LOCAL_CID | quote }} \ @@ -48,13 +52,13 @@ failed_when: create_admin.rc != 0 and 'user already exists' not in create_admin.stderr - name: "⏳ Wait until Gitea setup and migrations are ready" - uri_retry: - url: "http://{{ DOCKER_REACH_HOST }}:{{ lookup('config', application_id, 'services.gitea.ports.local.http') }}/api/v1/version" - method: GET - status_code: 200 - return_content: false + ansible.builtin.shell: >- # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node + container exec {{ GITEA_LOCAL_CID | quote }} + {{ 10 | curl(retries=0) }} -fS -o /dev/null {{ GITEA_LOOPBACK_VERSION_URL | quote }} + delegate_to: "{{ GITEA_HOST_NODE }}" register: gitea_ready - until: gitea_ready.status == 200 + changed_when: false + until: gitea_ready.rc == 0 retries: 20 delay: 5 when: (GITEA_OIDC_ENABLED | bool) or (GITEA_LDAP_ENABLED | bool) diff --git a/roles/web-app-gitea/vars/main.yml b/roles/web-app-gitea/vars/main.yml index 7b36c9e8e4..9282a3dc5f 100644 --- a/roles/web-app-gitea/vars/main.yml +++ b/roles/web-app-gitea/vars/main.yml @@ -22,6 +22,7 @@ GITEA_CONTAINER: "{{ lookup('config', application_id, 'services.gitea.name') }}" GITEA_CONTAINER_ADDRESS: "{{ lookup('container_address', application_id, entity_name) }}" GITEA_USER: "git" GITEA_CONFIG: "/data/gitea/conf/app.ini" +GITEA_LOOPBACK_VERSION_URL: "http://127.0.0.1:{{ lookup('config', application_id, 'services.gitea.ports.internal.http') }}/api/v1/version" GITEA_REDIS_ENABLED: "{{ lookup('config', application_id, 'services.redis.enabled') }}" GITEA_REDIS_ADDRESS: "{{ lookup('engine', 'redis', application_id, 'host') }}:{{ lookup('engine', 'redis', application_id, 'port') }}" diff --git a/roles/web-app-gitlab/meta/services.yml b/roles/web-app-gitlab/meta/services.yml index 9c7cd70687..111272749a 100644 --- a/roles/web-app-gitlab/meta/services.yml +++ b/roles/web-app-gitlab/meta/services.yml @@ -76,7 +76,7 @@ gitlab: lifecycle: beta webservice: image: registry.gitlab.com/gitlab-org/build/cng/gitlab-webservice-ce - version: v19.5.1 + version: v19.5.3 name: gitlab-webservice healthcheck: test: ["CMD", "/scripts/healthcheck"] @@ -95,7 +95,7 @@ sidekiq: flavor: tcp path: liveness image: registry.gitlab.com/gitlab-org/build/cng/gitlab-sidekiq-ce - version: v19.5.1 + version: v19.5.3 name: gitlab-sidekiq cpus: "1.0" mem_reservation: 2g @@ -106,7 +106,7 @@ sidekiq: http: 3808 workhorse: image: registry.gitlab.com/gitlab-org/build/cng/gitlab-workhorse-ce - version: v19.5.1 + version: v19.5.3 name: gitlab-workhorse healthcheck: test: ["CMD", "/scripts/healthcheck"] @@ -118,7 +118,7 @@ gitaly: # nocheck: single-replica replicas: 1 image: registry.gitlab.com/gitlab-org/build/cng/gitaly - version: v19.5.1 + version: v19.5.3 healthcheck: test: ["CMD", "/scripts/healthcheck"] name: gitlab-gitaly @@ -131,7 +131,7 @@ gitaly: pids_limit: 1024 shell: image: registry.gitlab.com/gitlab-org/build/cng/gitlab-shell - version: v19.5.1 + version: v19.5.3 name: gitlab-shell ports: internal: @@ -144,7 +144,7 @@ migrations: # nocheck: single-replica replicas: 1 image: registry.gitlab.com/gitlab-org/build/cng/gitlab-rails-ce - version: v19.5.1 + version: v19.5.3 name: gitlab-migrations cpus: "1.0" mem_reservation: 1g diff --git a/roles/web-app-joomla/meta/volumes.yml b/roles/web-app-joomla/meta/volumes.yml index f9bbb1d80c..d9c14bc427 100644 --- a/roles/web-app-joomla/meta/volumes.yml +++ b/roles/web-app-joomla/meta/volumes.yml @@ -12,7 +12,7 @@ php_upload: mode: "0444" mounts: - service: joomla - target: /usr/local/etc/php/conf.d/zzz-joomla-uploads.ini + target: /usr/local/etc/php/conf.d/uploads.ini php_hardening: type: config diff --git a/roles/web-app-magento/meta/volumes.yml b/roles/web-app-magento/meta/volumes.yml index 8fceecaa8a..541ceefd0d 100644 --- a/roles/web-app-magento/meta/volumes.yml +++ b/roles/web-app-magento/meta/volumes.yml @@ -31,3 +31,11 @@ php_hardening: mounts: - service: php target: /usr/local/etc/php/conf.d/zz-infinito-hardening.ini + +php_memory_unlimited: + type: config + source: "{{ FILE_PHP_MEMORY_UNLIMITED_INI }}" + mode: "0444" + mounts: + - service: php + target: /usr/local/etc/php/conf.d/zz-infinito-memory-unlimited.ini diff --git a/roles/web-app-mailu/README.md b/roles/web-app-mailu/README.md index f803334cb0..f1a6425f20 100644 --- a/roles/web-app-mailu/README.md +++ b/roles/web-app-mailu/README.md @@ -87,6 +87,7 @@ Solid `1:1` edges are fixed relationships; dashed `0..1` edges are conditional ( - **Customizable Webmail and Administration:** Provides a modern web interface for managing emails and administrative tasks with ease. - **Flexible Deployment:** Easily scale and customize using Docker Compose, with configurable settings for networking, storage, and external services. - **OIDC Support:** Optionally integrate with OpenID Connect for centralized authentication across your services. +- **DMARC Reports:** The published `_dmarc` record sends aggregate reports (`rua`) to `@` of the user key in `services.mailu.dmarc.rua_user` (`administrator` unless the inventory names another one). That user MUST carry a `mailbox` account or a `forward` to a user that carries one and whose `email` is that mailbox (`@`), otherwise the deploy fails before any record is written. ## Quick Setup diff --git a/roles/web-app-mailu/meta/services.yml b/roles/web-app-mailu/meta/services.yml index 828b626233..a9bc21bbeb 100644 --- a/roles/web-app-mailu/meta/services.yml +++ b/roles/web-app-mailu/meta/services.yml @@ -46,6 +46,8 @@ mailu: project_hard_restart: true min_storage: 20GB domain: "{{ lookup('email').domain }}" + dmarc: + rua_user: administrator ports: local: http: 8007 diff --git a/roles/web-app-mailu/meta/volumes.yml b/roles/web-app-mailu/meta/volumes.yml index 8616ec60f4..163df1c462 100644 --- a/roles/web-app-mailu/meta/volumes.yml +++ b/roles/web-app-mailu/meta/volumes.yml @@ -90,3 +90,10 @@ php_hardening: mounts: - service: webmail target: /etc/php83/conf.d/zz-infinito-hardening.ini +php_memory_unlimited: + type: config + source: "{{ FILE_PHP_MEMORY_UNLIMITED_INI }}" + mode: "0444" + mounts: + - service: webmail + target: /etc/php83/conf.d/zz-infinito-memory-unlimited.ini diff --git a/roles/web-app-mailu/tasks/08_dns-records.yml b/roles/web-app-mailu/tasks/08_dns-records.yml index 9fa9c1bf66..2b18a65363 100644 --- a/roles/web-app-mailu/tasks/08_dns-records.yml +++ b/roles/web-app-mailu/tasks/08_dns-records.yml @@ -1,4 +1,23 @@ --- +- name: "βœ… Assert the DMARC aggregate report address reaches a Mailu mailbox or alias" + ansible.builtin.assert: + that: + - >- + 'mailbox' in lookup('users', MAILU_DMARC_RUA_USER).accounts + or ( + lookup('users', MAILU_DMARC_RUA_USER).forward | length > 0 + and 'mailbox' in lookup('users', lookup('users', MAILU_DMARC_RUA_USER).forward).accounts + and lookup('users', lookup('users', MAILU_DMARC_RUA_USER).forward).email + == lookup('users', lookup('users', MAILU_DMARC_RUA_USER).forward).username ~ '@' ~ MAILU_DOMAIN + ) + fail_msg: >- + services.mailu.dmarc.rua_user '{{ MAILU_DMARC_RUA_USER }}' carries + neither a mailbox account nor a forward to a user with one whose email + is that mailbox (@{{ MAILU_DOMAIN }}), so {{ MAILU_DMARC_RUA }} + reaches no Mailu mailbox and DMARC aggregate reports bounce or leave + the server. + quiet: true + - name: "🌐 DNS (Cloudflare) for Mailu" include_role: name: sys-dns-cloudflare-records @@ -26,7 +45,7 @@ zone: "{{ MAILU_DOMAIN_DNS_ZONE }}" name: "_dmarc.{{ MAILU_DOMAIN_DNS_ZONE }}" solo: true - value: '"v=DMARC1; p=reject; ruf=mailto:{{ MAILU_DMARC_RUF }}; adkim=s; aspf=s"' + value: '"v=DMARC1; p=reject; rua=mailto:{{ MAILU_DMARC_RUA }}; ruf=mailto:{{ MAILU_DMARC_RUF }}; adkim=s; aspf=s"' - type: TXT zone: "{{ MAILU_DOMAIN_DNS_ZONE }}" name: "dkim._domainkey.{{ MAILU_DOMAIN_DNS_ZONE }}" diff --git a/roles/web-app-mailu/templates/env.j2 b/roles/web-app-mailu/templates/env.j2 index 469b70fa0d..d073323611 100644 --- a/roles/web-app-mailu/templates/env.j2 +++ b/roles/web-app-mailu/templates/env.j2 @@ -20,7 +20,7 @@ RELAYNETS= RELAYHOST= FETCHMAIL_DELAY=600 RECIPIENT_DELIMITER=+ -DMARC_RUA=admin +DMARC_RUA={{ MAILU_DMARC_RUA_LOCALPART }} DMARC_RUF=admin WELCOME=false WELCOME_SUBJECT=Welcome to your new email account diff --git a/roles/web-app-mailu/vars/main.yml b/roles/web-app-mailu/vars/main.yml index 67132cbd2e..cbacf1545c 100644 --- a/roles/web-app-mailu/vars/main.yml +++ b/roles/web-app-mailu/vars/main.yml @@ -48,6 +48,9 @@ MAILU_EXTRA_HOSTS: "{{ query('mailu_extra_hosts') }}" MAILU_USERS: "{{ lookup('mailu_users') }}" MAILU_DOCKER_FLAVOR: "{{ 'ghcr.io/heviat' if MAILU_OIDC_ENABLED | bool else 'ghcr.io/mailu' }}" MAILU_DMARC_RUF: "{{ lookup('config', application_id, 'users.administrator.email') }}" +MAILU_DMARC_RUA_USER: "{{ lookup('config', application_id, 'services.mailu.dmarc.rua_user') }}" +MAILU_DMARC_RUA_LOCALPART: "{{ lookup('users', MAILU_DMARC_RUA_USER).username }}" +MAILU_DMARC_RUA: "{{ MAILU_DMARC_RUA_LOCALPART }}@{{ MAILU_DOMAIN }}" MAILU_DKIM_KEY_FILE: "{{ MAILU_DOMAIN }}.dkim.key" MAILU_DKIM_KEY_PATH: "/dkim/{{ MAILU_DKIM_KEY_FILE }}" MAILU_NGINX_HOST_DIR: "{{ [ MAILU_OVERRIDES_DIR, 'nginx' ] | path_join }}" diff --git a/roles/web-app-pgadmin/meta/services.yml b/roles/web-app-pgadmin/meta/services.yml index 4184791bf4..263a62428e 100644 --- a/roles/web-app-pgadmin/meta/services.yml +++ b/roles/web-app-pgadmin/meta/services.yml @@ -11,7 +11,7 @@ pgadmin: # nocheck: default-placement-manager embedded sqlite config db; node-local in swarm placement: manager image: dpage/pgadmin4 - version: "9.18" + version: "9.19" min_storage: 378MB server_mode: false master_password_required: true diff --git a/roles/web-app-phpldapadmin/meta/volumes.yml b/roles/web-app-phpldapadmin/meta/volumes.yml index df9e69ec7e..d5c7b46468 100644 --- a/roles/web-app-phpldapadmin/meta/volumes.yml +++ b/roles/web-app-phpldapadmin/meta/volumes.yml @@ -6,3 +6,11 @@ php_hardening: mounts: - service: phpldapadmin target: /usr/local/etc/php/conf.d/zz-infinito-hardening.ini + +php_memory_unlimited: + type: config + source: "{{ FILE_PHP_MEMORY_UNLIMITED_INI }}" + mode: "0444" + mounts: + - service: phpldapadmin + target: /usr/local/etc/php/conf.d/zz-infinito-memory-unlimited.ini diff --git a/roles/web-app-pretix/meta/services.yml b/roles/web-app-pretix/meta/services.yml index db3aa46d73..e6410681cd 100644 --- a/roles/web-app-pretix/meta/services.yml +++ b/roles/web-app-pretix/meta/services.yml @@ -53,7 +53,7 @@ pretix: swarm: enabled: true image: pretix/standalone - version: 2026.8.1 + version: 2026.9.0 custom: true name: pretix min_storage: 1003MB diff --git a/roles/web-app-prometheus/meta/services.yml b/roles/web-app-prometheus/meta/services.yml index fd8f536f5b..3efbe50131 100644 --- a/roles/web-app-prometheus/meta/services.yml +++ b/roles/web-app-prometheus/meta/services.yml @@ -79,7 +79,7 @@ alertmanager: flavor: wget path: -/healthy image: prom/alertmanager # nocheck: volumes-path-single-spot: the repository path of an image name, not a mount target - version: v0.34.1 + version: v0.34.2 name: prometheus-alertmanager cpus: "0.25" mem_reservation: 64m diff --git a/roles/web-app-shopware/meta/services.yml b/roles/web-app-shopware/meta/services.yml index 2e31a7bd76..72a61b5c05 100644 --- a/roles/web-app-shopware/meta/services.yml +++ b/roles/web-app-shopware/meta/services.yml @@ -47,7 +47,7 @@ shopware: swarm: enabled: true image: composer - version: "2.10" + version: "2.11" custom: true min_storage: 278MB package: diff --git a/roles/web-app-shopware/meta/volumes.yml b/roles/web-app-shopware/meta/volumes.yml index 021a1a0809..44cfe23ed8 100644 --- a/roles/web-app-shopware/meta/volumes.yml +++ b/roles/web-app-shopware/meta/volumes.yml @@ -131,6 +131,14 @@ php_hardening: - service: web target: /usr/local/etc/php/conf.d/zz-infinito-hardening.ini +php_memory_unlimited: + type: config + source: "{{ FILE_PHP_MEMORY_UNLIMITED_INI }}" + mode: "0444" + mounts: + - service: web + target: /usr/local/etc/php/conf.d/zz-infinito-memory-unlimited.ini + php_fpm_hardening: type: config source: "{{ FILE_PHP_FPM_HARDENING_CONF }}" diff --git a/roles/web-app-shopware/tasks/02_manager_ops.yml b/roles/web-app-shopware/tasks/02_manager_ops.yml index b8b9040167..d49edced27 100644 --- a/roles/web-app-shopware/tasks/02_manager_ops.yml +++ b/roles/web-app-shopware/tasks/02_manager_ops.yml @@ -37,13 +37,6 @@ - name: "🚿 Flush compose handlers" meta: flush_handlers -- name: ⏳ Wait for Shopware HTTP endpoint - wait_for: - host: "{{ DOCKER_REACH_HOST }}" - port: "{{ lookup('config', application_id, 'services.shopware.ports.local.http') }}" - delay: 5 - timeout: "{{ lookup('timeout', 300) | int }}" - - name: "πŸ” Resolve Shopware web hosting node + container id" ansible.builtin.include_tasks: "{{ lookup('path_absolute', 'roles/sys-svc-compose/tasks/utils/swarm/resolve_host_cid.yml') }}" vars: @@ -53,6 +46,18 @@ resolve_converge_retries: 120 resolve_converge_delay: 5 +- name: ⏳ Wait for Shopware HTTP endpoint + ansible.builtin.shell: >- # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node + container exec {{ SHOPWARE_WEB_LOCAL_CID | quote }} + sh -c 'timeout "$2" wget -q --spider "$1/robots.txt" || timeout "$2" wget -q --spider "$1/"' + _ {{ SHOPWARE_API_BASE | quote }} {{ lookup('timeout', 10) | int }} + delegate_to: "{{ SHOPWARE_WEB_HOST_NODE }}" + register: shopware_http_ready + changed_when: false + retries: "{{ ((lookup('timeout', 300) | int) / 5) | round(0, 'ceil') | int }}" + delay: 5 + until: shopware_http_ready.rc == 0 + - name: "βœ… Ensure admin user exists with correct password" ansible.builtin.include_tasks: file: 01_admin.yml diff --git a/roles/web-app-socialhome/meta/services.yml b/roles/web-app-socialhome/meta/services.yml index 2d1238bd0b..4f9f1999bd 100644 --- a/roles/web-app-socialhome/meta/services.yml +++ b/roles/web-app-socialhome/meta/services.yml @@ -13,7 +13,7 @@ socialhome: # nocheck: default-placement-manager embedded sqlite in a node-local volume; no clustered storage placement: manager image: ghcr.io/social-home-io/socialhome - version: "2026.10.27" + version: "2026.10.29" ports: local: http: 8089 diff --git a/roles/web-app-stalwart/README.md b/roles/web-app-stalwart/README.md index 8e3469b14c..72272de799 100644 --- a/roles/web-app-stalwart/README.md +++ b/roles/web-app-stalwart/README.md @@ -221,6 +221,11 @@ account (or the Keycloak SSO token when SSO is enabled). per-volume stop/start cycles. - **ClamAV runs fail-open with short milter timeouts** so mail keeps flowing while clamd warms its signature database instead of blocking the DATA stage. +- **DMARC aggregate reports go to the mailbox of + `services.stalwart.dmarc.rua_user`** (the `administrator` user unless the + inventory names another user key). The `_dmarc` record publishes + `rua=mailto:@`, and a deploy whose report user carries + no `mailbox` account fails before any record is written. - **`config.json` is bootstrap-only** (data store selection); all other configuration lives in the database and is provisioned over JMAP (`templates/jmap/*.json.j2`). @@ -368,7 +373,7 @@ Set `INFINITO_MAIL_PRODUCTION_HOST` to the server's public FQDN (in CI, a GitHub | A / AAAA | the mail host resolves | | MX | the zone's only MX is the mail host (the role publishes it `solo`) | | SPF | exactly one `v=spf1` record, authorising `mx` or `a:` | -| DMARC | `_dmarc` publishes a `v=DMARC1` record with a policy | +| DMARC | `_dmarc` publishes a `v=DMARC1` record with a policy whose `rua` names the deployed aggregate report mailbox | | DKIM | the selector this deploy read back publishes a non-empty `v=DKIM1` key | | SRV | `_submissions`/465, `_imaps`/993, `_pop3s`/995 point at the mail host | | PTR | rDNS does not contradict the mail host (absent β†’ warning; rDNS is provisioned for Hetzner only) | diff --git a/roles/web-app-stalwart/files/python/production_facts.py b/roles/web-app-stalwart/files/python/production_facts.py index dab5f17ab6..b92e56f489 100755 --- a/roles/web-app-stalwart/files/python/production_facts.py +++ b/roles/web-app-stalwart/files/python/production_facts.py @@ -23,6 +23,7 @@ import struct import sys import time from pathlib import Path +from urllib.parse import unquote TYPE_A = 1 TYPE_CNAME = 5 @@ -313,17 +314,62 @@ def check_spf(args, resolvers, report: Report) -> None: report.ok(f"SPF of {args.mail_domain}: {value}") +def dmarc_tags(record: str) -> dict[str, str]: + """Split a DMARC record into its ``tag=value`` pairs, tags lowercased. + + Raises: + ValueError: a tag occurs twice, which invalidates the whole record + (RFC 6376 3.2 tag-list, adopted by RFC 7489 6.3). + """ + tags: dict[str, str] = {} + for field in record.split(";"): + tag, separator, value = field.partition("=") + if not separator: + continue + tag = tag.strip().lower() + if tag in tags: + raise ValueError(f"duplicate tag {tag}=") + tags[tag] = value.strip() + return tags + + +def dmarc_report_addresses(uris: str) -> list[str]: + """The lowercased ``mailto:`` addresses of a ``rua``/``ruf`` value. + + A URI may end in a ``!`` report size limit (RFC 7489 6.2), which is + not part of the address. The address itself may be percent-encoded and + followed by ``?`` header fields (RFC 6068 2). + """ + addresses: list[str] = [] + for uri in uris.split(","): + scheme, separator, target = uri.strip().split("!", 1)[0].partition(":") + if separator and scheme.lower() == "mailto": + addresses.append(unquote(target.split("?", 1)[0]).lower()) + return addresses + + def check_dmarc(args, resolvers, report: Report) -> None: - """_dmarc TXT exists, is a DMARC1 record and declares a policy.""" + """_dmarc TXT is a DMARC1 record with a policy and the deployed rua address.""" name = f"_dmarc.{args.mail_domain}" records = [str(r) for r in query(name, TYPE_TXT, resolvers, args.timeout)] dmarc = [r for r in records if r.lower().startswith("v=dmarc1")] if not dmarc: report.fail(f"{name} has no v=DMARC1 TXT record") return - if "p=" not in dmarc[0].lower(): + try: + tags = dmarc_tags(dmarc[0]) + except ValueError as error: + report.fail(f"{name} is not a valid DMARC record, {error}: {dmarc[0]}") + return + if not tags.get("p"): report.fail(f"{name} declares no policy (p=): {dmarc[0]}") return + expected = args.dmarc_rua.strip().lower() + if expected not in dmarc_report_addresses(tags.get("rua", "")): + report.fail( + f"{name} sends no aggregate reports to {expected} (rua=): {dmarc[0]}" + ) + return report.ok(f"DMARC of {args.mail_domain}: {dmarc[0]}") @@ -489,6 +535,11 @@ def parse_args(argv: list[str] | None = None) -> argparse.Namespace: parser.add_argument( "--mail-domain", required=True, help="Zone carrying MX/SPF/DMARC" ) + parser.add_argument( + "--dmarc-rua", + required=True, + help="Mailbox the DMARC record must name as aggregate report address (rua)", + ) parser.add_argument( "--dkim-selector", default="", help="Selector published by the server" ) diff --git a/roles/web-app-stalwart/meta/services.yml b/roles/web-app-stalwart/meta/services.yml index 25892c1ffb..0734303a85 100644 --- a/roles/web-app-stalwart/meta/services.yml +++ b/roles/web-app-stalwart/meta/services.yml @@ -43,7 +43,7 @@ stalwart: placement: manager image: stalwartlabs/stalwart version: "v1.0.1" - webui_version: "v2.0.2" + webui_version: "v2.0.3" update: key: webui_version type: git_tags @@ -58,6 +58,8 @@ stalwart: # nocheck: min-storage-headroom Reason: the mail store (maildir blobs, FTS index, queue) lives in this service's volumes and dwarfs the image transfer size min_storage: 20GB domain: "{{ lookup('email').domain }}" + dmarc: + rua_user: administrator ports: local: http: 8095 diff --git a/roles/web-app-stalwart/tasks/09_dns-records.yml b/roles/web-app-stalwart/tasks/09_dns-records.yml index b461e9c02a..36a9ea4775 100644 --- a/roles/web-app-stalwart/tasks/09_dns-records.yml +++ b/roles/web-app-stalwart/tasks/09_dns-records.yml @@ -1,4 +1,14 @@ --- +- name: "βœ… Assert the DMARC aggregate report address reaches a Stalwart mailbox" + ansible.builtin.assert: + that: + - "'mailbox' in lookup('users', STALWART_DMARC_RUA_USER).accounts" + fail_msg: >- + services.stalwart.dmarc.rua_user '{{ STALWART_DMARC_RUA_USER }}' carries + no mailbox account, so Stalwart provisions no recipient for + {{ STALWART_DMARC_RUA }} and every DMARC aggregate report bounces. + quiet: true + - name: "πŸ”§ DNS (Cloudflare) for Stalwart" include_role: name: sys-dns-cloudflare-records @@ -35,7 +45,7 @@ zone: "{{ STALWART_DOMAIN_DNS_ZONE }}" name: "_dmarc.{{ STALWART_DOMAIN_DNS_ZONE }}" solo: true - value: '"v=DMARC1; p=reject; ruf=mailto:{{ STALWART_DMARC_RUF }}; adkim=s; aspf=s"' + value: '"v=DMARC1; p=reject; rua=mailto:{{ STALWART_DMARC_RUA }}; ruf=mailto:{{ STALWART_DMARC_RUF }}; adkim=s; aspf=s"' - type: TXT zone: "{{ STALWART_DOMAIN_DNS_ZONE }}" name: "{{ stalwart_dkim_selector }}._domainkey.{{ STALWART_DOMAIN_DNS_ZONE }}" diff --git a/roles/web-app-stalwart/tasks/13_production_facts.yml b/roles/web-app-stalwart/tasks/13_production_facts.yml index e57495248c..c9ba028b97 100644 --- a/roles/web-app-stalwart/tasks/13_production_facts.yml +++ b/roles/web-app-stalwart/tasks/13_production_facts.yml @@ -9,6 +9,7 @@ {{ [ role_path, 'files/python/production_facts.py' ] | path_join }} --mail-host {{ STALWART_PRODUCTION_HOST | quote }} --mail-domain {{ STALWART_DOMAIN | quote }} + --dmarc-rua {{ STALWART_DMARC_RUA | quote }} {{ ('--dkim-selector ' ~ (stalwart_dkim_selector | quote)) if stalwart_dkim_selector is defined else '' }} {{ ('--resolver ' ~ (STALWART_PRODUCTION_RESOLVER | quote)) diff --git a/roles/web-app-stalwart/vars/main.yml b/roles/web-app-stalwart/vars/main.yml index d7a841b0e5..4057e736d7 100644 --- a/roles/web-app-stalwart/vars/main.yml +++ b/roles/web-app-stalwart/vars/main.yml @@ -84,6 +84,8 @@ STALWART_ADMIN_PASSWORD: "{{ lookup('users', 'stalwartadmin').password }}" STALWART_USERS: "{{ lookup('stalwart_users') }}" STALWART_DMARC_RUF: "{{ lookup('config', application_id, 'users.administrator.email') }}" +STALWART_DMARC_RUA_USER: "{{ lookup('config', application_id, 'services.stalwart.dmarc.rua_user') }}" +STALWART_DMARC_RUA: "{{ lookup('users', STALWART_DMARC_RUA_USER).username }}@{{ STALWART_DOMAIN }}" STALWART_BOT_APP_PASSWORD_DESCRIPTION: "Infinito.Nexus submission" STALWART_BOT_APP_PASSWORD_RETIRED_DESCRIPTION: "Infinito.Nexus submission, retired" diff --git a/roles/web-app-wazuh/meta/services.yml b/roles/web-app-wazuh/meta/services.yml index d38e9054c9..224974902e 100644 --- a/roles/web-app-wazuh/meta/services.yml +++ b/roles/web-app-wazuh/meta/services.yml @@ -60,7 +60,7 @@ wazuh: lifecycle: beta certs_generator: image: wazuh/wazuh-certs-generator - version: "0.0.4" + version: "0.0.5" name: wazuh-certs-generator cpus: "0.2" mem_reservation: 64m diff --git a/scripts/git/assert/main_merged.sh b/scripts/git/assert/main_merged.sh index bb63e43b46..ac7471884d 100755 --- a/scripts/git/assert/main_merged.sh +++ b/scripts/git/assert/main_merged.sh @@ -4,23 +4,37 @@ # from the current tip, so a branch can never be pushed while it lags main. # # Env overrides: INFINITO_MAIN_REMOTE (default origin), INFINITO_MAIN_BRANCH -# (default main). +# (default main), INFINITO_MAIN_COMMIT (unset: check the live branch tip; set: +# fetch and check this full commit SHA of that branch instead, e.g. the base +# SHA a CI event carries). set -euo pipefail remote="${INFINITO_MAIN_REMOTE:-origin}" # nocheck: git maintainer tooling knob, not a deployment env key branch="${INFINITO_MAIN_BRANCH:-main}" # nocheck: git maintainer tooling knob, not a deployment env key +if [[ -v INFINITO_MAIN_COMMIT ]]; then + target="${INFINITO_MAIN_COMMIT}" # nocheck: git maintainer tooling knob, not a deployment env key + if [[ ! "$target" =~ ^[0-9a-f]{40}([0-9a-f]{24})?$ ]]; then + echo "❌ assert-main-merged: INFINITO_MAIN_COMMIT must be a full commit SHA, got '${target}'." >&2 + exit 2 + fi + label="${remote}/${branch}@${target}" +else + target="$branch" + label="${remote}/${branch}" +fi + cd "$(git rev-parse --show-toplevel)" -echo "assert-main-merged: fetching ${remote}/${branch} ..." >&2 -git fetch --quiet "$remote" "$branch" +echo "assert-main-merged: fetching ${label} ..." >&2 +git fetch --quiet "$remote" "$target" if git merge-base --is-ancestor FETCH_HEAD HEAD; then - echo "βœ… assert-main-merged: ${remote}/${branch} is fully merged into HEAD." >&2 + echo "βœ… assert-main-merged: ${label} is fully merged into HEAD." >&2 exit 0 fi behind="$(git rev-list --count HEAD..FETCH_HEAD)" -echo "❌ assert-main-merged: ${remote}/${branch} has ${behind} commit(s) not merged into HEAD." >&2 +echo "❌ assert-main-merged: ${label} has ${behind} commit(s) not merged into HEAD." >&2 echo " Merge upstream main first, e.g.: git pull ${remote} ${branch}" >&2 exit 1 diff --git a/scripts/lint/autoformat.sh b/scripts/lint/autoformat.sh index 907e51eaee..1a4fa210a3 100755 --- a/scripts/lint/autoformat.sh +++ b/scripts/lint/autoformat.sh @@ -139,8 +139,8 @@ run_mbake() { return 0 fi local rc=0 - mbake format Makefile >/dev/null 2>&1 || rc=$? - [[ $rc -eq 0 ]] && { mbake format Makefile >/dev/null 2>&1 || rc=$?; } + mbake format --config .bake.toml Makefile >/dev/null 2>&1 || rc=$? + [[ $rc -eq 0 ]] && { mbake format --config .bake.toml Makefile >/dev/null 2>&1 || rc=$?; } if [[ $rc -eq 0 ]]; then write_status mbake OK else diff --git a/scripts/lint/makefile.sh b/scripts/lint/makefile.sh index 84e3b27f7e..07819375df 100755 --- a/scripts/lint/makefile.sh +++ b/scripts/lint/makefile.sh @@ -17,4 +17,4 @@ if ! command -v mbake >/dev/null 2>&1; then exit 127 fi -mbake format --check Makefile +mbake format --check --config .bake.toml Makefile diff --git a/scripts/system/worktree/up.sh b/scripts/system/worktree/up.sh index f97a72aab2..ab71eaf4f3 100755 --- a/scripts/system/worktree/up.sh +++ b/scripts/system/worktree/up.sh @@ -53,7 +53,7 @@ git worktree add "${path}" "${branch}" git_common_dir="$(git rev-parse --path-format=absolute --git-common-dir)" -lab_octet="$((244 + slot))" +lab_prefix="10.160.${slot}" echo ">>> Pinning slot ${slot} in ${path}/custom.env" cat >"${path}/custom.env" <&2 - exit 1 + echo "==> INFINITO_INSTANCE=${INFINITO_INSTANCE} leaves no pinned node band in ${cache_prefix}.0/24; Docker assigns the node addresses from ${CACHE_NET}'s pool" >&2 + pin_nodes=false fi for node in "${MGR}" "${WRK1}" "${WRK2}" "${NFS_SERVER}" "${BACKUP_NODE}"; do - if ! connect_err="$(docker network connect --ip "${cache_prefix}.${node_octet}" "${CACHE_NET}" "${node}" 2>&1)"; then + connect_args=() + if [ "${pin_nodes}" = true ]; then + connect_args=(--ip "${cache_prefix}.${node_octet}") + fi + if ! connect_err="$(docker network connect "${connect_args[@]}" "${CACHE_NET}" "${node}" 2>&1)"; then case "${connect_err}" in *"already exists in network"* | *"already attached to network"*) echo "==> ${node} already on ${CACHE_NET}; keeping its current address" >&2 ;; *) - echo "FAILURE: cannot pin ${node} to ${cache_prefix}.${node_octet} on ${CACHE_NET}: ${connect_err}" >&2 + echo "FAILURE: cannot attach ${node} to ${CACHE_NET} (${connect_args[*]:-pool address}): ${connect_err}" >&2 exit 1 ;; esac diff --git a/tests/lint/filesystem/env/test_worktree_swarm_lab_subnet.py b/tests/lint/filesystem/env/test_worktree_swarm_lab_subnet.py new file mode 100644 index 0000000000..7395b5f012 --- /dev/null +++ b/tests/lint/filesystem/env/test_worktree_swarm_lab_subnet.py @@ -0,0 +1,88 @@ +"""Every worktree slot must pin a valid swarm lab subnet of its own. + +`scripts/system/worktree/up.sh` derives `INFINITO_SWARM_LAB_SUBNET` from the +slot. A derivation that overflows an octet yields an address Docker rejects at +network creation, and one that lands in a reserved range breaks the swarm at +runtime: inside NETWORK_TOR_VIRTUAL_CIDR svc-net-tor redirects every TCP +connection to Tor's TransPort, so the nodes cannot reach each other. +""" + +from __future__ import annotations + +import ipaddress +import re +import unittest + +from utils.cache.files import read_text +from utils.cache.yaml import load_yaml_any +from utils.env.parser import parse_static_env + +from . import PROJECT_ROOT + +_UP_SH = PROJECT_ROOT / "scripts/system/worktree/up.sh" +_NETWORKS = PROJECT_ROOT / "group_vars/all/08_networks.yml" +_MAX_SLOT_RE = re.compile(r"^max_slot=(?P\d+)$", re.MULTILINE) +_LAB_PREFIX_RE = re.compile(r'^lab_prefix="(?P