1PAM_FAIL_DELAY(3)              Linux-PAM Manual              PAM_FAIL_DELAY(3)
2
3
4

NAME

6       pam_fail_delay - request a delay on failure
7

SYNOPSIS

9       #include <security/pam_appl.h>
10
11       int pam_fail_delay(pam_handle_t *pamh, unsigned int usec);
12

DESCRIPTION

14       The pam_fail_delay function provides a mechanism by which an
15       application or module can suggest a minimum delay of usec
16       micro-seconds. The function keeps a record of the longest time
17       requested with this function. Should pam_authenticate(3) fail, the
18       failing return to the application is delayed by an amount of time
19       randomly distributed (by up to 50%) about this longest value.
20
21       Independent of success, the delay time is reset to its zero default
22       value when the PAM service module returns control to the application.
23       The delay occurs after all authentication modules have been called, but
24       before control is returned to the service application.
25
26       When using this function the programmer should check if it is available
27       with:
28
29           #ifdef HAVE_PAM_FAIL_DELAY
30               ....
31           #endif /* HAVE_PAM_FAIL_DELAY */
32
33
34       For applications written with a single thread that are event driven in
35       nature, generating this delay may be undesirable. Instead, the
36       application may want to register the delay in some other way. For
37       example, in a single threaded server that serves multiple
38       authentication requests from a single event loop, the application might
39       want to simply mark a given connection as blocked until an application
40       timer expires. For this reason the delay function can be changed with
41       the PAM_FAIL_DELAY item. It can be queried and set with pam_get_item(3)
42       and pam_set_item (3) respectively. The value used to set it should be a
43       function pointer of the following prototype:
44
45           void (*delay_fn)(int retval, unsigned usec_delay, void *appdata_ptr);
46
47
48       The arguments being the retval return code of the module stack, the
49       usec_delay micro-second delay that libpam is requesting and the
50       appdata_ptr that the application has associated with the current pamh.
51       This last value was set by the application when it called pam_start(3)
52       or explicitly with pam_set_item(3). Note, if PAM_FAIL_DELAY item is
53       unset (or set to NULL), then no delay will be performed.
54

RATIONALE

56       It is often possible to attack an authentication scheme by exploiting
57       the time it takes the scheme to deny access to an applicant user. In
58       cases of short timeouts, it may prove possible to attempt a brute force
59       dictionary attack -- with an automated process, the attacker tries all
60       possible passwords to gain access to the system. In other cases, where
61       individual failures can take measurable amounts of time (indicating the
62       nature of the failure), an attacker can obtain useful information about
63       the authentication process. These latter attacks make use of procedural
64       delays that constitute a covert channel of useful information.
65
66       To minimize the effectiveness of such attacks, it is desirable to
67       introduce a random delay in a failed authentication process. Preferable
68       this value should be set by the application or a special PAM module.
69       Standard PAM modules should not modify the delay unconditional.
70

EXAMPLE

72       For example, a login application may require a failure delay of roughly
73       3 seconds. It will contain the following code:
74
75               pam_fail_delay (pamh, 3000000 /* micro-seconds */ );
76               pam_authenticate (pamh, 0);
77
78
79       if the modules do not request a delay, the failure delay will be
80       between 1.5 and 4.5 seconds.
81
82       However, the modules, invoked in the authentication process, may also
83       request delays:
84
85           module #1:    pam_fail_delay (pamh, 2000000);
86           module #2:    pam_fail_delay (pamh, 4000000);
87
88
89       in this case, it is the largest requested value that is used to compute
90       the actual failed delay: here between 2 and 6 seconds.
91

RETURN VALUES

93       PAM_SUCCESS
94           Delay was successful adjusted.
95
96       PAM_SYSTEM_ERR
97           A NULL pointer was submitted as PAM handle.
98

SEE ALSO

100       pam_start(3), pam_get_item(3), pam_strerror(3)
101

STANDARDS

103       The pam_fail_delay function is an Linux-PAM extension.
104
105
106
107Linux-PAM Manual                  05/18/2017                 PAM_FAIL_DELAY(3)
Impressum