All docsEnterprise access controlsSelf-verify

Security advisory 2026-11-18

TOKENLOCK could report a route, method or environment as authorized when no route policy applied to it. Fixed in SDK 0.4.0, PHP drop-in 0.4.0 and the hosted API. Current release: 0.4.4 (security correction: validation and policy-expiry checks that ran on only some code paths, see 0.4.4 update; 0.4.3 refused malformed authorization requests, see 0.4.3 update). 0.4.3 and 0.4.2 are deprecated.

IDTOKENLOCK-2026-11-18
Published18 Nov 2026
Updated18 Nov 2026: hosted API denies every client version (9 PM PT); 0.4.1 documentation-only release and fail-closed guarantee added; 0.4.2 security-hardening release; 0.4.3 security correction (0.4.2 deprecated). 19 Nov 2026: 0.4.4 security correction (0.4.3 deprecated)
Componentsnpm SDK, now published as @tokenlock/sdk (versions up to 0.5.2 were published under its earlier package name; hosted client, Next/Express middleware, self-verify), PHP drop-in, Cloudflare worker example, hosted verify API
SeverityHigh for issue 1 (self-verify with no policy). Medium for issue 2 (token-only sites). Both need a valid pass from a current token holder; neither skips the signature, pass or token check.
Fixed innpm 0.4.0 (issue 1 alone: 0.3.3), PHP drop-in 0.4.0, Cloudflare example 0.4.0, hosted API (all clients, any version, since the 18 Nov 2026 9 PM PT deployment). Current: npm 0.4.4, PHP drop-in 0.4.4 and Cloudflare example 0.4.4 (security correction; 0.4.3 and 0.4.2 are deprecated)
BreakingYes, for token-only sites using the middleware or passing a path. See Upgrade.

Summary

The guarantee TOKENLOCK now gives in every supported integration: no protected action is authorized unless a policy explicitly permits it. A check that names a path, method or environment is allowed only when a route policy (registered keys) grants it. When no route policy applies, the answer is valid: false, allowed: false, code: "policy_required", with identity_valid: true if the pass itself is good. Identity-only checks (no path, method or environment) work as before.

Issues

1. Self-verify: a resource with no policy was allowed (High)

verifyLocalPass(pass, { passSecret, resource }) with no policy answered allowed: true, which reads as "route, method and environment were checked" when nothing checked them. The same happened with a token-mode policy (registered keys off), which has no route rules. The PHP self-verify (tokenlock_sv_verify_local_pass) behaved the same way.

Who is affected: servers using self-verify (Enterprise or pilot) that pass a resource and rely on allowed to restrict routes, but did not configure a registered-keys policy. A current token holder with a valid pass could be allowed on routes the integrator meant to restrict.

2. Token-only sites: route checks were answered "allowed" (Medium)

On a site with registered keys off (token-only), the hosted API has no route rules for the site. When a client sent a path, method or environment with a pass, the API still answered valid: true without checking them, and the SDK and PHP clients accepted that answer. So verifyPass(pass, { path }), getPass(req, { path }), authorize(...) and tokenlock_verify_pass($pass, $resource) returned a result that looked like a route decision.

Who is affected: integrations that call these with a resource on a token-only site and expect TOKENLOCK to restrict routes, methods or environments (for example, a site whose registered keys were never turned on, or were turned off). The middleware on a token-only site let every token holder into every protected path. That is the intended token-only behavior, but it was not explicit; 0.4.0 makes it an explicit setting.

Not affected: sites with registered keys turned on (routes, methods and environments were checked by the hosted API), identity-only checks, and SDK 0.1.x (it never sends a resource).

Affected and fixed versions

ComponentIssue 1 (self-verify, no policy)Issue 2 (token-only route checks)Fixed
npm SDK (now @tokenlock/sdk)0.3.0 – 0.3.2 (no policy); 0.3.0 – 0.3.3 (token-mode policy)0.2.0 – 0.3.30.4.0
PHP drop-in0.3.00.2.0 – 0.3.00.4.0
Cloudflare worker examplen/abefore 0.4.00.4.0 (header cf-worker/0.4.0)
Hosted verify APIn/abefore 18 Nov 202618 Nov 2026: about 8:49 PM PT for direct API calls and 0.4.0 clients; 9 PM PT deployment for every client, 0.2.x/0.3.x included (see note)

All versions fail closed against the hosted API (since the 18 Nov 2026 9 PM PT deployment). A check that names a path, method or environment on a token-only site answers policy_required to every client: SDK, PHP drop-in and Cloudflare example 0.2.x/0.3.x included, as well as 0.4.0 and direct API calls. From about 8:49 PM PT until then, 0.2.x/0.3.x clients were still given the old answer, marked policy: "none" with a warning; that transition answer is now off. What this means for older integrations: a token-only site still running 0.2.x/0.3.x middleware (or PHP tokenlock_require()) now denies protected paths instead of letting holders in. Upgrade to 0.4.4 (0.4.0 or later fixes this issue; 0.4.4 is current) and set tokenOnly / token_only, or use the workaround below. Issue 1 (self-verify) runs on your own server, so 0.3.x self-verify stays affected until you upgrade.

Fail-closed guarantee and its limits

In SDK and PHP drop-in 0.4.4 (0.4.3 except the 0.4.4 row; 0.4.2 except the 0.4.3 and 0.4.4 rows; 0.4.0 and 0.4.1 with the default settings), each of these denies:

SituationAnswer
0.4.4: a policy past its expires_at or issued more than 5 minutes in the future, wherever it is used (signed bundle, local policy, custom source, evaluate()); a token-mode policy asked about a resource in evaluate(); a missing or short self-verify pass secret; a malformed path given to verifyLocalPass()policy_expired / policy_invalid; policy_required; bad_secret; bad_path with valid: false
0.4.3: malformed authorization request (unknown field or option, path without method, empty, whitespace-only, padded, null or non-string value; no resource and no explicit identity-only), in every adapter and the hosted APIbad_resource; relative or non-canonical path bad_path. Never an identity-only check
A path, method or environment with no applicable route policy (token-only site, no tokenOnly / token_only)403 policy_required
SDK, PHP or Cloudflare clients 0.2.x/0.3.x sending a resource to the hosted API on a token-only sitepolicy_required (hosted API, every client version)
tokenOnly / token_only / TOKENLOCK_TOKEN_ONLY on a site with registered keysroute, method and environment still checked against the key
TOKENLOCK API unreachable, timing out or answering 5xx503 tokenlock_unavailable, nothing protected is served
Self-verify: policy bundle can't be loaded, is expired or has a bad signaturepolicy_unavailable / policy_expired
Self-verify: holdings source fails or sources disagreelookup_failed / lookup_disagreement
0.4.2: invalid configuration, including the removed options, unknown or mistyped options and a malformed secret keybad_config (SDK throws at startup; PHP and the Cloudflare worker answer 500 on protected paths)
0.4.2: self-verify policy that is malformed (bad dates, keys, permissions or structure)policy_invalid
0.4.2: API answer that is not JSON, not an object, over 64 KiB, or contradicts itself (for example valid: true with an error code, or a different resource echoed)bad_answer / conflicting_answer
0.4.2 hosted API: storage error reading a site's settings or access data, or malformed access data503 site_unavailable / access_unavailable, or access_data_invalid

Limits: in 0.4.0 and 0.4.1, failOpen: true / 'fail_open' => true and checkResource: false / 'check_resource' => false weakened this when set; 0.4.2 removed them. On hosted registered-keys sites, a pass younger than 2 × recheck_holdings_s keeps working during a holdings-source outage unless require_fresh_holdings is on; the route policy is still enforced. Self-verify runs on your server, so 0.3.x self-verify stays affected until you upgrade.

Upgrade

Node / Next / Express

npm install @tokenlock/sdk

This installs the current release (0.5.3 or later), which includes the 0.4.4 correction. 0.5.0 and later also deny some inputs 0.4.4 accepted: read the changelog before upgrading from 0.4.x.

Since 0.4.2 the client and middleware refuse failOpen, checkResource and strict: false with bad_config, and the middleware refuses unknown options. 0.4.3 also refuses unknown options and malformed authorization fields on every call (bad_resource) and needs { identityOnly: true } for an identity-only check (see 0.4.3). 0.4.4 closes the gaps in 0.4.4.

PHP drop-in

Cloudflare worker example

Copy worker.js from 0.4.4 (0.4.0 or later has the fix for issues 1 and 2; 0.4.4 also validates the resource given to strictCheck() and refuses inherited fields; 0.4.3 validates every authorization request and TOKENLOCK_ENVIRONMENT; 0.4.2 added a fail-closed fetch timeout and answers 500 if TOKENLOCK_FAIL_OPEN or TOKENLOCK_CHECK_RESOURCE is set) and, on a token-only site, set TOKENLOCK_TOKEN_ONLY = "1".

Breaking behavior in 0.4.0

SituationBefore0.4.0
Identity-only check (no resource)allowedallowed (unchanged)
Resource on a token-only sitevalid: true, nothing checkedpolicy_required, identity_valid: true
Resource with registered keyschecked against the keyunchanged
Self-verify resource, no policy or token-mode policyallowed: truepolicy_required
Middleware / tokenlock_require() on a token-only siteevery holder let in403 policy_required unless tokenOnly / token_only is set

Workarounds if you can't upgrade yet

Token-only site on 0.2.x/0.3.x middleware that should let every holder in: set checkResource: false (Node) or 'check_resource' => false (PHP) so the check is identity only. This turns strict mode off (with a warning) in those versions; upgrade to 0.4.3 with tokenOnly / token_only as soon as you can. These options were removed in 0.4.2.

How the fix was tested

A shared authorization matrix (identity only, resource without a policy, resource allowed by a policy, route denied, method denied, token-only with a resource, token-only identity, revoked key, expired pass, forged pass) runs against Node self-verify, PHP self-verify, and the hosted API through direct calls, the Node SDK client and the PHP client. All return the same allow/deny and code. Tests run against a local copy of the API plus end-to-end runs against production with the published packages. An independent security review is planned, not done.

Update: 0.4.4 security correction (19 Nov 2026), 0.4.3 deprecated

Two issues were reported by an external reviewer (issues 4 and 5). We then widened our audit: instead of testing the public entry points, which validate their input before calling down, we enumerated every exported function of the Node SDK, the PHP drop-in, the Cloudflare example and the hosted API and fuzzed each one with malformed, partial, expired and not-yet-valid inputs. That found issues 6 to 10. 0.4.4 (npm, PHP drop-in, Cloudflare example and hosted API) is a correction with no new features. Regression tests reproducing every issue were committed before the fixes and fail against npm 0.4.3 and the production PHP 0.4.3 package. npm 0.4.3 is deprecated; upgrade to 0.4.4. Each issue needs either a valid pass from a current holder or an integration that uses the affected function in the way described; none skips the wallet signature check.

#Issue in 0.4.3Affected0.4.4Severity
4Self-verify evaluate() returned allowed: true from its token-mode branch before looking at the resource: a normal resource, { pth: '/private' } and an array path were all allowed. verifyLocalPass() was not affected. Found by external review.Node evaluate(); PHP tokenlock_sv_evaluate() (valid resources)The request is validated before any mode branch; a token-mode policy with a resource is policy_required; identity is explicit (identityOnly: true; null is bad_resource)Medium (integrations calling evaluate() directly)
5An explicitly expired local policy (for example expires_at in January 2020) still authorized a valid local pass: only the signed-bundle path checked expiry. A policy issued in the future was refused only in signed bundles. Found by external review.Node localPolicy(), custom sources, evaluate(), verifyLocalPass(), verifySignIn(); PHP equivalentsEvery policy's validity window is checked against the current time wherever it is used: policy_expired / policy_invalidMedium
6verifyLocalPass() used whatever pass secret it was given: with an empty secret (for example an unset environment variable) it accepted passes anyone can forge with an empty key.Node verifyLocalPass() (passSecret: '' or short); PHP tokenlock_sv_verify_local_pass() (missing, empty or short)bad_secret unless the secret is at least 32 characters (the rule issuing already used)High when misconfigured; none otherwise
7verifyLocalPass() checks the path before the pass and answered { valid: true, allowed: false, code: 'bad_path' } for a malformed path, even with a garbage token.Node and PHP self-verifyvalid: false: valid: true is only answered after the pass is verifiedHigh for integrations that check only valid; none for those that check allowed
8held: null (or a non-list) skipped the holdings check in evaluate().Node, PHP, hosted internal access.evaluate()bad_inputLow
9Hosted lower-level functions (verifyPass, evaluate, checkResource, checkPass) accepted partial or malformed resources and checked only the parts they recognized (a method-only resource skipped the route rules; an array path was turned into a string). The public /api/v1/gate/verify validated first and was not affected.Hosted API internalsOne strict schema in every functionLow (not reachable from the public API)
10The hosted "site still accepts this token" check ran only when a secret key was sent: a pass verified without one kept unlocking a site that had dropped that token until the pass expired.Hosted /api/v1/gate/verify without a secret key (the SDKs always send one)Checked on every verify (not_holder); hosted fix live 19 Nov 2026, 6:48 AM PT, no action neededLow to Medium
–Cloudflare example: strictCheck(answer, resource) did not validate resource; verify() type-checked only own fields but read inherited ones.Cloudflare example helpersbad_resourceLow

Also corrected: both starter projects (examples/express, examples/next-app) depended on ^0.1.0, which excludes 0.4.x, and left out tokenOnly: true; the Next.js members page called getPass() with no request, which throws bad_resource since 0.4.3. They now depend on ^0.4.4, set tokenOnly: true and ask for identity explicitly; each was installed from npm, built and smoke-tested. The README described authorize() without a resource as resource_required with status 0 (it is bad_resource, 400), called PHP 0.4.2 current and told token-only callers to drop the resource without saying to pass identityOnly: true.

Why the 0.4.3 audit missed these. It tested each public entry point with malformed input. Those entry points validate before calling the lower-level functions, so the early-return branch inside evaluate(), the order of checks inside verifyLocalPass() and the hosted internals were never given bad input directly, and expiry was tested only on the signed-bundle path where it was implemented. 0.4.4 adds an enumeration-driven fuzzer for each codebase that fails if any export is unclassified, and checks time windows on every path that uses a policy.

Production regression on the published 0.4.4 packages (npm from the registry, the production PHP zip, the Cloudflare example, legacy clients): 251/251 on 19 Nov 2026 at 7:03 AM PT, including the reviewer’s cases and issue 10 against production. These are our own results, not an independent review.

Upgrade: npm install @tokenlock/sdk (0.5.3 or later, which includes 0.4.4); replace the PHP tokenlock/ files with the 0.4.4 package; copy worker.js 0.4.4. Calls to evaluate() must pass resource or identityOnly: true (PHP: array('identity_only' => true)) and a list for held. Remaining limits are unchanged. An independent security assessment is planned, not done.

Update: 0.4.3 security correction (18 Nov 2026), 0.4.2 deprecated

Issue 3 (found by our 0.4.2 production regression run). In npm 0.4.2, PHP drop-in 0.4.2, self-verify and the hosted /api/v1/gate/verify, an authorization field that was unknown or mistyped (for example pth), empty, whitespace-only, null or not a string was dropped, and the call fell back to an identity-only check. An identity-only check can answer valid: true, so code that passed a malformed resource and checked only valid could let a current holder reach a resource no route policy granted. It needs a valid pass from a current token holder and an integration that builds a malformed request; it skips no signature, pass or token check. Middleware, the Cloudflare worker and tokenlock_require() build well-formed requests from the HTTP request and were not affected in normal use. Severity: Medium. 0.4.2 also said "unknown options are refused"; that was true for the middleware only.

0.4.3 (npm, PHP drop-in, Cloudflare example and hosted API) is a correction with no new features. Regression tests reproducing the issue were committed before the fixes and fail against 0.4.2. npm 0.4.2 is deprecated (and 0.4.3 since 19 Nov 2026: upgrade to 0.4.4, the current release).

Request0.4.20.4.3 (every adapter and the hosted API)
Unknown field or option (pth, route, …)dropped → identity-onlybad_resource (SDK throws, PHP TokenlockException 400, self-verify and hosted answer valid: false)
Path without method, or method without pathpartial checkbad_resource
Empty, whitespace-only, padded, null or non-string path, method or environmentdropped or truncatedbad_resource (never truncated)
Relative path, traversal (/a/../b, %2e%2e), double-encoded (%252e), malformed escapesmostly bad_pathbad_path or a decision on the canonical path; never a grant outside the policy. A query string or fragment is dropped (path rules v1.1)
Identity-only checkimplied by leaving the resource outexplicit: { identityOnly: true } (Node), array('identity_only' => true) (PHP), identity_only: true (API), alone. SDK/PHP calls with no resource are bad_resource
Path pattern that is not a path (Express/Next protect: 'api/*', PHP 'members/*', Cloudflare TOKENLOCK_PROTECT="/api/*")matched nothing: those paths were unprotectedbad_config (found by the 0.4.3 interface audit)
Hosted API POST with none of the fieldsidentity-onlyidentity-only (unchanged, for 0.2.x–0.4.2 clients)
Hosted API GET (?pass=…)the router added path=v1/gate/verify to every GET query, overwriting the caller's path: GET identity checks answered bad_path and GET route checks were decided on the wrong path (fail closed)router capture renamed and removed before checking; a GET identity check must say identity_only=true; a repeated query field is bad_resource

Upgrade (now to 0.4.4, which includes this correction): npm install @tokenlock/sdk (0.5.3 or later, which includes 0.4.4); replace PHP tokenlock/ files with the 0.4.4 package; copy worker.js 0.4.4. Change identity-only calls to pass identityOnly: true / 'identity_only' => true. A 0.4.0–0.4.2 Cloudflare worker without TOKENLOCK_ENVIRONMENT sends environment: null, which the hosted API now refuses (bad_resource, fail closed) on registered-keys sites: upgrade the worker. Older clients that send a path without a method get bad_resource from the hosted API.

Remaining limits are unchanged from 0.4.2 (below). An independent security assessment is planned, not done.

Update: 0.4.2 security hardening (18 Nov 2026)

0.4.2 (npm, PHP drop-in, Cloudflare example and hosted API) is a dedicated hardening release with no new features. It removes the two ways an integrator could bypass authorization and closes one edge case in the hosted API. Regression tests that reproduce each problem were committed before the fixes and fail against 0.4.1.

ChangeBefore (0.4.1)0.4.2
Fail-open option (failOpen, 'fail_open', TOKENLOCK_FAIL_OPEN)let pass holders in unverified while the API was downremoved; setting it is a configuration error (bad_config)
Identity-only option (checkResource: false, 'check_resource' => false, TOKENLOCK_CHECK_RESOURCE)skipped route, method and environment checksremoved; configuration error
strict: falseloose checks, short answer cacheremoved; strict mode is always on
Hosted API: storage error reading a site's settings at the same time as missing access state in Rediscould be read as "no registered keys", so a registered-keys site could get a token-only answer (route policy not applied) while both failed503 site_unavailable / access_unavailable; a site marked registered-keys without its access settings answers 503
Invalid configuration (unknown or mistyped middleware options, malformed secret key or API base, unusable PHP early-block settings)often ignoredrefused: bad_config (SDK at startup, PHP and Cloudflare 500)
Malformed, oversized or contradictory API answers; malformed self-verify policies; non-boolean holdings answerssome accepteddenied (bad_answer, conflicting_answer, policy_invalid, lookup_failed)
Cloudflare worker fetch to the APIno timeoutfail-closed timeout (TOKENLOCK_TIMEOUT_MS, default 8000 ms) → 503

Remaining limits (not switches): the hosted holdings re-check grace (2 × recheck_holdings_s unless require_fresh_holdings is on), up to 30 s per server instance for a token-only / registered-keys mode switch to propagate in the hosted API, the PHP identity-answer cache (up to 60 s, token-only checks without registered keys), admin_ips in the early block is a trusted allowlist, and versions already installed don't change until upgraded. An independent security assessment is planned, not done.

Credits and changelog

Issue 1 was reported by an external reviewer of SDK 0.3.2; issue 2 was found while fixing it. Release history: TOKENLOCK release history, npm versions (the package README has the full changelog; versions before 0.5.3 were published under the SDK's earlier package name).