Skip to content

fix(be-030): Add explicit JWT expiry validation in auth middleware - #406

Merged
Dev-Zully merged 1 commit into
OdyxeeeLabs:mainfrom
thisstk:fix/be-030-jwt-expiry-validation
Aug 30, 2026
Merged

fix(be-030): Add explicit JWT expiry validation in auth middleware#406
Dev-Zully merged 1 commit into
OdyxeeeLabs:mainfrom
thisstk:fix/be-030-jwt-expiry-validation

Conversation

@thisstk

@thisstk thisstk commented Aug 30, 2026

Copy link
Copy Markdown

🔒 Security Fix: JWT Expiry Validation

Issue

#267 BE-030: middleware.rs does not validate JWT expiry — expired tokens are accepted

Severity: 🔴 Critical
Category: Security / Authentication
Labels: backend, auth, security

Problem Statement

The authentication middleware was accepting JWT tokens without validating the exp (expiry) claim against the current time. This allowed expired tokens to continue working indefinitely, creating a significant security vulnerability for the admin API.

Solution

Implemented explicit validation of the JWT exp claim in the auth_middleware function to:

  • Verify the token has not expired before accepting the request
  • Return a 401 Unauthorized response for expired tokens
  • Provide clear error messaging for debugging

Changes

1. Core Fix: JWT Expiry Validation

  • File: core/src/auth.rs (lines 797-802)
  • Implementation: Added explicit expiry check after JWT decoding
    // Validate JWT expiry claim (BE-030: verify token has not expired)
    let now = now_secs();
    if token_data.claims.exp <= now {
        return Err(AppError::Unauthorized(
            "Token has expired".into(),
        ));
    }

( Closed #267 )

- Validates exp claim against current time in auth_middleware
- Rejects expired tokens with 401 Unauthorized response
- Adds comprehensive tests for expired and valid token scenarios
- Ensures admin API is protected from expired token exploitation

Fixes issue OdyxeeeLabs#267: middleware.rs does not validate JWT expiry
@drips-wave

drips-wave Bot commented Aug 30, 2026

Copy link
Copy Markdown

@thisstk Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Dev-Zully
Dev-Zully merged commit a209cb5 into OdyxeeeLabs:main Aug 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BE-030: middleware.rs does not validate JWT expiry — expired tokens are accepted

2 participants