Skip to content

fix: send the mail-relay secret, and narrow the workflow sandbox hint - #644

Open
huyplb wants to merge 1 commit into
mainfrom
fix/mail-secret-header-and-troubleshoot-hint
Open

huyplb wants to merge 1 commit into
mainfrom
fix/mail-secret-header-and-troubleshoot-hint

Conversation

@huyplb

@huyplb huyplb commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Two follow-ups from the review of #641.

1. Mail-relay secret with no sender

packaging/wordpress/foxschema-mail.php accepts an optional define('FOXSCHEMA_MAIL_SECRET', …). When it is set, /verify-email and /account-email refuse requests that lack a matching X-Foxschema-Mail-Secret header. The Fox server never sent that header, so defining the secret made every verification, reset and invite email fail with 403.

  • packages/server/src/platform/identity/auth-mail.ts: new mailServiceHeaders(). When FOX_MAIL_SECRET is set, it adds X-Foxschema-Mail-Secret to both relay calls (verification codes, and reset/invite codes). This works the same way as SIGNUP_WEBHOOK_SECRET → X-Foxschema-Signup-Secret.
  • Documented next to SIGNUP_WEBHOOK_SECRET in docs/guides/DEPLOYMENT.md, with a paragraph in the "Fox mail service" section. Also added to .env.example and to the PHP file's header comment.

A shared secret only helps self-hosted relays. Every public install talks to the foxschema.com relay, so that relay cannot require a secret: anyone running Fox would need it. Set FOXSCHEMA_MAIL_SECRET only on a relay you host yourself, and set FOX_MAIL_SECRET to the same value on your installs. The live foxschema.com relay runs as a Code Snippets copy and does not define it, so nothing changes in production.

2. Over-broad troubleshoot hint

The sandbox rule in apps/web/src/frontend/features/workflow/lib/troubleshoot.ts matched any is not allowed or not authorized. Ordinary errors like "Method is not allowed" or a database "user … is not authorized" therefore got "Fox blocked an unsafe operation". The rule now matches only the engine's own refusals:

  • HTTP request refused (both the protocol and the private-address messages in http-target.ts)
  • outside the workflow files (file-root)
  • SQLite's authorizer denial, which node:sqlite reports as the bare message not authorized (checked on Node 24). It matches as the whole message or the end of a …: not authorized one, never mid-sentence.
  • the existing disabled for security / Refusing to open / not allowed in workflows

Tests

  • auth-mail.test.ts: the header goes out on verification, invite and reset sends when FOX_MAIL_SECRET is set, and is absent by default.
  • troubleshoot.test.ts: new positive cases (private-address refusal, bare and prefixed not authorized, ATTACH disabled), plus negative cases: "Method is not allowed", "Request failed with status 405: Method Not Allowed", a Postgres user "fox" is not authorized…, "User not authorized to perform: dynamodb:Scan", and the origin-policy message.

A/B: with the source changes reverted and the new tests kept, 6 tests fail (1 auth-mail, 5 troubleshoot). With the changes, all pass. npm run verify passes locally on Node 24, except gitleaks, which is not installed here.

🤖 Generated with Claude Code


Note

Low Risk
Targeted auth-mail header wiring and UI hint-regex tightening; no change to default public relay behavior when FOX_MAIL_SECRET is unset.

Overview
Adds FOX_MAIL_SECRET support so Fox can authenticate to a self-hosted mail relay. New mailServiceHeaders() in auth-mail.ts attaches X-Foxschema-Mail-Secret on verification, reset, and invite calls when the env var is set—matching FOXSCHEMA_MAIL_SECRET on the WordPress relay, which previously returned 403 because the server never sent the header. .env.example, DEPLOYMENT.md, and the PHP snippet header document that the public foxschema.com relay must stay secretless.

Narrows the workflow sandbox troubleshoot rule so routine errors (e.g. HTTP 405 “Method is not allowed”, Postgres/DynamoDB “not authorized”, origin-policy text) no longer surface “Fox blocked an unsafe operation”. The matcher now targets engine refusals such as HTTP request refused, file-outside-workflow paths, and SQLite authorizer not authorized (whole message or …: not authorized suffix), with expanded unit tests for positive and negative cases.

Reviewed by Cursor Bugbot for commit fce3c89. Bugbot is set up for automated code reviews on this repo. Configure here.

Two follow-ups from the #641 review.

The WordPress mail relay accepts an optional FOXSCHEMA_MAIL_SECRET and
then refuses /verify-email and /account-email without a matching
X-Foxschema-Mail-Secret header, but the server never sent one, so
defining it broke every verification, reset and invite email with 403.
FOX_MAIL_SECRET now sends it, like SIGNUP_WEBHOOK_SECRET does for the
signup webhook. Documented in DEPLOYMENT.md and .env.example.

The troubleshoot "Fox blocked an unsafe operation" hint matched any
"is not allowed" or "not authorized", so "Method is not allowed" or a
database "user not authorized" pointed at the workflow sandbox. It now
matches only the engine's own refusals: "HTTP request refused", the
file-root message, and SQLite's authorizer "not authorized" as a whole
message or the end of a "…: not authorized" one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cursor

cursor Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: f22b1e36-91f9-4f31-904f-ff07b18f16e6)

This branch has not been deployed

No deployments
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