Bot Prevention
Menu

Get started

How it works

The components that the stack installs in your AWS account, and what happens when a visitor verifies.

Architecture

Architecture: the components in your AWS account and the services outside itYour AWS account · us-east-1Visitorweb browserWorld Appvisitor's phoneCloudFront + AWS WAFBot Control, World ID rulesChallenge assetsS3 · /__wid/assets/*Session checkCloudFront FunctionVerification APILambda · /__wid/api/*Your originunchangedCookie keysSecrets Manager, key storeSigning keyAWS KMS, created by youReplay stateDynamoDBDeveloper PortalWorld IDWorld billingAWS Marketplace usageverify proofQR code, proofcountIn your AWS accountOutside your account
Everything that handles visitor requests, keys and cookies runs in your AWS account.

Your CloudFront distribution and its AWS WAF Web ACL receive every request, as before. The stack adds rules to the Web ACL, a session check to your cache behaviors and two reserved routes, /__wid/api/* and /__wid/assets/*. Your origins, cache behaviors and other WAF rules stay.

Three services outside your account take part:

  • World App on the visitor's phone creates the proof.
  • World ID Developer Portal verifies proofs for your World ID app.
  • World runs the registration and setup pages, publishes the CloudFormation template and the release files that your stack loads, links your RP to your subscription when the stack asks, and reports your verification count to AWS Marketplace.

What the stack installs

ComponentAWS servicePurpose
Bot Control ruleAWS WAF managed rule groupLabels likely bots. With enforce, it also blocks bots that identify themselves and that AWS cannot verify.
World ID rule groupAWS WAF rule groupFlags the requests that need a verified session. Rate limits the verification API.
Session checkCloudFront Function (viewer request)Checks the session cookie of flagged requests and returns the challenge page when it is missing.
Verification APIAWS Lambda behind /__wid/api/*Starts and verifies World ID requests and issues session cookies. Only your distribution can call it.
Challenge assetsPrivate S3 bucket behind /__wid/assets/*The script and styles of the challenge page, pinned to the installed release.
Cookie keysSecrets Manager and CloudFront KeyValueStoreSign and check session cookies. Generated in your account.
Replay stateDynamoDBOne record per verified World ID and window, and a per-minute verification budget.
Alarms and logsCloudWatch, optional SNSAlarms for API errors and refused verifications. Logs expire after 365 days.

In automatic mode the stack also changes your distribution and Web ACL: it adds two origins and the /__wid/api/* and /__wid/assets/* behaviors, associates the session check with every behavior as its viewer-request function, adds the Bot Control rule and the World ID rule group to the Web ACL, attaches the Web ACL if the stack created it, and, if you choose, inserts the AWS WAF script into your pages. Uninstalling removes exactly these changes. Resources-only mode changes nothing on your distribution or Web ACL.

You create the RP signing key in AWS KMS yourself. The stack only gets permission to sign with it. Three IAM execution roles let the stack's Lambda functions work with these resources. See IAM permissions.

When a visitor must verify

AWS WAF flags a request when one of these conditions is true:

  • AWS WAF Bot Control gives it a bot label of medium or higher confidence: very high request volume in one browser session, coordinated activity across clients, or one AWS WAF token reused across several IP addresses, networks or countries.
  • The path is one that you always verify, such as /account or the whole site.

The session check then lets the request through if it has a valid session cookie. Otherwise, it returns the challenge page. Requests that AWS WAF does not flag never wait for a check. Bot Control does not label verified bots, such as the crawlers of large search engines.

Bot Control needs the AWS WAF script on your pages for most of its labels. The stack can insert it for you. See AWS WAF script.

Verification flow

Verification sequence between the browser, your CloudFront distribution, your verification API, World App and Developer PortalBrowservisitorCloudFrontyour accountVerification APIyour accountWorld Appvisitor's phoneDeveloper PortalWorld ID1Open a protected page2Challenge page (403)3Start, through CloudFront4Request signed with your KMS key5QR code or deep link6Zero-knowledge proof7Verify, through CloudFront8Verify proof9Valid10Session cookie, after the replay check11Reload the page
The browser calls the verification API through your CloudFront distribution. After the reload, CloudFront forwards the request to your origin.
  1. The challenge page loads its script from /__wid/assets/ on your domain.
  2. The verification API creates a World ID request for your app and signs it with your KMS key. It sets a short-lived challenge cookie.
  3. The visitor approves the request in World App, which returns a proof.
  4. The verification API checks the proof with Developer Portal. Then it records the proof's nullifier in DynamoDB, so the same World ID cannot get a second session in this window.
  5. The API sets the session cookie and the page reloads. If the network fails, the page retries for up to five minutes without asking for a new proof.

Sessions and uniqueness

The session cookie, __Host-wid_s, is signed with your cookie key and is valid only for the hostname where the visitor verified. It lasts for the session length (WindowSeconds, 24 hours by default) from the start of the verification.

Uniqueness uses fixed windows of the same length. With the default, a window is one UTC day. Each World ID can verify once per window on one installation, across all hostnames of the distribution. A visitor who clears cookies or changes device in the same window sees Already verified and can verify again in the next window.

Single-page apps and API requests

The challenge page works for page navigations. When a flagged fetch or XMLHttpRequest call has no valid session, CloudFront returns 403 with the header X-WID: challenge and the body {"error":"wid_challenge"}. It also sets a cookie for five minutes, so the next page navigation shows the challenge even if AWS WAF does not flag it.

Handle this response in your app: reload the page, so the visitor sees the challenge and comes back to the same page.

JavaScript

const response = await fetch("/api/cart", { method: "POST", body });
if (response.status === 403 && response.headers.get("x-wid") === "challenge") {
  window.location.reload();
}

The browser does not send a form or request body again after verification. After a challenged form submission, the visitor returns to the previous page and submits again.

Data and privacy

WhereWhat it holds
Your AWS accountVisitor traffic, the RP signing key, cookie keys, session cookies, nullifiers and logs.
WorldYour registration details, AWS account ID, World ID app ID and RP ID, and an hourly count of your verifications. You enter your AWS settings in CloudFormation, so World does not receive them. World never receives proofs, nullifiers, cookies or keys.
Developer PortalThe proofs that your verification API sends to it, and one nullifier per World ID and window, which it uses to count verifications.
VisitorShares no personal data. A nullifier is specific to your app and window, so it does not link a visitor across websites.

How World handles the data it holds about your subscription:

World
CollectionYour company name, contact person, contact phone and email from the registration page; your AWS account ID, license and agreement from AWS Marketplace; your World ID app ID and RP ID from your stack; and the hourly number of new verifications of your RP from Developer Portal.
StorageAmazon DynamoDB in World's AWS accounts in us-east-1, encrypted at rest. Your contact details are in two places, both World's: the registration page's table in World's AWS Marketplace seller account, and World's registration records. Both are apart from your billing records. The registration page also logs its requests, with your contact details, in Amazon CloudWatch Logs in the seller account.
UseTo contact you about your subscription and set up World ID with you, to link your RP to your subscription, and to report your usage to AWS Marketplace.
SharingAWS Marketplace receives your hourly usage with your AWS account ID and license. Your contact details go only to the World ID team and are not shared with AWS.
RetentionContact details stay until you ask for their deletion at botprevention@toolsforhumanity.com, or until the EULA no longer needs them. World then deletes them in both places. The registration page's logs expire after a retention period that World sets. Billing records and your RP binding stay for billing reconciliation. Setup links expire after 14 days and setup sessions after one hour.
BackupWorld's registration records and billing records use DynamoDB point-in-time recovery, with deletion protection on the tables. The registration page's table has no backup.

Billing

Every hour, World asks Developer Portal for the number of new production verifications of your RP and reports that number to AWS Marketplace. Nothing in your account reports usage, and World receives the count only.

  • Page loads with a valid session and retries of the same proof are free.
  • A shorter session length means more windows, and so more billed verifications per visitor.
  • In rare cases, Developer Portal accepts a proof that your installation then rejects, for example after a storage failure. Such a verification is still counted.
  • Cancelling the subscription does not switch off protection. Uninstall the stack, or switch to monitor-only mode, if you no longer want challenges.