PAM_FAIL_DELAY(3)
π PAM_FAIL_DELAY(3) β the Linux-PAM manual, bestie edition
okay so we're doing pam_fail_delay, from the Linux-PAM Manual. yes it's a real page, yes it's about making attackers wait, and yes it's lowkey iconic. let's get into it π
β¨ NAME β¨
pam_fail_delay β request a delay on failure. that's it. that's the whole vibe. you're asking the system to slow down when auth goes wrong π
π¦ SYNOPSIS π¦
#include <security/pam_appl.h>
int pam_fail_delay(pam_handle_t *pamh, unsigned int usec);
πΈ DESCRIPTION πΈ
so pam_fail_delay is this little mechanism where an application or a module can suggest a minimum delay of usec micro-seconds. and here's the cute part: the function keeps a record of the longest time anyone requested with it. it's not "last one wins", it's "biggest one wins" π
if pam_authenticate(3) fails, then the failing return back to the application gets delayed by an amount of time that's randomly distributed (by up to 50%) about this longest value. so it's not a fixed number, it's a fuzzy number, which is the whole point β¨
and independent of success, the delay time gets reset to its zero default value when the PAM service module returns control to the application. squeaky clean, every time π§Ό
the delay happens after all authentication modules have been called, but before control is returned to the service application. timing matters, bestie π°οΈ
such a vibe. anyway, when you're using this function, the programmer should check if it's even available first, like this:
#ifdef HAVE_PAM_FAIL_DELAY
....
#endif /* HAVE_PAM_FAIL_DELAY */
now, for applications written with a single thread that are event driven in nature, generating this delay may be undesirable. totally fair. instead, the application may want to register the delay in some other way. for example: in a single threaded server that serves multiple authentication requests from a single event loop, the application might want to simply mark a given connection as blocked until an application timer expires. no sleeping in the event loop, thank you π ββοΈ
for this reason the delay function can be changed with the PAM_FAIL_DELAY item. it can be queried and set with pam_get_item(3) and pam_set_item(3) respectively. and the value used to set it should be a function pointer of the following prototype:
void (*delay_fn)(int retval, unsigned usec_delay, void *appdata_ptr);
the arguments being:
- the retval return code of the module stack
- the usec_delay micro-second delay that libpam is requesting
- and the appdata_ptr that the application has associated with the current pamh
that last value was set by the application when it called pam_start(3) or explicitly with pam_set_item(3). iykyk π«Ά
note bestie: thePAM_FAIL_DELAYitem is set toNULLby default. that indicates PAM should perform a random delay as described above when authentication fails and a delay has been suggested. if an application does not want the PAM library to perform any delay on authentication failure, then the application must define a custom delay function that executes no statements and set thePAM_FAIL_DELAYitem to point to this function. an empty function. a little nothing burger. that's the move π
π₯ RATIONALE π₯
okay so why does any of this exist? because it is often possible to attack an authentication scheme by exploiting the time it takes the scheme to deny access to an applicant user. time is a leak, periodt β±οΈ
in cases of short timeouts, it may prove possible to attempt a brute force dictionary attack β with an automated process, the attacker tries all possible passwords to gain access to the system. gross but real.
in other cases, where individual failures can take measurable amounts of time (indicating the nature of the failure), an attacker can obtain useful information about the authentication process. these latter attacks make use of procedural delays that constitute a covert channel of useful information. not the fun kind of channel π
to minimize the effectiveness of such attacks, it is desirable to introduce a random delay in a failed authentication process. preferably this value should be set by the application or a special PAM module. standard PAM modules should not modify the delay unconditional. (like, don't just go changing it whenever, okay? that's the point.) π
π EXAMPLE π
for example, a login application may require a failure delay of roughly 3 seconds. it will contain the following code:
pam_fail_delay (pamh, 3000000 /* micro-seconds */ );
pam_authenticate (pamh, 0);
if the modules do not request a delay, the failure delay will be between 1.5 and 4.5 seconds. math! because of that up-to-50% randomness thing π
however, the modules, invoked in the authentication process, may also request delays:
module #1: pam_fail_delay (pamh, 2000000);
module #2: pam_fail_delay (pamh, 4000000);
in this case, it is the largest requested value that is used to compute the actual failed delay: here between 2 and 6 seconds. biggest number wins again, told you π
β RETURN VALUES β
PAM_SUCCESSβ Delay was successful adjusted. (yes that's the original wording, she's doing her best π«Ά)PAM_SYSTEM_ERRβ ANULLpointer was submitted as PAM handle. rude. but like, valid.
π SEE ALSO π
π STANDARDS π
the pam_fail_delay function is a Linux-PAM extension. so like, it's ours. main character energy fr fr π
β¨
and that's the page, bestie!! π¦π this was Linux-PAM, dated 07/08/2026, and the page itself is PAM_FAIL_DELAY(3) in the Linux-PAM Manual. go forth and delay your failures responsibly π
π¦ where this page comes from
- fedora 44: pam-devel 1.7.2-2.fc44 Β· BSD-3-Clause AND GPL-2.0-or-later
- fedora 44: pam-devel 1.7.2-2.fc44 Β· BSD-3-Clause AND GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms