Habr•September 11, 2026•🇷🇺Translated from Russian

API Token Lifecycle: From Issuance to Revocation and Secure Management

The security of API tokens extends far beyond cryptographic signatures. Even a properly signed token using a strong algorithm can be stolen and abused because the signature only prevents modification, not theft. Once an attacker obtains a valid access token, the server typically cannot distinguish the legitimate user from the attacker presenting the stolen credentials.

Stage 1: Token Issuance

Security begins at creation. Public clients such as single-page applications and mobile apps must use the Authorization Code Flow with PKCE rather than legacy implicit flows. PKCE binds the authorization request to a client-generated code_verifier, preventing an attacker who intercepts only the authorization code from completing the exchange. Confidential backend services should use the client_credentials grant with short-lived tokens and regularly rotated secrets stored in dedicated secret-management systems.

Access tokens for browser applications should expire within 5 to 15 minutes. Refresh tokens may live longer, supporting sliding sessions with an absolute maximum lifetime to force re-authentication. Endpoints such as /login, /token, and /oauth/authorize require strict rate limiting that considers account identifiers, device signals, and IP ranges, not just single addresses. Confidential clients can further strengthen authentication by presenting short-lived signed JWT assertions instead of static client secrets.

Stage 2: Client-Side Storage

Storing tokens in localStorage or sessionStorage exposes them to any JavaScript running on the page, including code injected through XSS, compromised npm packages, or supply-chain attacks. HttpOnly cookies marked Secure and SameSite=Lax significantly reduce direct token extraction. The Backend-for-Frontend (BFF) pattern offers even stronger protection by keeping OAuth tokens on the server; the browser receives only an opaque session identifier stored in an HttpOnly cookie. Session data can be maintained in Redis or another secure backend store, enabling centralized rotation, revocation, and monitoring.

Stage 3: Transmission and Usage

Bearer tokens are commonly sent in the Authorization header and require TLS. Cookie-based authentication simplifies client code but necessitates additional CSRF defenses such as synchronizer tokens or strict Origin/Referer validation. Sensitive operations should combine multiple layers rather than relying on any single browser flag.

By following short-lived tokens, atomic refresh-token rotation, HttpOnly cookies or BFF architecture, and comprehensive revocation capabilities, applications can substantially limit the impact of token compromise.

Related articles

Security NEXT•Vulnerabilities & Exploits

GitLab Issues Critical Patches for CVE-2026-110264 Affecting Wide Range of Versions

GitLab has released emergency security updates to address multiple vulnerabilities, including one rated critical that allows unauthenticated remote code execution. The flaw, tracked as CVE-2026-110264, stems from an integer overflow in the regular expression compiler and carries a maximum CVSSv3.1 base score of 10.0. It impacts GitLab Community Edition and Enterprise Edition starting from version 7.0, with patches now available for both current and older branches. The company strongly urges immediate updates due to the severity and potential for arbitrary code execution on affected servers. Additional lower-severity issues were also resolved in the same release cycle.

Hispasec•Vulnerabilities & Exploits

PHP Issues Emergency Patches for Critical PHP2Shell RCE Flaws as Exploit Attempts Emerge

PHP has released urgent patches for two critical vulnerabilities collectively known as PHP2Shell that enable unauthenticated remote code execution on affected servers. The flaws, tracked as CVE-2026-109618 and CVE-2026-109619, score 9.2 on CVSS v4.0 and have already seen active exploitation attempts with malicious payloads adjusted to bypass WAF rules. The issues affect multiple PHP deployment methods including Apache with mod_php, PHP-FPM, php-cgi, FrankenPHP, and LiteSpeed, and do not require complex application code to be exploitable. CVE-2026-109618 involves a memory corruption chain leading to code execution under the web process privileges, while CVE-2026-109619 stems from an obsolete global state issue causing use-after-free conditions that can result in memory disclosure and code execution. Patched versions include PHP 8.5.12, 8.4.27, 8.3.36, and 8.2.35, with administrators advised to restart all persistent workers after updating. Temporary mitigations such as setting memory_limit to -1 and disabling session.upload_progress.enabled are available for environments that cannot patch immediately.

Security NEXT•Vulnerabilities & Exploits

Two Critical RCE Vulnerabilities Patched in PHP with CVSS 9.2 Scores

The PHP development team has disclosed two severe remote code execution vulnerabilities affecting the widely used scripting language. Both issues, tracked as CVE-2026-109618 and CVE-2026-109619, received a CVSSv4.0 base score of 9.2 and were rated Critical. The flaws stem from improper memory handling during request processing and cleanup phases. Exploitation could allow attackers to execute arbitrary code by manipulating uninitialized or residual data in worker processes. Security updates addressing both vulnerabilities were released on October 21, 2026, and users are strongly urged to apply the patches immediately. The advisories were previewed the previous day, highlighting the urgency of the fixes.

BoletimSec•Vulnerabilities & Exploits

Critical PHP Core Flaws Enable Unauthenticated Remote Code Execution

The PHP project released emergency patches on October 21 for two critical vulnerabilities in the language core, tracked as CVE-2026-109618 and CVE-2026-109619 and collectively referred to as PHP2Shell. Both issues received a CVSS 4.0 score of 9.2 and allow remote code execution without authentication. CVE-2026-109618 resides in memory-handling routines where longjmp can leave request data partially initialized, and subsequent shutdown operates on invalid data; multipart requests with many headers or empty file fields can trigger the condition. CVE-2026-109619 affects an obsolete global state in long-lived workers that retain references to freed memory, with confirmed paths involving fatal errors, error reporting data, and session upload progress. Researchers demonstrated unauthenticated code execution over HTTP against the first flaw on Apache with mod_php using default limits, while PHP-FPM exposure was identified through code analysis. The FBI Cyber Division issued an alert urging immediate updates, and Cloudflare deployed WAF rules while confirming early attacks in the wild.