Skip to content

PR #1078 and #1430 audit: confirmed token-auth defects (cache, JWKS concurrency, OpenID discovery) #1446

@vzakaznikov

Description

@vzakaznikov

Summary

Deep static audit of PR #1078 (token authentication and authorization) identified multiple confirmed defects, including high-severity issues in cache handling and JWKS concurrency.

A detailed report has been prepared locally in:

  • PR-1078-audit-report.md

Scope reviewed

  • HTTP/TCP token auth entrypoints
  • Token validation/cache (ExternalAuthenticators)
  • JWT/JWKS path (TokenProcessorsJWT, JWKSProvider)
  • OpenID/Opaque provider path (TokenProcessorsOpaque)
  • Token user directory mapping (TokenAccessStorage)
  • Config/parser/load integration

Confirmed defects

High

  1. Use-after-erase in token cache expiry cleanup

    • src/Access/ExternalAuthenticators.cpp
    • Potential UB/crash in expired-entry cleanup path.
  2. Data race in JWKS refresh/cache writes

    • src/Access/Common/JWKSProvider.cpp
    • Shared-lock path writes mutable state (last_request_send, cached_jwks).
  3. OpenID discovery constructor does not assign discovered fallback endpoints

    • src/Access/TokenProcessorsOpaque.cpp
    • Discovery-configured OpenID processor can fail fallback path.

Medium

  1. token_cache_lifetime units mismatch (seconds vs minutes)

    • src/Access/ExternalAuthenticators.cpp
  2. cache_entry.expires_at can remain unset in one branch

    • src/Access/ExternalAuthenticators.cpp
  3. jwt_static_key parser requires static_key unconditionally

    • src/Access/TokenProcessorsParse.cpp
  4. Invalid roles_filter regex falls back to unfiltered role mapping

    • src/Access/TokenAccessStorage.cpp
  5. Inconsistent malformed-token handling (false vs throw) across JWT processors

    • src/Access/TokenProcessorsJWT.cpp

Low

  1. Diagnostics consistency issues in token/JWKS paths

Recommended next actions

  • Fix high-severity issues first (cache UB, JWKS race, OpenID discovery endpoint assignment).
  • Add focused regression tests for:
    • expired cache cleanup branch,
    • concurrent JWKS refresh,
    • OpenID discovery fallback behavior,
    • jwt_static_key parser behavior for asymmetric algorithms.

Notes

This issue intentionally tracks only confirmed defects from static reasoning. Runtime stress/TSAN validation is still recommended for concurrency manifestation frequency.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions