rusackas opened a new pull request, #41394:
URL: https://github.com/apache/superset/pull/41394

   ### SUMMARY
   
   Follow-up to #39645 (which is being closed as superseded — its security
   hardening already landed on master).
   
   The `DetailedJWTVerifier` expiration check has an edge case that turns a bad
   token into a server error. A JWT whose `exp` claim decodes to `float('inf')`
   — e.g. a JSON `1e309` — passes both existing guards:
   
   ```python
   exp = claims.get("exp")
   if exp is None: ...          # inf is not None  → passes
   if exp < time.time(): ...    # inf < now is False → passes (not "expired")
   ...
   expires_at=int(exp),         # int(float('inf')) → OverflowError
   ```
   
   `OverflowError` was not in the surrounding `except (ValueError, JoseError,
   KeyError, AttributeError, TypeError)` tuple, so it escaped uncaught and
   surfaced as a **500 instead of a 401**. (Note `nan` is already safe — 
`int(nan)`
   raises `ValueError`, which *was* caught. This is specifically the infinity
   overflow.)
   
   **Fix (two layers):**
   1. **Primary** — a finite-number guard at the expiration check rejects
      non-numeric and non-finite `exp` values with a precise
      `"Token has invalid expiration"` reason, consistent with this module's
      per-failure reason classification.
   2. **Backstop** — `OverflowError` is added to the `except` tuple so no
      arithmetic overflow anywhere in that block can ever escape as a 500.
   
   The fix was flagged by review bots (codeant-ai / Bito) on #39645 against the
   pre-existing master code, and confirmed by the original author and a 
maintainer
   in that thread.
   
   ### TESTING INSTRUCTIONS
   
   `pytest tests/unit_tests/mcp_service/test_jwt_verifier.py`
   
   Two new unit tests:
   - `test_non_finite_expiration_rejected` — `exp = inf` returns `None` (401) 
with
     reason `"Token has invalid expiration"` and does not raise.
   - `test_non_numeric_expiration_rejected` — a string `exp` is rejected with 
the
     same precise reason instead of degrading to the generic failure.
   
   ### ADDITIONAL INFORMATION
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to