Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

fix(auth): run the sign-up abuse gate on Google sign-ups too, and refuse dead domains (#15591)

Ahmad Tashe077d142134b
diff --git a/brain/knowledge/connections-auth/ce-authentication.md b/brain/knowledge/connections-auth/ce-authentication.md
index f186b7e90ff..56654b27408 100644
--- a/brain/knowledge/connections-auth/ce-authentication.md
+++ b/brain/knowledge/connections-auth/ce-authentication.md
@@ -18,13 +18,15 @@ The core (all-editions) auth layer: user identity creation, sign-in, and JWT ses
- First sign-up side effects: creates identity → User (PlatformRole.ADMIN) → default PERSONAL project; sends OTP on Cloud prod, auto-verifies otherwise; fires `USER_CREATED` flag + `SIGNED_UP` telemetry.
- **`signUp` has two arms and only one of them can create a platform.** When `params.platformId` is set (self-hosted, or a custom domain) the member joins that existing platform through `getOrCreateWithProject` and no platform is ever created or named. When it is nil (Cloud only) the identity is created first, then `getPreferredPlatformId` looks for a platform the identity already belongs to; finding none it hands off to `authenticationUtils.provisionOrOnboard`, which creates the platform straight away only when the identity is **verified and** carries a name someone gave us, and falls back to an ONBOARDING response (finished at `/create-platform`) when `!identity.verified || isPlaceholderName(identity)`. On Cloud a password sign-up is created unverified, so it always takes the onboarding arm at `/sign-up`; its platform is created on the first `/sign-in` after the verification email, which is where the `SignUpMethod.PASSWORD` telemetry stamp lives. `getPreferredPlatformId` returns null on every non-Cloud edition. **The member never types a platform name; they type their own, and the platform name is derived from it.** `completeSignUp` takes a single `fullName` field (that is the whole of `CompleteSignUpRequest`) and calls `signupNames.platformNameFromSignup`, which prefers the company read off a work email domain (`"Activepieces"`) and falls back to the person (`"<FirstName>'s Platform"`, then the capitalised first token of the email local part, then `"My Platform"`). The project name follows from the platform name via `personalProjectName`.
- **ONBOARDING** is the pre-platform principal: `authenticationUtils.getOnboardingResponse` mints it with `platformId: null, projectId: null` for a verified identity that belongs to no platform yet **and whose name we only guessed**, so the member can call `POST /v1/platforms` (`securityAccess.unscoped([ONBOARDING, USER])`) and land on `/create-platform`. It is Cloud-only in practice, because on self-hosted `platformUtils.getPlatformIdForRequest` falls back to `getOldestPlatform()` and there is always a platform to join. `accessTokenManager.assertUserSession` still revalidates it against `tokenVersion` + `verified`.
-- **Sign-up address validation** is one call to ZeroBounce (`zerobounce.maySignUp`), from `signUp` for the EMAIL provider and from `requestCode` for an address with no identity yet. It runs only when `AP_ZEROBOUNCE_API_KEY` is set, refuses the abuse half of `do_not_mail` plus `spamtrap`/`abuse`, and fails open on anything it cannot read. Both call sites refuse **silently**, and the lib throws nothing: `requestCode` returns the same `204` as a success (no identity, no code), and `signUp` throws `EMAIL_IS_NOT_VERIFIED`, the response a genuine unverified Cloud sign-up already produces. `DOMAIN_NOT_ALLOWED` is not used here at all. See [000032](../decisions/000032-a-signup-address-is-checked-against-zerobounce-not-a-bundled-blocklist.md).
+- **Sign-up address validation** is one call to ZeroBounce (`zerobounce.maySignUp`), from `signUp` for every provider except the platform-provisioned ones (`JWT`, `SAML`) — so the sign-up form and Sign in with Google alike — and from `requestCode` for an address with no identity yet. It runs only when `AP_ZEROBOUNCE_API_KEY` is set, refuses the abuse half of `do_not_mail`, `spamtrap`/`abuse`, and the dead-domain half of `invalid` (`no_dns_entries`, `does_not_accept_mail`, `unroutable_ip_address`), and fails open on anything it cannot read. Both call sites refuse **silently**, and the lib throws nothing: `requestCode` returns the same `204` as a success (no identity, no code), and `signUp` throws `EMAIL_IS_NOT_VERIFIED`, the response a genuine unverified Cloud sign-up already produces. A refused *Google* sign-up throws `INVALID_CREDENTIALS` with no params — indistinguishable from a failed Google token exchange on the same endpoint — and the redirect page toasts a generic "Sign-in failed": the abuser reads the response body, and an honest `DOMAIN_NOT_ALLOWED` would tell them which DNS record to add. `DOMAIN_NOT_ALLOWED` is not used on either path. See [000032](../decisions/000032-a-signup-address-is-checked-against-zerobounce-not-a-bundled-blocklist.md).
- **Passwordless sign-in** (`EMAIL_LOGIN`) is a typed 6-digit code on the same OTP primitive, with password as the fallback path. Its two unauthenticated routes, `/otp/request` and `/otp/verify`, live in `passwordlessAuthModule`, registered **only in the Cloud arm of `app.ts` and only when `turnstile.isConfigured()`** — everywhere else they do not exist, so a self-hosted instance answers 404. `/complete-sign-up` stays in `authenticationModule` on every edition, because it finishes any ONBOARDING principal and not just a code sign-up. The UI reads one flag, `ApFlagId.EMAIL_CODE_AUTH_ENABLED`, which carries that same pair of conditions. See [000027](../decisions/000027-email-sign-in-is-a-typed-code-on-the-existing-otp-primitive.md) for the code-not-link and anti-enumeration reasoning and [000032](../decisions/000032-emailed-sign-in-codes-are-served-on-cloud-only-and-only-behind-a-captcha.md) for why the reach narrowed.
### Gotchas
- Email-auth checks and domain allow-listing guards are **skipped on Community** edition.
- **OTP verification is sent on Cloud unless `AP_ENVIRONMENT` is exactly `dev`, in which case the identity is silently auto-verified and no email goes out.** `sendVerificationOrAutoVerify` compares against `ApEnvironment.DEVELOPMENT`, whose value is the string **`dev`** — not `development`, which an earlier version of this line claimed. The distinction is not cosmetic: `AP_ENVIRONMENT=dev` on Cloud takes the `verify()` branch and the email-code flow becomes untestable locally, while any other value (including a typo like `development`, which fails the system validator with a warning and nothing more) falls through to `otpService.createAndSend` and really does email. So to exercise sign-up email locally on Cloud, `AP_ENVIRONMENT` must not be `dev`; `prod` also works but switches on the newsletter POST to a live endpoint. CE/EE take the other edition arm entirely.
-- **`status: invalid` is deliberately NOT refused at sign-up.** A non-existent mailbox is allowed to create an (unverified) identity, because refusing it would make the public sign-up endpoint a mailbox-existence oracle for any address at any domain. So a random-address bot still gets a row; what it cannot get is a verified session. Do not "tighten" this without reading [000032](../decisions/000032-a-signup-address-is-checked-against-zerobounce-not-a-bundled-blocklist.md).
+- **`status: invalid` is refused only when it describes the domain, never the mailbox.** `no_dns_entries`, `does_not_accept_mail` and `unroutable_ip_address` are refused — nobody at such a domain could have received the code, so no one who would have completed sign-up is turned away. `mailbox_not_found`, `possible_typo` and `mailbox_quota_exceeded` are allowed to create an (unverified) identity, because refusing them would make the public sign-up endpoint a mailbox-existence oracle for any address at any domain. So a random-address bot at a real domain still gets a row; what it cannot get is a verified session. The dead-domain refusals are deliberately *not* cached by domain (only `disposable` is): DNS breaks transiently and the list has no TTL. Do not "tighten" this further without reading [000032](../decisions/000032-a-signup-address-is-checked-against-zerobounce-not-a-bundled-blocklist.md).
+- **Sign in with Google mints a *verified* identity with no email ever sent, and until 2026-09-16 it skipped the abuse gate entirely.** `signUp` sets `verified: isFederatedProvider`, so `sendVerificationOrAutoVerify` sends nothing and `provisionOrOnboard` goes straight to a platform + project. Google's `email_verified: true` means "this person controls this Google account", not "this address receives mail": a Cloud Identity tenant on a fresh domain needs only a `google-site-verification` TXT record — no MX — and gives 50 free accounts. That is how `[email protected]` and 35 siblings got in on the day ZeroBounce would have called them `no_dns_entries`. The gate is now keyed on the provider by denylist (`PLATFORM_CONTROLLED_PROVIDERS`); if you add a public provider, it is checked unless you say otherwise. When you investigate a bot account, look for `federated.login.started` before `signed.up` in PostHog before assuming the email path was involved.
+- **A ZeroBounce verdict looked up today is not the verdict the check saw at sign-up.** Re-validating a suspicious address weeks later is the obvious way to ask "how did this get through", and it misleads: throwaway domains are registered in sequential farms (`tttttrunapi.shop`, `ttttttrunapi.shop`, … sharing nameservers), given MX just long enough to receive the sign-up code, then left with the DNS dropped. So the address that reads `invalid` / `no_dns_entries` today answered `valid` or `catch-all` when it signed up, and the check behaved exactly as designed. A verified identity is the proof: verification only ever happens through an emailed OTP (`userIdentityService.verify` / `verifyAndDiscardPassword`), so the domain **must** have been accepting mail at the time. Before concluding the check failed, ask whether the identity is verified, and read the `address refused` log line from that date rather than a fresh lookup. This is also exactly what the dead-domain `invalid` refusals buy: reuse of a burnt farm is stopped, the original sign-up on a domain that still had MX was not.
- **`do_not_mail` is not a rejection on its own.** It covers `role_based`, `role_based_catch_all` and `mx_forward` as well as the abuse sub-statuses, so refusing the whole status would refuse `info@` and `sales@` — normal ways a team signs up. Only four sub-statuses are refused: `disposable`, `toxic`, `possible_trap`, `global_suppression`. Note those four are **not** all the same shape: `disposable` is a property of the domain, while `toxic` and `global_suppression` (and `spamtrap`/`abuse`) describe one address. Any future caching or batching of verdicts has to respect that — a per-domain cache is sound only for `disposable`, and caching an *allow* verdict per domain is never sound, because it would skip the address-level checks for every other mailbox on that domain.
- **`turnstile.assertSolved` must stay ahead of the ZeroBounce call in `requestCode`.** Each validation costs a ZeroBounce credit, and the captcha is what stops an unsolved request from spending one. Reordering those two lines turns the endpoint into a way to drain the credit balance.
- **A refused address creates nothing, so a bot can re-hit the same address forever.** That used to cost a credit per attempt, which made draining the balance a bypass (fail-open means an empty balance passes everything). `disposable` verdicts are now cached in one `distributedStore` key, `zerobounce:disposable-domains:v1` — an insertion-ordered array of at most 500 domains, oldest dropped on overflow, no TTL — so repeat abuse on one domain costs a single credit fleet-wide. Rotating across *new* domains still costs a credit each — that half is bounded by the captcha, the auth rate limits and whatever the edge enforces, not by the cache.
diff --git a/brain/knowledge/decisions/000032-a-signup-address-is-checked-against-zerobounce-not-a-bundled-blocklist.md b/brain/knowledge/decisions/000032-a-signup-address-is-checked-against-zerobounce-not-a-bundled-blocklist.md
index c500090ce94..90af00978a7 100644
--- a/brain/knowledge/decisions/000032-a-signup-address-is-checked-against-zerobounce-not-a-bundled-blocklist.md
+++ b/brain/knowledge/decisions/000032-a-signup-address-is-checked-against-zerobounce-not-a-bundled-blocklist.md
@@ -5,7 +5,7 @@ status: accepted
# A sign-up address is checked against ZeroBounce, not a bundled blocklist
## Decision
-`zerobounce.maySignUp` — the module's only export — asks ZeroBounce's `GET /v2/validate` about every address that has no account yet, and refuses the sign-up on `spamtrap`, `abuse`, or `do_not_mail` with a sub-status of `disposable`, `toxic`, `possible_trap` or `global_suppression`. The `disposable-email-domains` package leaves the sign-up path. The check runs only when `AP_ZEROBOUNCE_API_KEY` is set, and `AP_ALLOW_DISPOSABLE_EMAILS` is deleted — the key's presence is the switch.
+`zerobounce.maySignUp` — the module's only export — asks ZeroBounce's `GET /v2/validate` about every address that has no account yet and arrives through a public door (the sign-up form or Sign in with Google; `JWT` managed-auth and `SAML` are platform-provisioned and skipped), and refuses the sign-up on `spamtrap`, `abuse`, `do_not_mail` with a sub-status of `disposable`, `toxic`, `possible_trap` or `global_suppression`, or `invalid` with a sub-status of `no_dns_entries`, `does_not_accept_mail` or `unroutable_ip_address`. The `disposable-email-domains` package leaves the sign-up path. The check runs only when `AP_ZEROBOUNCE_API_KEY` is set, and `AP_ALLOW_DISPOSABLE_EMAILS` is deleted — the key's presence is the switch.
## Context
Cloud was taking botted sign-ups. The defence was a `Set` built from `disposable-email-domains` at module load, consulted by `disposableEmail.assertMaySignUp`. That list is a build artefact: it is fixed at release time, so a domain registered after the build is invisible until the next release, and an operator running an older tag never sees it at all. The purge script that cleans up the platforms those sign-ups leave behind needs an explicit `--domains` list precisely because "the package does not know about" the evasion domains actually in use.
@@ -14,7 +14,7 @@ Cloud was taking botted sign-ups. The defence was a `Set` built from `disposable
**A blocklist that ships with the release is always behind the attacker.** Throwaway domains are registered continuously and cost nothing; a list compiled weeks earlier and frozen into a tag cannot see them. A hosted service answers about the domain as it is today, which is the only version that matters.
-**Junk, not non-existence.** `status: invalid` — a mailbox that does not exist — is deliberately allowed through, even though random-address bots at real domains are exactly what it would catch. Refusing it turns the public sign-up endpoint into a mailbox-existence oracle for any address at any domain, and it refuses the ordinary member who typos their own address. Bots that get in this way still cannot verify a code, so they get an unverified identity row and nothing else, which the purge path already handles.
+**Junk, not non-existence — and a dead domain is neither.** `status: invalid` is split by what it describes. A mailbox that does not exist (`mailbox_not_found`, `possible_typo`, `mailbox_quota_exceeded`) is deliberately allowed through, even though random-address bots at real domains are exactly what it would catch. Refusing it turns the public sign-up endpoint into a mailbox-existence oracle for any address at any domain, and it refuses the ordinary member who typos their own address. Bots that get in this way still cannot verify a code, so they get an unverified identity row and nothing else, which the purge path already handles. A domain that cannot receive mail at all (`no_dns_entries`, `does_not_accept_mail`, `unroutable_ip_address`) is refused: the verdict says nothing about any one mailbox, and it turns away nobody who would have completed sign-up, because the code could never have arrived. It closes the dead half of a throwaway farm — domains given MX just long enough to receive a code, then left with no records — which is the state such a farm is found in once someone looks.
**Role addresses are accepted.** `do_not_mail` also covers `role_based`, `role_based_catch_all` and `mx_forward`. Refusing those would refuse `info@`, `sales@` and `automation@` — ordinary ways a team signs up for an automation tool. The reject set is deliberately the abuse half of `do_not_mail`, not the whole status.
@@ -22,6 +22,8 @@ Cloud was taking botted sign-ups. The defence was a `Set` built from `disposable
**The key is the feature flag.** `.claude/rules/self-hosting.md` forbids anything that looks enabled but is silently broken without setup, and a paid API cannot be a default. Gating on the key means an instance with no ZeroBounce account sees no check and no error, and one with a key gets it with no second switch to discover. `AP_ALLOW_DISPOSABLE_EMAILS` therefore had nothing left to control and was removed rather than kept as a knob that only ever agrees with the key.
+**The gate is keyed on the provider by denylist, not on `EMAIL`.** The first cut ran the check only when `provider === EMAIL`, on the reasoning that it was an email-deliverability check. It is not — it is a new-account abuse gate — and Sign in with Google is a public door that mints a *verified* identity with no email ever sent. On 2026-09-16 a farm that ZeroBounce had shut down on the email path (1,458 `emalupe.com` accounts, dead the day the check shipped) came back through Google: a throwaway `.shop` domain verified with Google via a TXT record, no MX, 36 Cloud Identity accounts, every one skipping the gate. So `requiresSignUpAbuseCheck` refuses to check only `PLATFORM_CONTROLLED_PROVIDERS` (`JWT`, `SAML`) — accounts a platform provisions for itself behind a signing key or an IdP — and any future public provider is checked by default rather than silently exempt. A refused Google sign-up throws `INVALID_CREDENTIALS` with no params — the same answer a failed Google token exchange already produces on that endpoint — and the redirect page shows a generic "Sign-in failed". An honest `DOMAIN_NOT_ALLOWED` was tried first and reverted: the mailbox-oracle argument does not apply (the member owns the Google account), but the *coaching* argument does — an abuser reads the response body, not the toast, and "domain not allowed" tells them precisely which DNS record to add. So the Google path mimics too, just a different legitimate failure than the email path does.
+
**The captcha comes first.** In `requestCode`, `turnstile.assertSolved` runs before the validation call, so no credit is spent on a request that has not solved a challenge. That ordering is load-bearing, not incidental: it is what makes per-address credit spend bounded by solved captchas rather than by packets.
## Consequences
@@ -30,10 +32,10 @@ The sign-up path now depends on a third party, and self-hosters lose a check the
- **An instance with no key accepts throwaway addresses where it previously refused them.** This is a deliberate loosening for self-hosters, and deliberately *not* recorded in `breaking-changes.mdx`: nothing errors, nothing has to be done on upgrade, and the call was that no self-hoster was leaning on the bundled list. The cost is that the loss is silent — anyone who *was* relying on it learns from throwaway sign-ups rather than the upgrade guide. `AP_ALLOW_DISPOSABLE_EMAILS` is removed on the same reasoning: an instance that still sets it boots fine and the value is ignored. Self-hosted instances are not the ones under sign-up attack, and the alternative — shipping a stale list to everyone — is what was being replaced.
- **Burning the credit balance is the bypass, so disposable domains are cached.** Fail-open plus an exhaustible balance means an attacker who spends the credits makes every subsequent address pass. A refusal creates no identity, so the same address can be re-tried indefinitely; without a cache each attempt cost a credit. `disposable` verdicts therefore accumulate in one `distributedStore` key, `zerobounce:disposable-domains:v1`, holding an ordered array of at most 500 domains: a hit is an array membership test, and a new domain is appended with the oldest dropped once the list is full. Hammering one domain costs one credit, ever, rather than one per attempt. This bounds *repeat* abuse, not *breadth*: rotating across new domains still costs a credit each, which is the edge's job (a Cloudflare rate-limiting rule on the sign-up paths), not the app's.
- **The cache is a bounded list with no TTL, not one key per domain.** One key means one read on the hot path and a size cap that is simply `slice(-500)`, where per-domain keys would need a separate index to bound them. It is insertion-ordered, not true LRU — a hit does not promote its entry, because that would put a Redis write on every refused sign-up. The read-modify-write is not atomic, so two instances adding different domains at once can lose one; the cost is one credit later, which is the right trade for a cache. Dropping the TTL makes an entry live until 500 newer domains evict it, so correcting a wrong verdict means deleting that single key and letting the list rebuild — cheap, but someone has to know the key exists. Redis is a cache, not a record: a flush or an `allkeys-lru` eviction silently drops the list, which costs credits and nothing else.
-- **Only a domain-shaped verdict may be cached by domain.** `disposable` is a property of the domain; `toxic`, `global_suppression`, `spamtrap` and `abuse` describe one mailbox, so caching those by domain would refuse every account on `gmail.com` after a single bad one. Allow-verdicts are not cached either, since a cached "this domain is fine" would skip the address-level checks for every other mailbox on it. Four tests pin each half of this.
+- **Only a domain-shaped verdict may be cached by domain.** `disposable` is a property of the domain; `toxic`, `global_suppression`, `spamtrap` and `abuse` describe one mailbox, so caching those by domain would refuse every account on `gmail.com` after a single bad one. Allow-verdicts are not cached either, since a cached "this domain is fine" would skip the address-level checks for every other mailbox on it. The dead-domain `invalid` verdicts are domain-shaped too and are still *not* cached: `no_dns_entries` can be a registrar hiccup or a zone mid-propagation, and a list with no TTL would refuse a legitimate domain until 500 newer entries evicted it. A dead domain also gives a bot nothing to come back for, so there is no repeat-hammer to bound — the captcha bounds the credit spend. `disposable` is the one verdict that is both domain-shaped and stable. Tests pin each of these.
- **One credit per address that has no account yet.** `requestCode` skips the check entirely for an existing identity, so a repeat sign-in costs nothing. A refused address creates no identity, so a bot re-hitting the same address does spend a credit per attempt; the rate limits and the captcha in front are what bound that. Running out of credits degrades to fail-open, not to an outage.
-- **Both paths refuse silently, each by mimicking its own legitimate outcome.** The lib only answers the question — `maySignUp` returns a boolean and throws nothing — because the two call sites need different disguises. `requestCode` returns the same `204` as a success, creating no identity and sending no code, so the card advances to "Enter your code" and none arrives. `signUp` throws `EMAIL_IS_NOT_VERIFIED` with the address, which is *exactly* what a real Cloud sign-up returns (the identity is created unverified, then `getOnboardingResponse` throws it), so the form renders its ordinary `CheckEmailNote`. Both mirror the silent-return [000027](./000027-email-sign-in-is-a-typed-code-on-the-existing-otp-primitive.md) already uses for the invitation check, for the same reason: a distinguishable answer turns a public endpoint into an oracle, here for "is this address disposable". `DOMAIN_NOT_ALLOWED` is therefore absent from this path entirely and means only the platform domain allow-list again. The cost is that a false positive is invisible to the member *and* to support: the only trace is the `address refused` log line, so that log is the sole way to answer "why did no code arrive".
+- **Both paths refuse silently, each by mimicking its own legitimate outcome.** The lib only answers the question — `maySignUp` returns a boolean and throws nothing — because the two call sites need different disguises. `requestCode` returns the same `204` as a success, creating no identity and sending no code, so the card advances to "Enter your code" and none arrives. `signUp` throws `EMAIL_IS_NOT_VERIFIED` with the address, which is *exactly* what a real Cloud sign-up returns (the identity is created unverified, then `getOnboardingResponse` throws it), so the form renders its ordinary `CheckEmailNote`. Both mirror the silent-return [000027](./000027-email-sign-in-is-a-typed-code-on-the-existing-otp-primitive.md) already uses for the invitation check, for the same reason: a distinguishable answer turns a public endpoint into an oracle, here for "is this address disposable". `DOMAIN_NOT_ALLOWED` is therefore absent from this path entirely and means only the platform domain allow-list again; the Google path disguises itself as `INVALID_CREDENTIALS` for the same reason. The cost is that a false positive is invisible to the member *and* to support: the only trace is the `address refused` log line, so that log is the sole way to answer "why did no code arrive".
- **A mimicked response has to match the real one down to value normalization.** The first cut echoed `params.email` as submitted while the genuine path echoes it lowercased, having read it back from the stored identity — so a mixed-case address came back `[email protected]` on a refusal and `[email protected]` on a real sign-up, which is a perfectly good oracle. Any future mimicry needs the same `toLowerCase().trim()` the identity service applies. The test that pins this asserts `toEqual` against the whole body, not just the code, which is what caught it.
-- **The reject set is domain-flavoured, so the error stayed `DOMAIN_NOT_ALLOWED`.** No new error code and no web change. If `invalid` is ever added to the reject set, that message ("Email domain is disallowed") becomes wrong for the address-level cases and needs its own code.
+- **The reject set stays domain-flavoured, so there is no new error code.** Every refused verdict is a property of the domain or a mailbox flagged for abuse — never "this honest mailbox does not exist" — so the silent mimicry above holds with nothing distinguishable to show. The mailbox-level `invalid` sub-statuses stay out for that reason: adding one would reopen the oracle and would need its own, honest error.
- **The offline blocklist survives only inside the purge script**, which classifies existing identities in bulk and must run without spending a credit per row. `disposable-email-domains` stays a runtime dependency for it — the runtime image installs with `bun install --production`, so a `devDependency` would not exist where that script runs.
- A member who already holds an accepted invitation is never refused, unchanged from the blocklist behaviour.
diff --git a/docs/install/reference/environment-variables.mdx b/docs/install/reference/environment-variables.mdx
index 664c46cac87..3494d724274 100644
--- a/docs/install/reference/environment-variables.mdx
+++ b/docs/install/reference/environment-variables.mdx
@@ -284,18 +284,32 @@ self-hosted instance needs neither a Cloudflare nor a ZeroBounce account.
| Variable | Description | Default |
|---|---|---|
-| `AP_ZEROBOUNCE_API_KEY` | ZeroBounce API key. Set it to check each new address against ZeroBounce before an account is created. | `None` |
+| `AP_ZEROBOUNCE_API_KEY` | ZeroBounce API key. Set it to check each new address against ZeroBounce before an account is created, whether it arrives through the sign-up form or through Sign in with Google. | `None` |
| `AP_TURNSTILE_SITE_KEY` | Cloudflare Turnstile site key. Public; served to the sign-in page. | `None` |
| `AP_TURNSTILE_SECRET_KEY` | Cloudflare Turnstile secret key, used to verify a solved challenge. | `None` |
With `AP_ZEROBOUNCE_API_KEY` set, a sign-up is refused when ZeroBounce reports
the address as disposable, toxic, a spam trap, an abuse address or globally
-suppressed. Role addresses such as `info@` and `sales@` are accepted, and so is
-an address whose mailbox ZeroBounce cannot confirm. A member who already holds an
-accepted invitation is never refused. One credit is spent per address, and only
-for an address that has no account yet. If ZeroBounce cannot be reached, or
-answers that the key is invalid or out of credits, the sign-up is allowed through
-and the reason is logged — a validation outage never blocks sign-up.
+suppressed, or reports that its domain cannot receive mail at all: no DNS
+records, a send-only domain, or a mail server at an unroutable address. Role
+addresses such as `info@` and `sales@` are accepted, and so is an address whose
+mailbox ZeroBounce cannot confirm. A member who already holds an accepted
+invitation is never refused. One credit is spent per address, and only for an
+address that has no account yet. If ZeroBounce cannot be reached, or answers
+that the key is invalid or out of credits, the sign-up is allowed through and
+the reason is logged — a validation outage never blocks sign-up.
+
+The check covers the two public doors — password sign-up and Sign in with
+Google — and skips accounts a platform provisions itself through SSO (SAML) or
+embedding (managed authentication), since those are vouched for by the platform.
+A Google sign-up costs a credit only the first time an address is seen. A refused
+Google sign-up answers exactly like a failed Google token exchange
+(`INVALID_CREDENTIALS`) and the page shows a generic "Sign-in failed", so the
+response never says *why*; as on the email path, the server log is the only
+record.
+
+ZeroBounce resolves DNS from the public internet. If your members' mail domains
+are only resolvable inside your own network, leave the key unset.
Both refusals are silent: the emailed-code request answers exactly as a served
one does and the sign-in page moves to the code step, while password sign-up
diff --git a/packages/server/api/src/app/authentication/authentication.service.ts b/packages/server/api/src/app/authentication/authentication.service.ts
index 59ac880c814..3f017418ac4 100644
--- a/packages/server/api/src/app/authentication/authentication.service.ts
+++ b/packages/server/api/src/app/authentication/authentication.service.ts
@@ -14,17 +14,14 @@ import { zerobounce } from './lib/zerobounce'
import { otpService } from './otp/otp-service'
import { userIdentityService } from './user-identity/user-identity-service'
+const PLATFORM_CONTROLLED_PROVIDERS = new Set([UserIdentityProvider.JWT, UserIdentityProvider.SAML])
+
export const authenticationService = (log: FastifyBaseLogger) => ({
async signUp(params: SignUpParams): Promise<AuthenticationResult> {
- if (params.provider === UserIdentityProvider.EMAIL) {
+ if (requiresSignUpAbuseCheck(params.provider)) {
const maySignUp = await zerobounce.maySignUp({ email: params.email, log })
if (!maySignUp) {
- throw new ActivepiecesError({
- code: ErrorCode.EMAIL_IS_NOT_VERIFIED,
- params: {
- email: params.email.toLowerCase().trim(),
- },
- })
+ throw refusedSignUpError(params)
}
}
const platformId = params.platformId
@@ -273,6 +270,24 @@ async function selectCloudSignInPlatformIdByEmail({ email, log }: SelectCloudSig
+function requiresSignUpAbuseCheck(provider: UserIdentityProvider): boolean {
+ return !PLATFORM_CONTROLLED_PROVIDERS.has(provider)
+}
+
+function refusedSignUpError({ email, provider }: SignUpParams): ActivepiecesError {
+ const normalizedEmail = email.toLowerCase().trim()
+ if (provider === UserIdentityProvider.EMAIL) {
+ return new ActivepiecesError({
+ code: ErrorCode.EMAIL_IS_NOT_VERIFIED,
+ params: { email: normalizedEmail },
+ })
+ }
+ return new ActivepiecesError({
+ code: ErrorCode.INVALID_CREDENTIALS,
+ params: null,
+ })
+}
+
type SelectCloudSignInPlatformIdParams = {
identityId: string
}
diff --git a/packages/server/api/src/app/authentication/lib/zerobounce.ts b/packages/server/api/src/app/authentication/lib/zerobounce.ts
index 099a9d833d2..e97f415201a 100644
--- a/packages/server/api/src/app/authentication/lib/zerobounce.ts
+++ b/packages/server/api/src/app/authentication/lib/zerobounce.ts
@@ -14,7 +14,10 @@ const DISPOSABLE_DOMAIN_CACHE_KEY = 'zerobounce:disposable-domains:v1'
const DISPOSABLE_DOMAIN_CACHE_SIZE = 500
const REFUSED_STATUSES = new Set(['spamtrap', 'abuse'])
-const REFUSED_DO_NOT_MAIL_SUB_STATUSES = new Set(['disposable', 'toxic', 'possible_trap', 'global_suppression'])
+const REFUSED_SUB_STATUSES = new Map<string, Set<string>>([
+ ['do_not_mail', new Set(['disposable', 'toxic', 'possible_trap', 'global_suppression'])],
+ ['invalid', new Set(['no_dns_entries', 'does_not_accept_mail', 'unroutable_ip_address'])],
+])
function apiKey(): string | undefined {
const raw = system.get(AppSystemProp.ZEROBOUNCE_API_KEY)?.trim()
@@ -35,7 +38,7 @@ function refusedBy(verdict: ValidateResponse): boolean {
if (REFUSED_STATUSES.has(status)) {
return true
}
- return status === 'do_not_mail' && REFUSED_DO_NOT_MAIL_SUB_STATUSES.has(verdict.sub_status?.toLowerCase() ?? '')
+ return REFUSED_SUB_STATUSES.get(status)?.has(verdict.sub_status?.toLowerCase() ?? '') ?? false
}
function isDisposableVerdict(verdict: ValidateResponse): boolean {
diff --git a/packages/server/api/test/integration/cloud/authn/federated-authn.test.ts b/packages/server/api/test/integration/cloud/authn/federated-authn.test.ts
new file mode 100644
index 00000000000..d0573e50334
--- /dev/null
+++ b/packages/server/api/test/integration/cloud/authn/federated-authn.test.ts
@@ -0,0 +1,127 @@
+import { safeHttp } from '@activepieces/server-utils'
+import { FastifyInstance } from 'fastify'
+import { StatusCodes } from 'http-status-codes'
+import { databaseConnection } from '../../../../src/app/database/database-connection'
+import { redisConnections } from '../../../../src/app/database/redis-connections'
+import { mockAndSaveBasicSetup } from '../../../helpers/mocks'
+import { setupTestEnvironment, teardownTestEnvironment } from '../../../helpers/test-setup'
+
+const FRESH_TENANT_EMAIL = '[email protected]'
+const DISPOSABLE_DOMAIN_CACHE_KEY = 'zerobounce:disposable-domains:v1'
+
+const googleAccount = vi.hoisted(() => ({
+ email: '[email protected]',
+ firstName: 'user',
+ lastName: '01',
+}))
+
+vi.mock('../../../../src/app/ee/authentication/federated-authn/google-authn-provider', () => ({
+ googleAuthnProvider: () => ({
+ getLoginUrl: () => Promise.resolve('https://accounts.google.com/o/oauth2/v2/auth'),
+ authenticate: () => Promise.resolve(googleAccount),
+ }),
+}))
+
+let app: FastifyInstance | null = null
+
+function answersAboutTheAddress(verdict: { status: string, sub_status: string }) {
+ const realGet = safeHttp.axios.get.bind(safeHttp.axios)
+ return vi.spyOn(safeHttp.axios, 'get').mockImplementation((url, config) => {
+ if (String(url).includes('zerobounce')) {
+ return Promise.resolve({ data: verdict })
+ }
+ return realGet(url, config)
+ })
+}
+
+async function claimWithGoogle() {
+ return app?.inject({
+ method: 'POST',
+ url: '/api/v1/authn/federated/claim',
+ body: {
+ providerName: 'google',
+ code: 'authorization-code',
+ },
+ })
+}
+
+async function storedIdentity() {
+ return databaseConnection().getRepository('user_identity').findOneBy({ email: googleAccount.email })
+}
+
+beforeAll(async () => {
+ app = await setupTestEnvironment({ fresh: true })
+})
+
+afterAll(async () => {
+ await teardownTestEnvironment()
+})
+
+beforeEach(async () => {
+ process.env.AP_GOOGLE_CLIENT_ID = 'test-google-client-id'
+ process.env.AP_GOOGLE_CLIENT_SECRET = 'test-google-client-secret'
+ process.env.AP_ZEROBOUNCE_API_KEY = 'test-api-key'
+ googleAccount.email = FRESH_TENANT_EMAIL
+ const redis = await redisConnections.useExisting()
+ await redis.del(DISPOSABLE_DOMAIN_CACHE_KEY)
+ await mockAndSaveBasicSetup()
+})
+
+afterEach(() => {
+ delete process.env.AP_GOOGLE_CLIENT_ID
+ delete process.env.AP_GOOGLE_CLIENT_SECRET
+ delete process.env.AP_ZEROBOUNCE_API_KEY
+ vi.restoreAllMocks()
+})
+
+describe('Federated Authentication API', () => {
+ describe('Claim Endpoint', () => {
+ it('refuses a Google sign-up whose domain cannot receive mail exactly like a failed token exchange, and creates nothing', async () => {
+ const answer = answersAboutTheAddress({ status: 'invalid', sub_status: 'no_dns_entries' })
+
+ const response = await claimWithGoogle()
+
+ expect(response?.statusCode).toBe(StatusCodes.UNAUTHORIZED)
+ expect(response?.json()?.code).toBe('INVALID_CREDENTIALS')
+ expect(response?.json()?.params).toBeNull()
+ expect(answer).toHaveBeenCalledTimes(1)
+ expect(await storedIdentity()).toBeNull()
+ })
+
+ it('refuses a disposable Google address the same way the sign-up form does, and remembers the domain', async () => {
+ googleAccount.email = '[email protected]'
+ const answer = answersAboutTheAddress({ status: 'do_not_mail', sub_status: 'disposable' })
+
+ const response = await claimWithGoogle()
+
+ expect(response?.statusCode).toBe(StatusCodes.UNAUTHORIZED)
+ expect(response?.json()?.code).toBe('INVALID_CREDENTIALS')
+ expect(await storedIdentity()).toBeNull()
+
+ answer.mockClear()
+ googleAccount.email = '[email protected]'
+ const secondResponse = await claimWithGoogle()
+
+ expect(secondResponse?.statusCode).toBe(StatusCodes.UNAUTHORIZED)
+ expect(answer).not.toHaveBeenCalled()
+ })
+
+ it('asks ZeroBounce once for a new Google address, lets a valid one in verified, and never asks again for that account', async () => {
+ const answer = answersAboutTheAddress({ status: 'valid', sub_status: '' })
+
+ const signUp = await claimWithGoogle()
+
+ expect(signUp?.statusCode).toBe(StatusCodes.OK)
+ expect(answer).toHaveBeenCalledTimes(1)
+ const identity = await storedIdentity()
+ expect(identity?.verified).toBe(true)
+ expect(identity?.provider).toBe('GOOGLE')
+
+ answer.mockClear()
+ const signIn = await claimWithGoogle()
+
+ expect(signIn?.statusCode).toBe(StatusCodes.OK)
+ expect(answer).not.toHaveBeenCalled()
+ })
+ })
+})
diff --git a/packages/server/api/test/integration/cloud/managed-authn/external-token.test.ts b/packages/server/api/test/integration/cloud/managed-authn/external-token.test.ts
index c9c1a86a220..0a109ad31f9 100644
--- a/packages/server/api/test/integration/cloud/managed-authn/external-token.test.ts
+++ b/packages/server/api/test/integration/cloud/managed-authn/external-token.test.ts
@@ -1,4 +1,5 @@
import { apId, ProjectRole } from '@activepieces/core-utils'
+import { safeHttp } from '@activepieces/server-utils'
import { DefaultProjectRole, PieceSelectionMode, PiecesFilterType } from '@activepieces/shared'
import { FastifyInstance } from 'fastify'
import { StatusCodes } from 'http-status-codes'
@@ -83,6 +84,38 @@ describe('Managed Authentication API', () => {
expect(responseBody?.token).toBeDefined()
})
+ it('never asks ZeroBounce about a managed-auth sign-up, since the platform vouches for it', async () => {
+ const { mockPlatform } = await mockAndSaveBasicSetup()
+ const mockSigningKey = createMockSigningKey({
+ platformId: mockPlatform.id,
+ })
+ await db.save('signing_key', mockSigningKey)
+ const { mockExternalToken } = generateMockExternalToken({
+ platformId: mockPlatform.id,
+ signingKeyId: mockSigningKey.id,
+ })
+ process.env.AP_ZEROBOUNCE_API_KEY = 'test-api-key'
+ const answer = vi.spyOn(safeHttp.axios, 'get')
+
+ try {
+ const response = await app?.inject({
+ method: 'POST',
+ url: '/api/v1/managed-authn/external-token',
+ body: {
+ externalAccessToken: mockExternalToken,
+ },
+ })
+
+ expect(response?.statusCode).toBe(StatusCodes.OK)
+ expect(response?.json()?.verified).toBe(true)
+ expect(answer).not.toHaveBeenCalled()
+ }
+ finally {
+ delete process.env.AP_ZEROBOUNCE_API_KEY
+ answer.mockRestore()
+ }
+ })
+
it('Creates new project', async () => {
// arrange
const { mockPlatform } = await mockAndSaveBasicSetup()
diff --git a/packages/server/api/test/unit/app/authentication/zerobounce.test.ts b/packages/server/api/test/unit/app/authentication/zerobounce.test.ts
index 2c12f7f2cd8..5963c8e4d94 100644
--- a/packages/server/api/test/unit/app/authentication/zerobounce.test.ts
+++ b/packages/server/api/test/unit/app/authentication/zerobounce.test.ts
@@ -77,6 +77,9 @@ describe('zerobounce', () => {
{ status: 'do_not_mail', sub_status: 'global_suppression' },
{ status: 'spamtrap', sub_status: '' },
{ status: 'abuse', sub_status: '' },
+ { status: 'invalid', sub_status: 'no_dns_entries' },
+ { status: 'invalid', sub_status: 'does_not_accept_mail' },
+ { status: 'invalid', sub_status: 'unroutable_ip_address' },
])('refuses $status/$sub_status', async (verdict) => {
answers(verdict)
expect(await maySignUp()).toBe(false)
@@ -86,8 +89,11 @@ describe('zerobounce', () => {
{ status: 'valid', sub_status: '' },
{ status: 'catch-all', sub_status: '' },
{ status: 'unknown', sub_status: 'greylisted' },
+ { status: 'invalid', sub_status: '' },
{ status: 'invalid', sub_status: 'mailbox_not_found' },
{ status: 'invalid', sub_status: 'possible_typo' },
+ { status: 'invalid', sub_status: 'mailbox_quota_exceeded' },
+ { status: 'invalid', sub_status: 'failed_syntax_check' },
{ status: 'do_not_mail', sub_status: 'role_based' },
{ status: 'do_not_mail', sub_status: 'role_based_catch_all' },
{ status: 'do_not_mail', sub_status: 'mx_forward' },
@@ -198,6 +204,17 @@ describe('zerobounce', () => {
expect(mockStorePut).not.toHaveBeenCalled()
})
+ it.each([
+ { status: 'invalid', sub_status: 'no_dns_entries' },
+ { status: 'invalid', sub_status: 'does_not_accept_mail' },
+ { status: 'invalid', sub_status: 'unroutable_ip_address' },
+ ])('never caches the domain-level verdict $status/$sub_status, so a transient DNS failure cannot poison the list', async (verdict) => {
+ answers(verdict)
+
+ expect(await maySignUp('[email protected]')).toBe(false)
+ expect(mockStorePut).not.toHaveBeenCalled()
+ })
+
it('does not cache an allow verdict, so an address-level refusal is never skipped', async () => {
answers({ status: 'valid', sub_status: '' })
diff --git a/packages/web/src/app/routes/redirect.tsx b/packages/web/src/app/routes/redirect.tsx
index e0a26bb42a2..6146dc09306 100644
--- a/packages/web/src/app/routes/redirect.tsx
+++ b/packages/web/src/app/routes/redirect.tsx
@@ -47,16 +47,17 @@ const RedirectPage: React.FC = React.memo(() => {
}
navigate(from);
} catch (e) {
- if (
- api.isError(e) &&
- (e.response?.data as { code: ErrorCode })?.code ===
- ErrorCode.INVITATION_ONLY_SIGN_UP
- ) {
+ const errorCode = api.isError(e)
+ ? (e.response?.data as { code: ErrorCode })?.code
+ : undefined;
+ if (errorCode === ErrorCode.INVITATION_ONLY_SIGN_UP) {
toast(t('Invitation only sign up'), {
description: t(
'Please ask your administrator to add you to the organization.',
),
});
+ } else if (errorCode === ErrorCode.INVALID_CREDENTIALS) {
+ toast(t('Sign-in failed'));
} else {
internalErrorToast();
}