]> granicus.if.org Git - linux-pam/blob - doc/man/pam_fail_delay.3
Relevant BUGIDs:
[linux-pam] / doc / man / pam_fail_delay.3
1 .\"     Title: pam_fail_delay
2 .\"    Author: 
3 .\" Generator: DocBook XSL Stylesheets v1.70.1 <http://docbook.sf.net/>
4 .\"      Date: 08/01/2006
5 .\"    Manual: Linux\-PAM Manual
6 .\"    Source: Linux\-PAM Manual
7 .\"
8 .TH "PAM_FAIL_DELAY" "3" "08/01/2006" "Linux\-PAM Manual" "Linux\-PAM Manual"
9 .\" disable hyphenation
10 .nh
11 .\" disable justification (adjust text to left margin only)
12 .ad l
13 .SH "NAME"
14 pam_fail_delay \- request a delay on failure
15 .SH "SYNOPSIS"
16 .sp
17 .ft B
18 .nf
19 #include <security/pam_appl.h>
20 .fi
21 .ft
22 .HP 19
23 .BI "int pam_fail_delay(pam_handle_t\ *" "pamh" ", unsigned\ int\ " "usec" ");"
24 .SH "DESCRIPTION"
25 .PP
26 The
27 \fBpam_fail_delay\fR
28 function provides a mechanism by which an application or module can suggest a minimum delay of
29 \fIusec\fR
30 micro\-seconds. The function keeps a record of the longest time requested with this function. Should
31 \fBpam_authenticate\fR(3)
32 fail, the failing return to the application is delayed by an amount of time randomly distributed (by up to 25%) about this longest value.
33 .PP
34 Independent of success, the delay time is reset to its zero default value when the PAM service module returns control to the application. The delay occurs
35 \fIafter\fR
36 all authentication modules have been called, but
37 \fIbefore\fR
38 control is returned to the service application.
39 .PP
40 When using this function the programmer should check if it is available with:
41 .sp
42 .RS 3n
43 .nf
44 #ifdef HAVE_PAM_FAIL_DELAY
45     ....
46 #endif /* HAVE_PAM_FAIL_DELAY */
47       
48 .fi
49 .RE
50 .PP
51 For applications written with a single thread that are event driven in nature, generating this delay may be undesirable. 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. For this reason the delay function can be changed with the
52 \fIPAM_FAIL_DELAY\fR
53 item. It can be queried and set with
54 \fBpam_get_item\fR(3)
55 and
56 \fBpam_set_item \fR(3)
57 respectively. The value used to set it should be a function pointer of the following prototype:
58 .sp
59 .RS 3n
60 .nf
61 void (*delay_fn)(int retval, unsigned usec_delay, void *appdata_ptr);
62       
63 .fi
64 .RE
65 .sp
66 The arguments being the
67 \fIretval\fR
68 return code of the module stack, the
69 \fIusec_delay\fR
70 micro\-second delay that libpam is requesting and the
71 \fIappdata_ptr\fR
72 that the application has associated with the current
73 \fIpamh\fR. This last value was set by the application when it called
74 \fBpam_start\fR(3)
75 or explicitly with
76 \fBpam_set_item\fR(3). Note, if PAM_FAIL_DELAY item is unset (or set to NULL), then no delay will be performed.
77 .SH "RATIONALE"
78 .PP
79 It is often possible to attack an authentication scheme by exploiting the time it takes the scheme to deny access to an applicant user. In cases of
80 \fIshort\fR
81 timeouts, it may prove possible to attempt a
82 \fIbrute force\fR
83 dictionary attack \-\- with an automated process, the attacker tries all possible passwords to gain access to the system. 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
84 \fIcovert channel\fR
85 of useful information.
86 .PP
87 To minimize the effectiveness of such attacks, it is desirable to introduce a random delay in a failed authentication process. Preferable this value should be set by the application or a special PAM module. Standard PAM modules should not modify the delay unconditional.
88 .SH "EXAMPLE"
89 .PP
90 For example, a login application may require a failure delay of roughly 3 seconds. It will contain the following code:
91 .sp
92 .RS 3n
93 .nf
94     pam_fail_delay (pamh, 3000000 /* micro\-seconds */ );
95     pam_authenticate (pamh, 0);
96     
97 .fi
98 .RE
99 .PP
100 if the modules do not request a delay, the failure delay will be between 2.25 and 3.75 seconds.
101 .PP
102 However, the modules, invoked in the authentication process, may also request delays:
103 .sp
104 .RS 3n
105 .nf
106 module #1:    pam_fail_delay (pamh, 2000000);
107 module #2:    pam_fail_delay (pamh, 4000000);
108     
109 .fi
110 .RE
111 .PP
112 in this case, it is the largest requested value that is used to compute the actual failed delay: here between 3 and 5 seconds.
113 .SH "RETURN VALUES"
114 .TP 3n
115 PAM_SUCCESS
116 Delay was successful adjusted.
117 .TP 3n
118 PAM_SYSTEM_ERR
119 A NULL pointer was submitted as PAM handle.
120 .SH "SEE ALSO"
121 .PP
122
123 \fBpam_start\fR(3),
124 \fBpam_get_item\fR(3),
125 \fBpam_strerror\fR(3)
126 .SH "STANDARDS"
127 .PP
128 The
129 \fBpam_fail_delay\fR
130 function is an Linux\-PAM extension.