Fix locale-dependent strftime breaking HMAC auth#372
Open
AaronAtDuo wants to merge 1 commit into
Open
Conversation
Replace locale-dependent strftime(localtime()) with strftime_l(gmtime()) using an explicit C locale. This fixes three issues: - #366/#355: strftime %a and %b produce localized day/month names when the system locale is non-English, breaking HMAC signature verification - #363: strftime %z on AIX produces a timezone name ("EST") instead of a numeric offset ("-0500"), also breaking signatures The fix uses gmtime() with a hardcoded "+0000" UTC offset (matching the Python client's default behavior) and strftime_l() with a C locale to guarantee English day/month abbreviations regardless of environment. Resolves #366, #355, #363 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
strftime(localtime())withstrftime_l(gmtime())using an explicit C locale for theX-Duo-Dateheader+0000UTC offset instead of relying on platform-specific%zbehaviorMotivation
Three related bugs where
strftimeproduces output that breaks HMAC signature verification:setlocale(LC_ALL, ""), pam_duo inherits the locale.strftimethen produces localized day/month names (e.g., "mar", "juin" instead of "Tue", "Jun"), causing the Duo API to reject the request with HTTP 401.strftime %zproduces a timezone name ("EST") instead of a numeric offset ("-0500"), also breaking signature verification.Fix
strftime_lwith C locale guarantees English day/month names regardless of process localegmtime()with+0000sidesteps the AIX%zbug entirelysig_timezonebehaviorPlatform support
strftime_l(POSIX.1-2008) is available on Linux (glibc), macOS, FreeBSD, AIX 7.2+, Solaris 11.4+, and illumos. Not available on Solaris 11.3 and earlier (EOL for premier support: January 2024).Test plan
LC_ALL=fr_FR.UTF-8test_pam_locale.charness that callssetlocale(LC_ALL, "")before PAM auth (simulates GDM/display manager behavior)make check)Resolves #366, #355, #363
This analysis was generated with AI assistance (Claude).