Skip to content

Owner-only forced domains, a domain limit, masked dump errors, per-client OAuth limit - #140

Merged
tricknotes merged 5 commits into
mainfrom
domain-and-backup-hardening
Nov 23, 2026
Merged

tricknotes merged 5 commits into
mainfrom
domain-and-backup-hardening

Conversation

@tricknotes

Copy link
Copy Markdown
Owner

Summary

The remaining low-severity findings, one commit each.

  • Only the owner forces a custom domain active. A forced domain is routed and gets a certificate without proof that it points at this host, hostnames are unique across apps, and the console's gate then redirects to it. Members with the manage role keep adding, verifying, deleting and choosing the primary domain; changing force_active answers 403 forbidden_role.
  • 20 custom domains per app (422 too_many_domains). Each domain orders a certificate from the shared ACME account and each change reloads the whole Caddy configuration.
  • The app's secrets are masked in the message of a failed dump hook. The tail of the hook's stderr is shown to everyone with the view role, and tools such as pg_dump print connection strings when they fail.
  • OAuth callbacks are counted per client address (10 a minute per address, an IPv6 /64 counting as one; 60 a minute in total as the bound on requests to GitHub), so that one client cannot use up the limit for everyone.
  • Documentation of two properties that are by design: log archives in the bucket are not encrypted (restic's repository is), and deleting an app leaves its logs and snapshots under its name, where an app created later with the same name finds them. The deletion dialog says so.

Screenshots

Domain list for a member, light
Domain list for a member, dark
Domain list for a member, 390px
Domain limit, light
Domain limit, dark
Delete dialog, light
Delete dialog, dark
Delete dialog, 390px

Test plan

  • go vet ./..., go vet -tags integration ./..., go test ./...
  • pnpm lint, pnpm test
  • New tests: TestForcingADomainActiveIsOwnerOnly, the domain limit in the store, the API and the SPA, masking with a fake runner whose stderr holds a variable's value, the callback limiter (per address, /64, total, memory bound)
  • Screenshots from the mock API, checked in light, dark and at 390px
  • The whole integration suite on the combined stack

🤖 Generated with Claude Code

tricknotes and others added 5 commits November 24, 2026 04:01
A custom domain becomes active once its hostname resolves to this host.
force_active skips that check, and any member with the manage role could
set it: the hostname is then routed and has a certificate ordered with no
proof that it points here, it occupies a name that is unique across all
apps, and for a protected app the console's /auth/gate redirects a
logged-in user to it with a one-time code, which makes the console
redirect to a host of the member's choosing.

Changing force_active in PATCH /api/apps/{slug}/domains/{id} is now an
owner-only field, refused for members with 403 forbidden_role and
details.fields like the owner-only settings of an app. Sending the present
value is not a change, and the rest of the route (the primary flag) stays
at manage, as do adding, verifying and deleting. Ending the force is the
owner's too: a member who wants the hostname gone deletes the domain.

The domain list shows members who manage the app who has the switch
instead of the button.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
POST /api/apps/{slug}/domains had no limit. A member with the manage role
and a wildcard DNS record of their own could add verified hostnames
without end: Caddy orders a certificate for each from the ACME account
all apps share, whose new-order limits are per account, and every add or
removal reloads the whole Caddy configuration.

An app now holds at most 20 custom domains, pending ones included, which
is plenty for a personal host with a handful of apps. The number is the
constant store.MaxDomainsPerApp, checked in the same statement that
inserts the row so that concurrent requests cannot pass it. One more is
refused with 422 too_many_domains and details.limit, and the console says
how many an app can have and to delete one first.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
When a backup's dump hook fails, the tail of its standard error is kept in
backup_run_targets and shown on the app's backups and overview tabs to
everyone with the view role. The masker of the backup manager only knew
the storage keys, and tools such as pg_dump print the connection string
they failed with, so a database password in the app's variables could
reach members who may not read the variables.

The output of the dump command now passes through a masker that also
knows the values of the app's variables: the saved ones and the ones in
the live env file, exactly what the task logs hide. The backup package
still knows nothing of the database or the master key: backup.App gains
OutputMasker, a function the caller sets next to WithDumpService, and
cmd/koroku fills it from the engine's task masker. It is asked for once
per dump, so the values are those at the time the command runs. The dump
taken before a database copy goes the same way.

When the values cannot be loaded the dump still runs, since a backup is
worth more than its error message, but nothing the command printed is
kept: the message says so and carries the exit status only.

Messages recorded by earlier runs are not rewritten; the tabs show the
newest run of an app only.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
GET /auth/github/callback had one limit for everyone: ten code exchanges
a minute, counted only for requests whose state cookie matches the state
parameter. A client that sends a cookie and a matching parameter of its
own (nothing checks that koroku issued the state) could still use up all
ten every minute from one address and keep every real login failing.

Exchanges are now counted per client address first, with the same ten a
minute for each, and a request from an address over its own limit no
longer counts against the total. The address is clientIP, which Caddy
sets and a client cannot forge; an IPv6 /64 counts as one client, because
one host can pick any address in it.

The total stays as the bound on requests that carry the client secret to
GitHub, raised to 60 a minute: one a second is still a small, fixed
number, real use is a few logins a week, and it takes six addresses at
their full allowance to use it up instead of one. A client with many
addresses can still do that; this is not prevented.

The per-address counters live in memory for one window and at most 1024
addresses are remembered. Past that a new address is refused, by which
time the total is used up anyway.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Two properties of the design were not written down where an operator or
a member's owner would look for them.

Archived logs are not encrypted. The bucket holds restic/, which restic
encrypts (the database, /etc/koroku with the keys, volumes, dumps), and
logs/<slug>/..., which is gzip only: runtime logs, access logs and
deployment logs of every app, handed to the browser as they are through
presigned URLs. Whoever can read the bucket reads all of them. The
architecture (10.1, 10.2), the storage step of SETUP and the secrets
table of OPERATIONS now say so, and that runtime logs are archived as the
app printed them.

Deleting an app removes apps/<slug> only. Its local logs (14 days), its
archived logs (until the lifecycle rule) and its restic snapshots (tagged
app:<slug>, kept by the retention policy for months) stay, and since all
of them are looked up by slug, an app created later under the same slug
shows them to its own members: view reads the old logs, manage downloads
the old dumps and restores the old volumes. The architecture described
this for kept volumes only; it now covers logs and snapshots, USAGE has a
section on deleting an app, and OPERATIONS lists what stays, where, and
how to remove it by hand before reusing a name. The restic commands there
were checked against a throwaway local repository: --tag app:<slug>
selects the exact tag only.

The deletion dialog gains one sentence saying that logs and backups stay
under the name and will belong to an app created with it.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Base automatically changed from api-hardening to main November 23, 2026 19:24
@tricknotes
tricknotes merged commit 7445a42 into main Nov 23, 2026
5 checks passed
@tricknotes
tricknotes deleted the domain-and-backup-hardening branch November 23, 2026 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant