IntegrationsRoute lock

Integrations

Lock your website to the routes visitors use

The route lock answers every route and method your visitors never use with a 404 or 405, before your app sees the request.

The route lock is part of the live Defense Agent. It knows every route and method a visitor of your website uses, and answers everything else itself, before your app sees the request. A route nobody visits, such as an admin page or a debug page, gets a 404. A visitor's route asked with the wrong method, such as a POST to a page that only answers GET, gets a 405. Each website project has its own route lock, on its Live page. Any member can see it; owners and admins change it.

The route lock needs @isagentproof/live 0.2.0 or later in your app's container, in process or as a proxy.

Turn on the route lock

  1. Install the live Defense Agent

    Follow Live Defense Agent. Add the install key while the website project is the current project: the key's containers get that project's route map.

  2. Map the routes

    Open Live and press Map routes on the Route lock card. AgentProof reads your website, as described below, and builds the Route map.

  3. Start in Monitor

    Choose Monitor under Mode and press Save. Every request still reaches your app. The Would deny card lists what the lock would have refused.

  4. Turn on Enforce

    When Would deny shows nothing your visitors need, choose Enforce and press Save.

Enforce is offered at once when your app or your build has sent its routes (see Send your app's routes). Otherwise it opens after 7 days in Monitor.

What the modes do

What the modes do
ModeWhat happens
OffNothing is checked. This is where every project starts.
MonitorEvery request reaches your app. Requests the lock would refuse are counted on the Would deny card, with what your app answered.
EnforceRoutes that are not on the map, and locked routes, get a 404. A wrong method on an open route gets a 405 with an Allow header that lists the methods the route takes.

Pause in Settings > Live protection turns Enforce into Monitor until you turn it off.

Refused requests get the same Protected by AgentProof answer as other refusals: a short page for browsers, JSON for API clients, and a reference you can look up with Find a refused request. See Live Defense Agent.

Where the route map comes from

AgentProof builds each website project's map from these sources:

  • Your app's own routes. The agent in your app reads the routes your app registers with Express, Fastify or Koa (with @koa/router), and the pages, route handlers and server actions in a built Next.js app. It sends paths and methods only, never code.
  • A build-time map from agentproof-live map, for Next.js, Laravel, Rails, Django and OpenAPI files, or the WordPress plugin. See Send your app's routes.
  • The crawl. Map routes loads your website's pages the way a visitor does.
  • Your choices on the Route map card. They always win.

How each route is sorted

  • Your own choice comes first.
  • Then routes a source marks as locked, and what AgentProof knows about WordPress: /wp-admin/, wp-login.php, xmlrpc.php and the users REST route stay locked even when a page links to them.
  • Routes your app lists that the crawl reached are open, with your app's methods.
  • Routes your app lists that the crawl never reached are locked. A route whose name says webhook or callback is open only to callers that send a signature header (Stripe, GitHub, Shopify, Slack, Twilio, PayPal, Svix and others). /health, /healthz, /ready, /readyz, /livez, /up, /ping and /status are open only to requests from private and loopback addresses.
  • Until a crawl has finished, routes your app lists stay open, except names such as admin, internal, debug and metrics, which are locked.
  • Routes only the crawl saw are open, with the methods the crawl saw.

The map holds at most 5,000 routes.

Map routes with the crawl

Map routes loads your website from AgentProof's own browser:

  • It starts at the home page, your sitemap.xml (sitemap indexes too) and the Sitemap: lines of robots.txt, then follows the links it finds on your website.
  • It loads pages with GET only, never submits a form and never clicks. It skips links that look like sign out, delete, remove or cancel.
  • It records each page's links, its forms (where they post, with which method), the requests the page's own scripts make, and the addresses in your website's own JavaScript.
  • It reads at most 300 pages in 5 minutes, 2 pages a second.
  • It only crawls the project's verified and confirmed website.

The crawl also runs by itself once a week while the route lock is on, and after a deploy test, at most once an hour.

Its time counts as agent hours, rounded up to the minute. While it runs it holds 15 minutes.

Crawl signed in

To map the pages members see, choose a test account under Crawl signed in as and press Save. The list shows this website's accounts from Settings > Test access (see Test access). The crawl signs in once on the account's login page (or /login when the account has none), then loads pages with GET only, as above. The account's values stay sealed and are never stored with the map.

Change the route map

The Route map card lists each route with whether it is open, open to callers with a signature, open to health checks, or locked, its methods and where it came from. Type in Filter to find routes. The card shows 200 routes at a time.

  • Open lets visitors use the route.
  • Lock closes it to everyone but unlocked browsers.
  • Remove takes it off the map, so it gets a 404.

Your choice shows as Your choice, and a new crawl or a new app map never changes it.

Allow what the lock would deny

The Would deny card lists the last 7 days of refused or would-be-refused requests: the method and path, Would 404 or Would 405 in Monitor (404 or 405 in Enforce), how many times, and what your app answered. An answer such as 200 or 302 means your app has that route. Press Allow to open it for that method.

Ids and numbers in paths are folded, so /orders/17 and /orders/18 show as one row and Allow opens /orders/:id.

How requests are matched

  • The query string does not matter, except WordPress's rest_route and WooCommerce's wc-ajax, which are matched as the routes they open.
  • On PHP websites, /index.php/ in front of a path is matched as the path.
  • Paths that hide another path are refused with a 404: . and .. segments, an encoded / or `, NUL characters, double encoding and ;` parameters.
  • // counts as /. In Enforce your app receives the path with // collapsed. A trailing / matches the same route.
  • Letters match in any case.
  • HEAD goes wherever GET goes. OPTIONS passes only as a browser's CORS preflight for a method the route takes. TRACE, CONNECT and WebDAV methods never pass.
  • A POST with X-HTTP-Method-Override, X-HTTP-Method, X-Method-Override or _method (in the query or the form) is checked as the method it asks for.
  • On Next.js, a POST to a page passes only with one of that page's server action ids.

Unlock locked routes

Owners and admins can open locked routes in their own browser for an hour with a passkey and the AgentProof Unlock extension. See Unlock locked routes.

Messages you may see

Messages you may see
MessageWhat to do
Map routes first.Press Map routes, or send your app's routes, before choosing Enforce.
Enforce opens after 7 days of Monitor, or when your app or build sends its routes.Keep Monitor on, or send your app's routes.
A crawl of this website is already running.Wait for it to finish.
No agent hours are left this month.The crawl uses agent hours. See Plans.
Choose one of this website's test accounts.Pick an account from the list, or add one in Settings > Test access.
Choose a website project first.Switch to a website project. Repository and app projects have no route map.
Only owners and admins can change the route lock.Ask an owner or admin.
Last crawl failedThe message after it says why. Check that the website answers, then press Map routes again.

Last updated