474 Commits
Author SHA1 Message Date
Mike Dalessio 945c22f141 Merge pull request #447 from basecamp/card-5441-blank-bot-token
Harden bot key authentication against a blank token
2026-11-20 10:00:00 -05:00
Mike Dalessio 00373e1a30 Reject a bot key with a blank token
`User.authenticate_bot` searched with a missing or empty token, so a key
holding only a bot's id matched that bot if its `bot_token` was `NULL`,
and a key with an empty token segment matched a `bot_token` of `""`.
Return `nil` when the token is blank.
2026-11-19 15:33:10 -05:00
Mike Dalessio 5196f5d6b8 Merge pull request #444 from basecamp/card-10519586476-ruby-memory-safety
Upgrade runtime to Ruby 4.0.10
2026-11-18 22:32:58 -05:00
Mike Dalessio f6637892a5 Upgrade runtime to Ruby 4.0.10
Ruby 4.0.10 fixes memory-safety bugs in Regexp and in String case
conversion. Move `.ruby-version`, `Dockerfile` and `Dockerfile-export`
to it, and bump `ruby/setup-ruby` to v1.342.0, the first release that
installs 4.0.10.

ref: https://www.ruby-lang.org/en/news/2026/11/18/multiple-vulnerabilities-in-regexp-and-string/
2026-11-18 22:10:32 -05:00
Marcello CostagliolaandClaude Opus 5.5 f95e5d3d2e Update Thruster to 0.1.27 (#360)
Thruster 0.1.24 and 0.1.27 fix two published advisories in its HTTP cache:
GHSA-m592-hhcw-jh6f, "cache-key collisions allow cross-request response
substitution", and GHSA-g74j-pv38-jj8g, "HTTP cache ignores later Vary
field lines and repeated request header values". Campfire's public
responses go through that cache: avatars, the account logo, files and
assets.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 15:50:54 -08:00
Mike Dalessio 7b809885a1 Merge pull request #437 from basecamp/puma-8-0-3
Upgrade puma to 8.0.3
2026-11-13 16:32:41 -05:00
Mike Dalessio 6fb1b4c35a Upgrade puma to 8.0.3
Puma 8.0.2 was affected by security advisories in its reactor timeouts,
TLS write timeouts, graceful shutdown, bind URL parsing and `pumactl`.
Upgrade to 8.0.3, which fixes them.

ref: https://github.com/puma/puma/releases/tag/v8.0.3
2026-11-13 16:02:38 -05:00
Mike Dalessio fb0d34ec10 Check the release tag through gh, and stop when the check fails
The tag check ignored a failed `git ls-remote` and continued as if the
tag did not exist, and it asked `origin`, which can differ from the
repository `gh` releases to.

Look the tag up with `gh api`, abort when that call fails, and accept
only a version of dot-separated numbers.

A 1.5.x release still moves `latest` on both registries. That is
harmless until 1.6 ships, so it is left for then.
2026-11-06 15:24:35 -05:00
Mike Dalessio 3a3579264d Build the release image from the committed tree
The image build used the working tree as its context, so untracked files
such as `.ruby-lsp/` shipped in the registry.once.com image.

Extract `git archive` of `HEAD` once and build both the image and the
source ZIP from it. Say in the uncommitted-changes prompt that those
changes are not released.
2026-11-06 15:24:35 -05:00
Mike Dalessio 86909e302d Export the release ZIP from the committed tree
The export image copied the working tree, so untracked files such as
`.ruby-lsp/` landed in the published ZIP.

Build it from `git archive` of `HEAD`, extracted to a directory so that
`.dockerignore` still applies.
2026-11-06 15:14:00 -05:00
Mike Dalessio d124120690 Tag the release at the commit being released
`bin/release` let `gh release create` make the tag, and `gh` makes a
new tag at the head of the default branch. Running it on `release-1.5`
tagged `main` as v1.5.7, so the GitHub release and the GHCR images
shipped `main`.

Pass `HEAD` as `--target`, and abort when the tag already exists on
origin at a different commit.
2026-11-06 15:14:00 -05:00
Mike Dalessio 86dd525e18 Update Rails to main at 8b06b0eb (#423)
* Upgrade Rails to 8b06b0eb

Rails at 8b06b0eb includes today's security release, rails/rails@6782df4a.

* Update addressable to 2.9.2

addressable 2.9.0 had a ReDoS in URI templates with several exploded variables, which failed the gem audit.

ref: https://github.com/sporkmonger/addressable/security/advisories/GHSA-4w5q-wg7v-w6gp

* Update rack to 3.2.8

rack 3.2.7 had four advisories, including a multipart parser memory exhaustion, which failed the gem audit.

ref: https://github.com/rack/rack/security/advisories/GHSA-5v64-555j-wjxm

* Ignore resque-web advisories in the gem audit

Four resque 2.7 advisories are in resque-web, which Campfire doesn't mount. They are fixed only in resque 3.

* Document the Forwarded header check for proxied installs

Rails now refuses a request whose Forwarded and X-Forwarded-For headers name different clients. Behind a proxy that adds Forwarded from a public address, that breaks every signed-in page. Say how to avoid it.

* Drop the Forwarded header note from the self-hosting guide

Thruster deletes a client's Forwarded header before proxying, so the header conflict the note described can't reach Campfire in the documented container.

This reverts commit 81ed465095.
2026-11-04 14:38:28 -05:00
Mike Dalessio a05ee90897 dep: update rails-html-sanitizer, loofah, and nokogiri (#421)
loofah 2.25.2 let a live CSS `url()` through `style` attributes, and
its HTML5 output could become new markup when a browser parsed it again.

Update rails-html-sanitizer to 1.7.2, loofah to 2.25.3, and nokogiri
to 1.19.5.

ref: https://github.com/rails/rails-html-sanitizer/releases/tag/v1.7.2
ref: https://github.com/flavorjones/loofah/releases/tag/v2.25.3
ref: https://github.com/sparklemotion/nokogiri/releases/tag/v1.19.5
2026-11-02 08:51:52 -05:00
Mike Dalessio ca9b963961 dep: update sqlite3 and crass (#418)
* dep: update sqlite3 to 2.10.2

sqlite3 2.9.6 truncated SQL strings and bound values longer than
`INT_MAX` bytes, and could crash or deadlock when a callback raised.

ref: https://github.com/sparklemotion/sqlite3-ruby/releases/tag/v2.10.2
ref: https://github.com/sparklemotion/sqlite3-ruby/security/advisories/GHSA-4fqr-96q8-xrfx

* dep: update crass to 1.0.8

crass 1.0.7 tokenized bad URLs incorrectly, which allowed a CSS
sanitizer bypass.

ref: https://github.com/rgrove/crass/security/advisories/GHSA-pq4g-8rxf-4g29
2026-10-26 18:24:58 -04:00
Jeremy Daer 59d2164b11 Merge pull request #379 from basecamp/check-trusted-ca-certificates
Check the trusted CA certificates at build time
2026-10-24 12:05:52 -07:00
Mike Dalessio eccb2d6c91 Upgrade runtime to Ruby 4.0.9 (#381)
* Upgrade runtime to Ruby 4.0.9

Ruby 4.0.9 fixes the Regexp compilation bug behind GitLab's
CVE-2026-110264. Move `.ruby-version`, `Dockerfile` and
`Dockerfile-export` to it.

ref: https://www.ruby-lang.org/en/news/2026/10/23/ruby-4-0-9-released/

* Bump setup-ruby to v1.334.0 for Ruby 4.0.9

The pinned v1.327.0 and v1.324.0 did not know Ruby 4.0.9, so every CI
job failed at Ruby setup. v1.334.0 is the first release that does.
2026-10-23 18:34:43 -04:00
Jeremy Daer d7589951cf Check the trusted CA certificates at build time
ruby:4.0.7-slim already ships ca-certificates 20250419+deb13u1, which removes
emSign ECC Root CA - G3 and AAA Certificate Services. Fail the build if either
root comes back in the store Ruby's OpenSSL loads.
2026-10-21 14:02:55 -07:00
Sam RubyandClaude Opus 5.5 c8f74a0b0e Compute a page's script sources once per importmap and host
Every page parsed the importmap and joined each of its URLs against the
request's base URL, about a millisecond of CPU a page, though the answer
changes only with the importmap and the host. Keep the last answer, keyed
by both. One entry, so a request with a made-up Host header can't grow it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 21:06:01 +09:00
Sam RubyandClaude Opus 5.5 8d4a5264cf Raise the TLS alert from a subclass instead of extending one connection
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 21:04:16 +09:00
Jeremy Daer ce7b5d4ea0 Check a cable connection's session while it's open (#376)
* Check a cable connection's session while it's open

Signing out or changing the password ends sessions and then disconnects
their connections. A connection that found its session just before isn't
subscribed to its disconnects yet, so it missed that and stayed open.

Each connection now looks its session up every minute while it's open, and
closes once the session is gone, asking the browser to reconnect so one
holding a current session comes back. That also covers any other way a
connection misses the disconnect, such as a subscription that takes long to
register, and a lookup that fails is simply tried again.

* Check the session on the server's heartbeat rather than a timer of its own

A connection's own timer could outlive it: closing can run before opening finishes, or a channel's teardown can fail before the connection's. The heartbeat only reaches connections that are open, so nothing is left to stop.

* Skip the session check on a rejected connection

A rejected connection stays registered until its socket closes, and has no session to check, so its heartbeat mustn't fail and stop the heartbeat reaching the connections after it.
2026-10-20 20:42:54 -07:00
Jeremy Daer a10211fb8a Merge pull request #375 from basecamp/refuse-session-for-changed-password
Refuse a session for a password that changed after it was checked
2026-10-20 10:17:29 -07:00
Jeremy Daer a476cbfa24 Sign the browser out when its new session is refused after a password change
If the password changes again between this browser's change and its new session, that session is refused, and the browser is sent to sign in instead of an error.
2026-10-20 08:57:40 -07:00
Jeremy Daer c3faccb0f4 Read the password digest past the query cache
A digest cached earlier in the request would let the check pass on a password that has since changed.
2026-10-20 08:47:47 -07:00
Jeremy Daer 19319a1cff Refuse a session for a password that changed after it was checked
A password change ends every session, but a sign-in or sign-in link checked
against the old password just before the change could still save its session
just after, and that session outlived the change.

The session now checks, as it's saved, that the user's password is still the
one the request loaded. The save's transaction holds SQLite's write lock from
the start, so a change commits either before the check, which fails it, or
after the insert, and ends this session with the others. Sessions start
through the user's association so the check sees the user that was
authenticated, and a refused sign-in is answered like a wrong password.
2026-10-20 08:37:07 -07:00
Jeremy Daer ac073010c2 Merge pull request #372 from basecamp/password-check-on-digest-change
Check the current password whenever the saved password changes
2026-10-19 16:04:53 -07:00
Jeremy Daer 4a580302a5 Check the current password whenever the saved password changes
The profile asked for the current password when the request's password
field was filled in. The check now follows the save itself: the model
checks the challenge whenever the password digest is about to change,
and the profile always hands it the challenge. Editing a name, avatar
or email without a new password still needs none, and scripts that
reset a password, which set no challenge, are unaffected.

Only a string counts as a challenge, and the rate limit counts every
non-empty one, so what's limited is exactly what gets checked.
2026-10-19 15:05:19 -07:00
Jeremy Daer af4dd9fd59 Merge pull request #371 from basecamp/sign-out-elsewhere-on-password-change
Sign out the account's other sessions when its password changes
2026-10-19 14:08:53 -07:00
Jeremy Daer aa93269ceb Look the endpoint up past the query cache, and keep a subscription a race refused
The lookup under the write lock repeated the one made before
validation, so the query cache could answer it with that earlier miss
even after another connection had registered the endpoint. It runs
uncached now.

Enabling notifications unsubscribed the browser on any refusal, so a
session signed out between authenticating and saving lost the browser's
subscription too, and the next session had nothing to post. Only a
refused endpoint unsubscribes it now.
2026-10-19 13:34:34 -07:00
Jeremy Daer 3786ee5244 Post the browser's push subscription from every page, and register it once
Only room pages posted the subscription again, so a browser that
changed its password and closed the profile page went without
notifications until it next opened a room. A small controller in the
layout does it now, still once per session, and the bell is back to how
it was.

Two tabs posting at once after a password change could both miss the
row and insert two, so the endpoint is looked up again under the same
write lock as the session check.
2026-10-19 13:15:10 -07:00
Jeremy Daer 1af62a5bff Remove the fake push subscription after its system test
The browser is shared across system tests, and a script added to every
new document stays until it's removed, so later tests would have seen
the granted permission and the fake subscription too.
2026-10-19 12:55:14 -07:00
Jeremy Daer 6cab924097 Remove push subscriptions on a password change, and post them again
A push subscription belongs to the user, not a session, so a device
signed out by a password change kept getting notifications. Changing
the password now removes every subscription along with the sessions,
in the same transaction.

A browser still signed in keeps its own subscription in its service
worker, so the notifications controller posts it once per session: the
bell names the session by a digest of its id, never its token, and the
browser remembers the last one it posted for. That post never
unsubscribes the browser when the server refuses it.

A request that authenticated just before the change could put a
subscription back after it. The create action now checks the session
still exists and saves in one immediate transaction, after validating
the endpoint outside it.
2026-10-19 12:39:03 -07:00
Jeremy Daer 44a92ff6c6 Ask for the current password to change it
Changing the password now ends every other session, so whoever holds
one could shut the owner out of their own account with a new password.
The profile asks for the current password whenever the password
changes; without it, or with a wrong one, nothing is saved and the page
says why. Other profile edits don't need it, and the admin
reset-password script still works without it.

Attempts are rate limited like signing in, 10 in 3 minutes per address,
so the current password can't be guessed here instead.
2026-10-19 12:17:14 -07:00
Jeremy Daer 160ba295b5 End sign-in links made before a password change
A transfer link signed only the user id, so one copied before the
password changed still started a session for up to four hours after.
Bind it to the password salt with generates_token_for, so a new
password ends those links too. Links made before this upgrade stop
working; they last four hours at most.
2026-10-19 11:36:16 -07:00
Jeremy Daer e158388f3d Close live connections on the transaction that changed the password
An after_commit condition reads the record's last save, so another save
of the user in the same transaction skipped the disconnect even though
the sessions were gone. The callback that deletes them now registers
the disconnect on the transaction itself, which also leaves a rolled
back change alone. A password changed along with the avatar is covered
too: the attachment's touch doesn't hide the change.
2026-10-19 10:57:14 -07:00
Jeremy Daer b01bb7a0a7 Give the changing browser a new session rather than keeping its own
Keeping the session the password was changed from also kept any copy of
its cookie working, and a copied cookie is one of the ways someone else
gets into an account. Every session ends now, and the profile page
signs the browser that changed the password back in with a new one.
2026-10-19 10:45:34 -07:00
Jeremy Daer c6e0105491 Close live connections from the model on any password change
The sessions end wherever the password changes, but only the profile
page closed the live connections, so a change from a console left a
signed-out device receiving messages until it dropped. Close them after
commit from User, logging rather than failing if the realtime service
can't be reached, since the password is saved by then.
2026-10-19 10:33:46 -07:00
Jeremy Daer c78c3fd7ef Sign out the account's other sessions when its password changes
Changing the password is how someone shuts out whoever else is signed
in to their account, but every session opened with the old password
stayed valid. Now the others end and their live connections close, as
on sign-out. The session the password was changed from stays signed in.

Changing the password outside a request, as from a console, ends every
session.
2026-10-19 10:28:06 -07:00
Jeremy Daer 11d3fb9ce0 Merge pull request #365 from basecamp/enforce-script-policy
Enforce a script Content-Security-Policy
2026-10-15 19:20:35 -07:00
Jeremy Daer 2ba940c683 Allow an asset host only up to its own asset directory
An asset host's path can contain the asset directory too, as in
https://cdn.example.com/assets, and cutting each URL at the first one would
allow everything the host serves under it. Cut at the last one instead.
2026-10-15 19:13:26 -07:00
Jeremy Daer 0a494a10cb Leave the scheme off this origin's script sources
Behind a proxy that terminates TLS without X-Forwarded-Proto, Rails sees
http while the page is https, and an http source on a non-default port
doesn't match. A source without a scheme takes the page's own.
2026-10-15 19:01:12 -07:00
Jeremy Daer 2be2227f40 Allow scripts only from the asset directory, not the whole origin
Uploads are served from this origin too, so script-src 'self' would run one
that a cache still holds under a script type from before the upload guard.
Application pages now allow each importmap URL up to its asset directory
(relative root and asset host included), the inline importmap by hash, and
the service worker by worker-src.
2026-10-15 19:01:12 -07:00
Jeremy Daer 2a449401ec Leave a request without a policy when the policy is turned off
With DISABLE_CONTENT_SECURITY_POLICY=true there's no application policy,
and the hash callback started an empty one, so pages sent an empty
Content-Security-Policy header. Skip the callback then.
2026-10-15 19:01:12 -07:00
Jeremy Daer 9c37f41ff6 Keep a multi-range upload response's multipart type
A request for several byte ranges gets a 206 multipart/byteranges whose
boundary the client needs to split the body. Rewriting it to
octet-stream lost the boundary. No browser runs that type as a script,
so it passes through.
2026-10-15 19:01:12 -07:00
Jeremy Daer d713f2631d Say how long a pre-upgrade cached upload can last
Disk URLs are cached for an hour, but blob proxy URLs are cached
publicly and as immutable for a hundred years, so a copy taken that way
before the upgrade doesn't expire.
2026-10-15 19:01:12 -07:00
Jeremy Daer 562888251e Enforce a script policy that allows the importmap by hash
script-src 'self', object-src 'none' and base-uri 'self', enforced. The
two inline scripts the importmap helper emits are allowed by their
SHA-256, and the origins its URLs point to (a configured asset host, in
any form Rails accepts) are allowed by name. There is no per-request
nonce, so cached pages stay valid.

DISABLE_CONTENT_SECURITY_POLICY=true leaves the policy off, for an
install whose proxy or customization injects scripts.
2026-10-15 19:01:12 -07:00
Jeremy Daer cad2d7211d Serve uploads that aren't media as downloads
Uploaded files come from this origin, so one served with a JavaScript
type could run as one of the app's own scripts. Browsers accept sixteen
spellings of that type, and Disk URLs sign the type they were minted
with, so refusing a list of types at upload can't cover links already
out there. Instead, a middleware rewrites the type of anything Active
Storage reads out that isn't plainly media, a PDF or plain text to
application/octet-stream, whatever the URL says.
2026-10-15 19:01:12 -07:00
Jeremy Daer 821ff92dda Merge pull request #364 from basecamp/autolink-text-only
Link URLs only in a message's text
2026-10-15 18:59:57 -07:00
Jeremy Daer 9b271d0e19 Hand auto_link text escaped the way the serializer writes it
That's exactly what it was given before, with quotes and apostrophes
left as they are, rather than relying on its own sanitize pass to undo
h's &#39;. Covers an email address with an apostrophe.
2026-10-15 18:42:06 -07:00
Jeremy Daer 4e29c6e32b Keep a code block's leading newline when linking a message's text
A <pre> whose text starts with a newline needs one more written out to
survive being parsed again, as the html5 serializer does with
preserve_newline. Without it, linking text dropped one more of a code
block's leading blank lines than rendering did before.
2026-10-15 18:42:06 -07:00
Jeremy Daer 6052b123d5 Quote a mention as text when replying
Replying swaps each mention in the quoted copy for its text. Assigning
that text to outerHTML parsed it as html; replace the mention with a
text node instead.
2026-10-15 18:42:06 -07:00