2393 Commits
Author SHA1 Message Date
greg 179620b163 Merge pull request 'migrate_node_to_cinc: don't let needrestart hang the migration' (#719) from fix/migrate-cinc-noninteractive into master
Reviewed-on: #719
Reviewed-by: Greg <greg@kosmos.org>
2026-12-04 13:23:43 +00:00
greg 0fd69cc5e5 Merge pull request 'Mitigate distributed Gitea filter-permutation crawl' (#720) from chore/dos_mitigation into master
Reviewed-on: #720
Reviewed-by: Greg <greg@kosmos.org>
2026-12-04 13:22:03 +00:00
raucao ac639dcbe9 Scope the Gitea filter gate to location / to avoid a subrequest cycle
kosmos/actions: Required labels / Required labels (pull_request) Successful in 12s
The gate was a server-level rewrite_by_lua_block. Server-level rewrite_by_lua
is inherited by every location, including the internal /_gitea_signed_in probe.
Because $request_uri (which drives $filter_perm) is the *original* request URI
and is inherited by subrequests, the probe subrequest re-entered the gate and
captured "/_gitea_signed_in" again -> "lua subrequests cycle" and
"failed to issue subrequest: -1", i.e. a 500 for cookie-bearing clients.

Move the block into "location /" so the probe location no longer inherits it.
$filter_key is still set before the server-level limit_req (rewrite phase runs
before preaccess), so the behaviour is unchanged for real requests.

Verified on draco/fornax: nginx -t ok, zero cycle errors, anonymous filter
requests 429, plain pages 200.
2026-12-04 17:00:14 +04:00
raucao 246c751f4c Hard-ban CogBot at the Gitea edge
CogBot (cognition.ai) was the second-largest source of the current crawler
load, walking /src/branch/ and /commits/branch/ tree routes with a declared
User-Agent. Add it to the credentials/gitea bot_filter deny_user_agents list,
so the edge returns 403 and robots.txt disallows it.

Data bag re-encrypted with the configured secret; all attributes remain
encrypted (aes-256-gcm v3).
2026-12-04 17:00:14 +04:00
raucao 7d620d4d03 Mitigate distributed Gitea filter-permutation crawl
Gitea is again CPU-saturated by crawler traffic. The dominant source is a
distributed crawl of combinatorial issue/pull filter URLs, e.g.
/kosmos/chef/issues?assignee=0&labels=...&milestone=0&poster=0&project=0.
It spreads ~1 request across tens of thousands of client IPs with spoofed
browser User-Agents and no referer, so the existing per-IP zones (bots,
expensive) never fill; the last hour saw ~45k permutation requests from
~43k distinct IPs, and the resulting render/DB load shows up as 499s and
slow page loads.

- Detect the filter-permutation list pages ($filter_perm, anchored so API
  paths never match) and cap the anonymous ones with a single non-IP
  "filters" bucket (1r/s, burst 5).
- Exempt authenticated sessions: rewrite_by_lua_block validates the
  i_like_gitea cookie once against a signed-in-only route
  (/_gitea_signed_in -> /user/settings; 200 signed in, 303 anonymous) and
  caches the result per session. Cookie presence alone is not enough, since
  Gitea issues it to anonymous visitors too. Probe failures fail open so a
  flaky Gitea cannot throttle a signed-in user.
- Skip the probe for rate-limited bot UAs and give the internal probe its
  own empty-key limit_req zone, so the subrequest cannot set
  r->main->limit_req_set and disable the main request's limits.
- Disallow the combinatorial tree-browse routes in robots.txt
  (/*/src/branch/, /*/commits/branch/, and the tag variants).

Reviewed and signed off by the review agent. Bump cookbook to 0.3.11.

The CogBot denial is configured in the encrypted credentials/gitea data bag
(bot_filter), which is managed by Ops.
2026-12-04 17:00:14 +04:00
raucao 09343cde51 migrate_node_to_cinc: don't let needrestart hang the migration
kosmos/actions: Required labels / Required labels (pull_request) Successful in 11s
The script runs over SSH with no TTY, but needrestart's apt hook runs in
its default interactive mode (via debconf) after installing or removing
packages, so it blocks forever waiting on a prompt. That stalled the
garage-14 migration during `apt-get remove chef`.

Export DEBIAN_FRONTEND=noninteractive and NEEDRESTART_SUSPEND=1 inside the
generated remote script so no invocation flags are needed. The needrestart
hook exits early ("needrestart is suspended") and dpkg/apt can't prompt.
2026-12-04 15:42:56 +04:00
raucao b431c97129 Merge pull request 'Restart Garage automatically, and alert when a Garage node is down' (#718) from chore/garage_systemd into master
Reviewed-on: #718
Reviewed-by: Greg <greg@kosmos.org>
2026-12-04 11:30:53 +00:00
raucao 7d2ba8bea5 Update nodes submodule after Cinc migration and garage converge 2026-12-04 14:34:20 +04:00
raucao f048e0d5ee Alert when a Garage node is down
Prometheus already scrapes Garage (job="garage", port 3903) but there was
no alert on up{job="garage"}, so the 2026-12-04 garage-15 outage went
unnoticed for ~1h40m. Add a critical GarageDown alert and ship it via the
cookbook.
2026-12-04 13:20:35 +04:00
raucao 887f5e271e Restart the Garage service automatically after crashes
The garage.service unit had no restart policy, so a service that died
stayed dead until it was restarted by hand. On 2026-12-04 the unit on
garage-15 (10.1.1.82) was killed by the kernel OOM killer after its block
resync loop pushed memory over the 1.9GB VM's limit; systemd left it down
for ~1h40m and the cluster saw the node as disconnected the whole time.

Set Restart=always with a 30s backoff and disable the start rate limit
(StartLimitIntervalSec=0) so systemd keeps retrying instead of giving up
after a few rapid failures. Bump the cookbook to 0.2.0 and extend the
InSpec test to assert the restart policy.
2026-12-04 13:20:32 +04:00
raucao 3fbaf32156 Merge pull request 'Upgrade Mastodon to 4.7.7' (#717) from chore/upgrade_mastodon into master
Reviewed-on: #717
2026-12-02 18:36:33 +00:00
raucao 7543f0decb Update chef-nodes submodule 2026-12-02 22:34:50 +04:00
raucao a5a5cda5fc Merge origin/master into chore/upgrade_mastodon
# Conflicts:
#	site-cookbooks/kosmos-mastodon/attributes/default.rb
2026-12-02 22:28:45 +04:00
raucao 2f8f2e7e2f Upgrade Mastodon to 4.7.7
Bump the runtime Ruby to 4.0.10 (and the ruby-build definitions to
v20261119, the first release that defines it), matching upstream's
updated default Ruby for the 4.7.6 security release.

Strip client-supplied Forwarded headers in the Mastodon nginx config,
mirroring the upstream 4.7.5 hardening.
2026-12-02 22:00:14 +04:00
raucao 1ecf29e676 Merge pull request 'Upgrade Gitea to 28.4.0 and Actions runner to 6.1.0' (#716) from chore/upgrade_gitea-runner into master
Reviewed-on: #716
2026-12-02 11:00:55 +00:00
raucao 957433a0b9 Shorten kosmos_gitea 0.3.10 changelog entry 2026-12-02 14:56:25 +04:00
raucao 8dbc01a938 Merge remote-tracking branch 'origin/master' into chore/upgrade_gitea-runner
# Conflicts:
#	site-cookbooks/kosmos_gitea/CHANGELOG.md
#	site-cookbooks/kosmos_gitea/metadata.rb
2026-12-02 14:21:15 +04:00
raucao 3056df33f7 Upgrade Gitea to 28.4.0 and Actions runner to 6.1.0
Gitea 28.4.0 is a maintenance/security release with no app.ini changes.

Runner 6.0.0 removed the builtin:checkout action; map it to
actions/checkout@v6 via runner.action_replacements so existing workflows
keep working. 6.1.0 runs JavaScript actions on a Node.js 24 the runner
downloads and mounts into jobs.
2026-12-02 14:20:34 +04:00
raucao a2a8748f20 Merge pull request 'Manage the RSKj node config so upgrades can't mis-network nodes' (#715) from fix/rsk-manage-node-config into master
Reviewed-on: #715
2026-11-30 06:00:09 +00:00
raucao 1dcc1c538c Manage the RSKj node config so upgrades can't mis-network nodes
The rskj package owns /etc/rsk/node.conf: its postinst re-asks the
`shared/config` debconf question on every configure and re-points node.conf at
the selected network's shipped config. That debconf state is not reliably
preserved across upgrades. After the plain 9.0.1 -> 9.0.5 upgrade, the question
fell back to the template default ("mainnet"), the service was restarted, and
rsk-testnet-6 started syncing the mainnet chain from genesis into a fresh
database while its real testnet data sat idle.

Stop relying on debconf: template our own node config (with the RPC bind/CORS
settings the openresty proxies need) and manage the node.conf symlink from Chef,
after the package has been configured. The restart then happens with the correct
config, and a package upgrade can no longer flip the network.

Bump the cookbook to 0.6.1 and extend the InSpec test to assert the managed
config and the symlink target.
2026-11-30 09:56:33 +04:00
raucao c89c0b9f8a Merge pull request 'Upgrade RSKj to 9.0.5' (#714) from chore/upgrade_rsk into master
Reviewed-on: #714
2026-11-28 17:14:30 +00:00
raucao a32c97a0e9 Upgrade RSKj to 9.0.5
VETIVER-9.0.5 is a security release that mitigates CVE-2026-114938 ("Java4Shell") in the OpenJDK Base64 decoder. The 9.0.5 JAR has no code changes: protection comes from the new systemd unit that disables the vulnerable intrinsic, together with the OpenJDK 17 update from USN-9155-1 (covered by unattended-upgrades).

The rskj package upgrade does not restart the node itself, so restart rsk explicitly when the pinned package version changes; otherwise the new unit and JAR are not picked up.

Bump the cookbook to 0.6.0 and update the InSpec assertion, adding a check that the unit carries -XX:-UseBASE64Intrinsics.
2026-11-28 21:11:31 +04:00
raucao 4c780808db Merge pull request 'Scale akkounts Solid Queue workers and guard unit memory' (#713) from chore/akkounts_workers into master
Reviewed-on: #713
2026-11-27 13:14:05 +00:00
raucao a39383940f Bump chef-nodes submodule for akkounts-2 kernel refresh
The akkounts-2 node file gained the 6.8.0-151-generic kernel version after
its reboot during the VM resize.
2026-11-27 17:09:30 +04:00
raucao 05d58872fe Scale akkounts Solid Queue workers and guard unit memory
Size the akkounts background workers for the 4 GB / 4 vCPU VM:

* JOB_CONCURRENCY=6 scales the `default,nostr` worker group.
* NOSTR_CONNECT_THREADS=24 and NOSTR_RPC_THREADS=4 size the separate
  nostr_connect (long-blocking listeners) and nostr_rpc (signing) pools.
* DB_POOL=24 keeps the pool >= the largest worker thread count.

Also cap the unit with MemoryHigh/MemoryMax, and restart the service when
the unit body changes since it now carries this configuration.
2026-11-27 17:09:30 +04:00
greg 3a3d23ea09 Merge pull request 'Disable HTTP/2 on OpenResty/nginx proxies (CVE-2026-123633, CVE-2026-123007)' (#708) from security/disable-http2-nginx-cves into master
Reviewed-on: #708
Reviewed-by: Greg <greg@kosmos.org>
2026-11-23 17:52:46 +00:00
raucao 647899e492 Merge pull request 'Upgrade akkounts Ruby, update Sentry and Blossom configs' (#712) from security/akkounts-ruby-3.3.14 into master
Reviewed-on: #712
2026-11-23 17:42:42 +00:00
raucao 0418c4299a Update nodes
akkounts-2 and bitcoin-2 record the kosmos_zerotier ohai plugin state.
2026-11-23 21:37:12 +04:00
raucao bd0fb5f634 akkounts: Configure the Blossom server URL in production
The app reads NOSTR_BLOSSOM_SERVER_URL (used for the Nostr profile media
editor). Default it to nil like the other nostr attributes and set it to
https://blossom.kosmos.org in the production environment.
2026-11-23 21:37:12 +04:00
raucao f2fb541f05 akkounts: Disable Sentry while sentry.kosmos.local is down
The Sentry host is unreachable, so every captured event ends in a TCP timeout
and a Sentry::ExternalError stack trace in the app log (thousands per day).
Leaving SENTRY_DSN out of the app environment makes
config/initializers/sentry.rb skip Sentry.init entirely, so the app stops
contacting it instead of failing on every event.

Temporary: uncomment the line once the Sentry host is back up.
2026-11-23 21:37:12 +04:00
raucao e4f3d687fd akkounts: Upgrade Ruby to 3.3.14
3.3.12 is affected by the seven Regexp and String case conversion
vulnerabilities announced on 2026-11-18, several of which allow remote code
execution. 3.3.14 is the fixed release on this branch line.

ruby-build is bumped to v20261119, which adds the 3.3.14 definition (the
previous v20260701 predates the release and cannot build it).
2026-11-23 21:37:12 +04:00
raucao 3c56eff6a4 Merge pull request 'Update Mastodon to 4.7.6' (#710) from chore/mastodon_security_update into master
Reviewed-on: #710
2026-11-23 17:26:59 +00:00
greg 751783d0cb Add back accidentally deleted Ruby version file 2026-11-20 17:17:15 +01:00
greg 2f78b9eacf Update nodes submodule 2026-11-20 17:12:43 +01:00
greg e66ff99e8d Update Mastodon to 4.7.6
This is a security update:
https://github.com/mastodon/mastodon/releases/tag/v4.7.6

Also updated Ruby to 4.0.10 as this was part of the fix for security
issues.

This is running on mastodon-4.

Fixes #709
2026-11-20 17:07:09 +01:00
raucao ae3056f23f Disable HTTP/2 on OpenResty/nginx proxies
The November 2026 nginx security release fixes two unauthenticated RCE
flaws reachable over HTTP/2: CVE-2026-123633 (HTTP/2 use-after-free,
vulnerable 1.19.7-1.31.8) and CVE-2026-123007 (HTTP/2 flow control
memory corruption, vulnerable 1.9.5-1.31.8). Fixes are in nginx 1.30.7
(stable) and 1.31.9 (mainline).

Neither of our proxies can be patched yet: OpenResty 1.25.3.1 runs an
nginx 1.25.3 core, and the newest OpenResty build in the apt repo
(1.31.8.1) still bundles nginx 1.31.8. The nginx.org apt repo has no
fixed package for Ubuntu focal either.

As a temporary mitigation, drop the http2 parameter from every listen
directive so the proxies no longer negotiate HTTP/2. Re-enable with
"http2 on;" in the server blocks once OpenResty ships an nginx 1.31.9
(or newer) core.
2026-11-19 00:16:03 +04:00
raucao eea6691881 Merge pull request 'Add public nostr submission relay and approved-content sync' (#705) from feature/nostr_submission_relay into master
Reviewed-on: #705
2026-11-18 11:09:47 +00:00
raucao f50abc655a Update nodes 2026-11-18 15:08:34 +04:00
raucao 9585dd5ba7 Merge remote-tracking branch 'origin/master' into feature/nostr_submission_relay 2026-11-18 14:31:20 +04:00
raucao 1b1e2fbb3d Runbook: document the deployed state and fix the NIP-11 check
The submission relay and both promotion paths are live in production, so the
runbook no longer claims that nothing has been deployed. Reframe the deployment
order and pre-go-live checks as completed, and fix the verification command:
strfry only returns the NIP-11 JSON with an Accept header, so the old
curl | jq pipeline could never work.
2026-11-18 14:31:00 +04:00
raucao ab60ae1ea8 Set nofiles in the approved-sync config
strfry raises RLIMIT_NOFILE to relay.nofiles at startup and exits if that exceeds the process hard limit. The sync config omitted nofiles, so strfry used its compiled-in default (1000000) while the systemd default here is 524288, and strfry-sync.service failed to start with:

  Unable to set NOFILES limit to 1000000, exceeds max of 524288

Set nofiles explicitly (from the production relay config, falling back to 524288, as the production template does) and extend the regression test to assert it.
2026-11-18 01:19:09 +04:00
raucao 128e9ce585 Add chef-managed member bridge (strfry router, LDAP-only)
Add kosmos_strfry::member_bridge: a strfry router stream group that subscribes to the local submission relay (ws://localhost:7778) and writes member-authored events into the production database. dir = "down" keeps it strictly one-way, and pluginDown is the new LDAP-only policy (ldap-only-policy.ts) from akkounts extras/strfry, so membership is decided per event by LDAP with no member list.

The two promotion paths (approved_sync, member_bridge) are enabled as role overrides in role[strfry_submission], not in the production environment config.

Also add a render regression test for the router config and update the runbook.

Refs raucao/marco#97.
2026-11-18 00:32:05 +04:00
raucao 366b308c1d Update nodes 2026-11-17 23:29:32 +04:00
raucao 5913bca004 Document the live DNS CNAME and the verified LMDB concurrency gate
submit.nostr.kosmos.org is now a CNAME to lb.kosmos.org, so the "add an
A/AAAA record" step is replaced by "verify the CNAME resolves". Also record
the LMDB concurrency test result: a strfry sync ran against the same LMDB
while the live relay served 13/13 subscriptions on the nuc's :7777 mirror.
2026-11-17 19:25:36 +04:00
raucao 511a512908 Add public nostr submission relay and approved-content sync
Add a second strfry instance and the machinery to promote moderated content
into the members relay, for raucao/marco#97.

New role[strfry_submission] and the kosmos_strfry_submission cookbook run a
separate relay (port 7778, own DB capped at a 4 GiB mapsize) fronted at
submit.nostr.kosmos.org, using the open submission write policy from akkounts
extras/strfry. It is deliberately not role[strfry], so nginx never adds it to
the members relay's _strfry upstream.

Add kosmos_strfry::approved_sync: a dedicated fail-closed sync config plus a
5-minute timer that pulls moderator-approved content from the nuc staging relay
into the members relay. The sync command URL and STAGING_RELAY_URL come from a
single attribute so the policy's byte-exact source match cannot drift.

Also add a role-scoped Node 22 install (the global Node attribute is
untouched), a proxy-scoped firewall rule, an nginx site, a runbook, and a
render regression check for the sync template.

Deployment is gated: approved_sync.enabled defaults to false, and the akkounts
policy files must be on the live branch before converging.
2026-11-17 14:23:03 +04:00
raucao b5d3f35596 Merge pull request 'liquor_cabinet: preload jemalloc into the Rainbows workers' (#704) from chore/liquor_cabinet into master
Reviewed-on: #704
2026-11-14 06:26:35 +00:00
raucao afc0453166 liquor_cabinet: preload jemalloc into the Rainbows workers
The Rainbows master and workers run on glibc malloc, which retains and
fragments heap in long-lived workers. Preload jemalloc (libjemalloc2) so the
aged per-worker RSS stays flat instead of growing.

Also restart liquor-cabinet.service when its systemd unit changes:
systemd_unit only reloads the daemon, so an env-only change would not take
effect until the next deploy or reboot.

Cookbook version 0.3.0 -> 0.4.0.
2026-11-14 10:24:40 +04:00
raucao 88ef468015 Update nodes 2026-11-14 10:24:40 +04:00
greg ea04af784e Merge pull request 'Move Gitea bot controls into encrypted data bag' (#703) from gitea-bot-filter-data-bag into master
Reviewed-on: #703
Reviewed-by: Greg <greg@kosmos.org>
2026-11-13 08:39:08 +00:00
raucao 207f0309f1 Move Gitea bot controls into encrypted data bag
Broaden the edge bot blocking and move the bot/IP lists out of the
cookbook so they are no longer published in the public repository.

- rate_limits.conf and robots.txt are now rendered from the encrypted
  credentials/gitea data bag (bot_filter): rate-limited crawler names,
  hard-banned user agents and denied networks.
- Add several AI crawlers to the rate-limited set, tighten the bots zone
  to 60r/m so the limit actually engages, hard-block a datacenter scraper
  network and disallow combinatorial commit-browsing routes in robots.txt.
- Rate values and the expensive-route/robots route patterns stay static.
- Bump cookbook to 0.3.9; include updated nodes submodule ref.
2026-11-13 11:08:04 +04:00