FixVibe
Covered by FixVibehigh

JWT Seguridade: riscos de fichas non seguras e falta de validación de reclamacións ZXCVFIXVIBESEXEEND ZXCVFIXVIBESEG1 A implementación inadecuada de JWT, como aceptar o algoritmo "ninguno" ou non validar as afirmacións "exp" e "aud", pode provocar que se omita a autenticación. ZXCVFIXVIBESEXEEND ZXCVFIXVIBESEG2 Os JSON Web Tokens (JWT) proporcionan un estándar para transferir reclamacións, pero a seguridade depende dunha validación rigorosa. Se non se verifican as sinaturas, os tempos de caducidade ou os públicos previstos, os atacantes poden evitar a autenticación ou os tokens de repetición. ZXCVFIXVIBESEXEEND ZXCVFIXVIBESEG3 ## Impacto do atacante ZXCVFIXVIBESEXEEND ZXCVFIXVIBESEG4 A validación incorrecta de ZXCVFIXVIBETOKEN4ZXCV permite aos atacantes eludir os mecanismos de autenticación falsificando reclamacións ou reutilizando tokens caducados ZXCVFIXVIBETOKEN1ZXCV. Se un servidor acepta tokens sen unha sinatura válida, un atacante pode modificar a carga útil para aumentar os privilexios ou suplantar a identidade de calquera usuario ZXCVFIXVIBETOKEN2ZXCV. Ademais, ao non aplicar a reclamación de caducidade (JWT), un atacante pode usar un token comprometido de forma indefinida ZXCVFIXVIBETOKEN3ZXCV. ZXCVFIXVIBESEXEEND ZXCVFIXVIBESEG5 ## Causa raíz ZXCVFIXVIBESEXEEND ZXCVFIXVIBESEG6 Un token web JSON (ZXCVFIXVIBETOKEN1ZXCV) é unha estrutura baseada en JSON que se usa para representar reclamacións asinadas dixitalmente ou protexidas pola integridade JWT. Os fallos de seguridade adoitan derivarse de dúas lagoas de implementación principais: ZXCVFIXVIBESEXEEND ZXCVFIXVIBESEG7 1. **Aceptación de JWT non seguros**: se un servizo non aplica estritamente a verificación da sinatura, pode procesar "JWT non seguros" onde a sinatura está ausente e o algoritmo está configurado como "ningunha" JWT. Neste escenario, o servidor confía nas reclamacións da carga útil sen verificar a súa integridade ZXCVFIXVIBETOKEN1ZXCV. ZXCVFIXVIBESEXEEND ZXCVFIXVIBESEG8 2. **Validación de reclamación faltante**: a reclamación JWT (tempo de caducidade) identifica o momento en que non se debe aceptar ZXCVFIXVIBETOKEN5ZXCV para procesar ZXCVFIXVIBETOKEN2ZXCV. A reclamación ZXCVFIXVIBETOKEN1ZXCV (audiencia) identifica os destinatarios previstos do token ZXCVFIXVIBETOKEN3ZXCV. Se non se marcan, o servidor pode aceptar tokens caducados ou destinados a unha aplicación diferente ZXCVFIXVIBETOKEN4ZXCV. ZXCVFIXVIBESEXEEND ZXCVFIXVIBESEG9 ## Correccións concretas ZXCVFIXVIBESEXEEND ZXCVFIXVIBESEG10 1. **Aplicar sinaturas criptográficas**: configure a aplicación para que rexeite calquera JWT que non utilice un algoritmo de sinatura forte e preaprobado (como RS256). ZXCVFIXVIBESEXEEND ZXCVFIXVIBESEG11 2. **Validar caducidade**: implementa unha comprobación obrigatoria para asegurarte de que a data e a hora actual son anteriores á hora especificada na reclamación JWT ZXCVFIXVIBETOKEN1ZXCV. ZXCVFIXVIBESEXEEND ZXCVFIXVIBESEG12 3. **Verificar o público**: asegúrate de que a reclamación JWT conteña un valor que identifique o servizo local; se o servizo non se identifica na reclamación ZXCVFIXVIBETOKEN1ZXCV, o token debe ser rexeitado ZXCVFIXVIBETOKEN2ZXCV. ZXCVFIXVIBESEXEEND ZXCVFIXVIBESEG13 4. **Evita a reprodución**: utiliza a reclamación JWT (ID de ZXCVFIXVIBETOKEN2ZXCV) para asignar un identificador único a cada token, permitindo ao servidor rastrexar e rexeitar os tokens reutilizados ZXCVFIXVIBETOKEN1ZXCV. ZXCVFIXVIBESEXEEND ZXCVFIXVIBESEG14 ## Estratexia de detección ZXCVFIXVIBESEXEEND ZXCVFIXVIBESEG15 As vulnerabilidades no manexo de JWT pódense identificar analizando a estrutura do token e o comportamento de resposta do servidor: ZXCVFIXVIBESEXEEND ZXCVFIXVIBESEG16 * **Inspección de cabeceira**: comprobando a cabeceira JWT (algoritmo) para asegurarse de que non estea definida como "ningunha" e que utiliza os estándares criptográficos esperados ZXCVFIXVIBETOKEN1ZXCV. ZXCVFIXVIBESEXEEND ZXCVFIXVIBESEG17 * **Verificación da reclamación**: confirma a presenza e a validez das reclamacións JWT (caducidade) e ZXCVFIXVIBETOKEN1ZXCV (audiencia) dentro da carga útil JSON ZXCVFIXVIBETOKEN2ZXCV. ZXCVFIXVIBESEXEEND ZXCVFIXVIBESEG18 * **Proba de validación**: proba se o servidor rexeita correctamente os tokens que caducaron segundo a reclamación JWT ou están destinados a un público diferente segundo o definido pola reclamación ZXCVFIXVIBETOKEN1ZXCV ZXCVFIXVIBETOKEN2ZXCV.

JSON Web Tokens (JWTs) provide a standard for transferring claims, but security relies on rigorous validation. Failure to verify signatures, expiration times, or intended audiences allows attackers to bypass authentication or replay tokens.

CWE-347CWE-287CWE-613

Attacker Impact

Improper JWT validation allows attackers to bypass authentication mechanisms by forging claims or reusing expired tokens [S1]. If a server accepts tokens without a valid signature, an attacker can modify the payload to escalate privileges or impersonate any user [S1]. Furthermore, failing to enforce the expiration (exp) claim allows an attacker to use a compromised token indefinitely [S1].

Root Cause

A JSON Web Token (JWT) is a JSON-based structure used to represent claims that are digitally signed or integrity protected [S1]. Security failures typically stem from two primary implementation gaps:

  • Acceptance of Unsecured JWTs: If a service does not strictly enforce signature verification, it may process "Unsecured JWTs" where the signature is absent and the algorithm is set to "none" [S1]. In this scenario, the server trusts the claims in the payload without verifying their integrity [S1].
  • Missing Claim Validation: The exp (expiration time) claim identifies the time on or after which the JWT must not be accepted for processing [S1]. The aud (audience) claim identifies the intended recipients of the token [S1]. If these are not checked, the server may accept tokens that are expired or were intended for a different application [S1].

Concrete Fixes

  • Enforce Cryptographic Signatures: Configure the application to reject any JWT that does not use a pre-approved, strong signing algorithm (such as RS256).
  • Validate Expiration: Implement a mandatory check to ensure the current date and time are before the time specified in the exp claim [S1].
  • Verify Audience: Ensure the aud claim contains a value identifying the local service; if the service is not identified in the aud claim, the token must be rejected [S1].
  • Prevent Replay: Use the jti (JWT ID) claim to assign a unique identifier to each token, allowing the server to track and reject reused tokens [S1].

Detection Strategy

Vulnerabilities in JWT handling can be identified by analyzing the token structure and server response behavior:

  • Header Inspection: Checking the alg (algorithm) header to ensure it is not set to "none" and uses expected cryptographic standards [S1].
  • Claim Verification: Confirming the presence and validity of the exp (expiration) and aud (audience) claims within the JSON payload [S1].
  • Validation Testing: Testing if the server correctly rejects tokens that have expired according to the exp claim or are intended for a different audience as defined by the aud claim [S1].