Skip to content

PhoenixKit 2.13.16: Security fixes for invitations, sign-in and sitemaps

PhoenixKit 2.13.16 fixes security problems and crashes found in a review of the whole codebase. Every site should update.

Any signed-in user who knew an organization invitation’s id could accept or decline it, even if it was sent to someone else. Invitations now only work for the invited email address.

Someone could register an account with another person’s email and keep a working password after the real owner confirmed it through social sign-in or a magic link. Confirming that way now signs out every session and makes the old password unusable; the owner can set one with “forgot password”. The magic-link page no longer reveals whether an email has an account: it always answers “If that email address exists, a magic link has been sent.”

Other fixes: logging out no longer crashes on a stale tab; requests for sitemap files that do not exist no longer each set off a full rebuild; notifications sent to several people reach all of them over external channels; scheduled sitemaps keep running after a failed run; WebM and MKV videos finish processing; and mix phoenix_kit.update -y now fails when a migration fails.

New components for module authors include right-click and touch-and-hold menus.

Full release notes: PhoenixKit 2.13.16

2.13.16 · 30 August 2026

Added

  • <.context_menu> — right-click and touch-and-hold menus. New PhoenixKitWeb.Components.Core.ContextMenu plus a ContextMenu JS hook. One menu element serves every row it matches: a tree of five hundred nodes renders one hidden <ul>, not five hundred. On right-click the hook finds the row under the pointer, copies its identifier onto each item’s phx-value-*, and opens the menu there — so opening costs no server round-trip and the event that fires afterwards still names the right target. Items are TableRowMenu‘s, so a context menu and a ⋮ row menu look identical. value_name takes a list when a menu’s items were written against handlers that spell the param differently. Overflow flips the menu to the other side of the pointer rather than sliding it, then clamps; the menu is portaled to <body> while open so position: fixed escapes <dialog> and transformed ancestors. Touch gets a 450ms hold (cancelled by a 10px move) with the following click swallowed, and Android’s native contextmenu de-duplicated. Several menus on one page resolve by deepest match, not DOM order; within confines a menu to one region.
  • <.folder_explorer> rows are context-menu ready. Every folder row and leaf row carries data-context-kind ("folder" / "item"), data-context-value and data-context-label, so a consumer gets right-click menus by declaring the menus alone — no flag, no slot. They sit on the folder’s row <div> and the leaf <li>, never on a folder’s wrapping <li>, so a right-click on a nested row resolves to that row rather than its ancestor folder. Consumers that declare no menu pay three attributes per row and keep the browser’s own menu.

Post-merge review of #772 and of 585973ca (ContextMenu, pushed without a PR) — see dev_docs/pull_requests/2026/772-form-field-label-parity/CLAUDE_REVIEW.md.

Fixed (post-merge review)

  • Form labels now match <.input> exactly, and the four bare <.label> call sites keep their bottom gap. #772 removed fieldset-legend from FormFieldLabel on the premise that it shrank and muted those labels. It does neither — daisyUI’s .fieldset-legend sets no font-size at all; what it sets is color: var(--color-base-content) (overriding .label’s 60%-alpha muting) and padding-block: 0.5rem. Removing it was still right, because that padding was the only bottom gap the callers that pass no class had (registration, magic_link_registration, send_profile_form ×2), and they lost it. mb-2 now lives in the component, as it does in <.input>.
  • <.translatable_field> labels are the same size as the <.input> labels beside them. The 0.75rem came from the component’s own fieldset wrapper, not from fieldset-legend, so #772’s compensating text-sm was a 12px→14px bump against a 16px neighbour. Dropping fieldset from the wrapper makes the span byte-identical to Input’s — now pinned by a test that renders both and compares.
  • Mentions.mention_input/1 tracks <.translatable_field> again. The two were byte-identical before #772 and render side by side in the same forms.
  • The required marker on <.select>/<.textarea> matches <.input>’s — a non-bold sibling span rather than a bold one nested inside the label span.
  • ContextMenu: a long press interrupted by a LiveView patch no longer strands a menu in <body> — destroyed() cancels the pending timer.
  • ContextMenu: within honours every matching container, not just the first one document.querySelector happened to return.
  • ContextMenu: a right-click on empty space closes the open menu instead of leaving it under the browser’s native one; the native-menu grace window no longer suppresses a right-click when no menu is showing.
  • ContextMenu: the post-long-press click is swallowed even if the menu closed in between (Escape, a scroll, an Android URL-bar resize) — the swallower was registered and removed with the menu, so the release click used to activate the row underneath. The backstop timer is tracked, so overlapping presses no longer clear each other’s flag.
  • ContextMenu docs: the MediaDragDrop collision warning said a non-overlapping selector avoids it. Rows resolve via Element.closest/1, so containment collides too — and FolderExplorer is exactly that shape. The warning now states the real rule and the workaround that works (long_press={false}). Not reachable in core: nothing in lib/ declares a <.context_menu> yet.

Repo-wide review sweep (no single PR): six areas audited, the verified defects fixed, the larger items recorded below under “Known / deferred”.

Fixed

Auth & sessions

  • Organization invitations are email-bound again. accept_invitation_by_uuid/2 checked existence, status and expiry but never that the invitation was addressed to the accepting user, and decline_invitation_by_uuid took no user at all — the uuid arrives from a client event, so any signed-in user who learned one could join (or cancel) somebody else’s invitation. Both now return {:error, :not_invitee} on a mismatch (case-insensitive); the decline API is now decline_invitation_by_uuid/2. Registration via an invite link only stashes the auto-accept when the registered address IS the invited one.
  • Confirming an account through a verified OAuth email or a magic link now closes the pre-hijack window. Both paths called admin_confirm_user/1, which only stamps confirmed_at — an attacker who pre-registered the victim’s address kept a working password and live sessions on the row the victim was just handed. New Auth.confirm_user_from_external_proof/1 confirms, deletes every token and rotates the stored password hash in one transaction; the rightful owner sets a password via “forgot password”.
  • Logout no longer 500s when the browser holds no session stack (stale tab / double-click on the unauthenticated DELETE /users/log-out) or when a secondary account is active but the root token no longer resolves (revoked, role change, expiry) — both are now a full logout.
  • Admin user form: editing an email to an already-taken address returns a changeset error instead of crashing the LiveView. validate_email: false skipped unique_constraint along with the pre-flight uniqueness query.
  • Magic-link request page is no longer an account-existence oracle — the registered and unregistered branches used different flash copy.
  • A non-last Owner can be deactivated again. status_changeset/2 rejected is_active: false for every Owner, contradicting the context’s last-owner-under-lock guard that deliberately allows revoking a compromised non-last Owner.
  • MultiSession.add_account/3 now passes the client IP, so the per-IP login bucket applies to it as it does on the main login form.
  • Magic-link consumption is atomic (delete_all by uuid, branch on the row count) — a concurrent replay yields {:error, :invalid_token} instead of Ecto.StaleEntryError. OAuth accounts with no email (GitHub allows it) now fail with {:error, :provider_email_missing} rather than a FunctionClauseError inside the transaction.

Integrations, settings, cache

  • Cache.clear_by_prefix/2 no longer crashes a cache started without ttl: — its fold matched only 3-tuples, but TTL-less entries are {key, value}; the FunctionClauseError killed the GenServer and dropped its :named_table.
  • Encryption.decrypt_fields/1 never returns enc:v1: ciphertext as a live credential. With no key resolving (encryption disabled, key store unreachable) the map path passed encrypted values through untouched; they are now dropped and logged, matching the existing wrong-key behaviour.
  • OAuth token refresh treats a failed persist as an error. The save result was discarded, so a failed UPDATE still returned {:ok, token} and — for IdPs that rotate refresh tokens — left the burned old refresh token in the row.
  • Settings.get_json_settings_cached/2 fills cache misses from the database instead of returning nil for every absent/expired key (the same bug get_settings_cached/2 was patched for).
  • Integrations.get_integration/1 by uuid only resolves module: "integrations" rows — any JSONB settings row’s uuid used to decrypt-as-integration.
  • Removed the legacy :cache_settings ETS table — it received every decrypted setting on warm and was never read or invalidated.
  • File key-store preflight opens its probe with :exclusive, so a planted symlink at <key>.preflight can no longer truncate the real key.

Notifications, activity, jobs

  • External-channel delivery reaches every recipient of a fan-out. The DeliveryWorker unique key was {source_uuid, channel}, so when one activity was routed to N recipients only the first job was inserted within the 300 s window. recipient_uuid is now part of the key.
  • Notifications.prune/1 also ages out standalone rows (create/1, create_many/2, digest summaries) — the delete joined on the activity entry, so rows with activity_uuid: nil accumulated forever.
  • Activity.log/1, Notifications.maybe_create_from_activity/1 and the delivery enqueue catch :exit as well as rescuing — a dead pool exits rather than raises, and the business action that logged the activity was crashing on a DB blip.
  • DigestWorker survives one user’s exit — previously an Oban retry re-sent every digest already delivered to earlier users in the sweep.
  • ScheduledJobs marks a job failed on exit/throw instead of leaving the row in processing until the stale reclaim and skipping the rest of the sweep.
  • activity_retention_days of 0 or negative falls back to 90 instead of crashing both prune workers daily with a FunctionClauseError.

Built-in modules

  • Sitemap: an anonymous miss can no longer trigger a full regeneration storm. Any GET /sitemaps/<unknown> used to run Generator.generate_all/1 (every source, every language) and then 404 — N bogus filenames meant N concurrent full regenerations. Misses within 5 minutes of a full generation now 404 directly, and on-demand generation is single-flight (:global.trans; concurrent callers get a 503 with Retry-After).
  • Sitemap scheduler goes through Oban.insert/1 and Oban.Repo instead of the host repo — Oban.Job carries no @schema_prefix, so on a prefixed install jobs landed in public.oban_jobs, a table no Oban instance polls.
  • Scheduled sitemap chain survives a skipped or failed run. A scheduled job that returned early (base URL briefly empty) or errored never rescheduled, so regeneration silently stopped until the next boot.
  • Video processing parses ffprobe output by key (stream=…:format= duration) instead of positionally — WebM/MKV carry duration on the format, not the stream, so the old [w, h, d] = match crashed and the file never became active.
  • SyncFilesJob is unique across available/scheduled/executing; the LiveView’s persistent_term guard was node-local and only set once the job started, so two clicks before pickup ran two concurrent syncs.
  • Bucket form connection test uses start_async/3 — the linked Task.async took the form down on an HTTP-pool exit.

Admin UI

  • remove_member on the user-details page only accepts a member of the organization being viewed; any uuid used to be detached, and a bogus one crashed the LiveView.
  • Activity index no longer runs the paginated query twice per mount.
  • Authorization settings and the markdown editor map event params through literal allowlists instead of String.to_existing_atom/1.
  • MediaSelector’s return_to goes through Routes.local_path?/1, the one redirect guard (rejects control characters), instead of a local copy.

Install & migrations

  • mix phoenix_kit.update -y fails when ecto.migrate fails instead of printing a warning and exiting 0 with the schema still behind.
  • mix phoenix_kit.gen.admin.page refuses to touch a non-literal admin_dashboard_tabs (a variable, base ++ […], a helper call) — it used to replace the whole value, dropping every page the host had registered.
  • The migrator raises on a version-lookup query error instead of folding it into “fresh install” and replaying the whole chain onto a current database.
  • DbConnectionCheck rescues/catches an unstarted repo and reports the friendly “cannot connect” message instead of a stack trace.
  • Asset rebuild reports :rebuild_failed when every build command fails; mix phoenix_kit.assets.rebuild no longer prints “✅ completed” over it. MigrationStrategy says when the DB was unreachable rather than reporting “installed (V00)”.

Known / deferred (recorded, not fixed here)

  • Storage: Manager.public_url/2 issues an S3 HEAD per bucket on every <.image> render (resolve from FileLocation rows instead); orphan detection hardcodes table_schema = 'public' and runs a LIKE '%uuid%' scan per file on every MediaBrowser mount; Manager.delete_file/2 reports success if any bucket returned :ok (Local returns :ok for enoent).
  • Settings: no cross-node invalidation (Settings.Events.broadcast_setting_changed/2 has no callers); read-then-put race can cache a stale value for one TTL.
  • Install: supervisor-order rewrite can emit an unparseable application.ex (trailing commas); gen.migration mis-detects the version after consolidate_wrappers; modernize_layouts is a stub that reports success; V179/V180 down/1 can fail on a raw FK violation after a local manufacturer delete.
  • Auth: reset-password submit does not re-verify the token (upstream phx.gen.auth behaviour); count_remaining_owners/1 in delete_user does not take the last-owner advisory lock.
  • Maintenance: an unparseable schedule end value is stored as “no end”.

PhoenixKit 2.13.16. Install or update: {:phoenix_kit, "~> 2.13"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.