-
Notifications
You must be signed in to change notification settings - Fork 0
/
SECURITY
219 lines (164 loc) · 8.81 KB
/
SECURITY
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# $Id$
PyKota - Print Quotas for CUPS
(c) 2003-2013 Jerome Alet <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
====================================================================
How to improve PyKota's security :
----------------------------------
- Secure your printers :
This is the most important thing to do !
Tell them to refuse any print job not coming from your print server.
Do this with telnet to set ACLs based on incoming IP addresses if
possible, or through any other way.
Put all your printers on a private unroutable subnet, different from
the subnet on which your client hosts will reside. Ensure that the
only machine allowed to access to this subnet is your print server.
- Secure your print servers :
Don't give shell access to your users on your print servers, and
don't let them execute unauthorized commands : they could very well
compile and/or execute tools like NetCat, and send datas directly to
the printer in the case the printer is networked, thus bypassing the
printing system and PyKota.
Ensure that no regular user can read PyKota administrator's
configuration file, but that both the PyKota Administrator and the
user the printing system is run as can read it. With CUPS under
Debian you may want to do :
$ chown pykota.pykota ~pykota/pykota.conf ~pykota/pykotadmin.conf
$ chmod 640 ~pykota/pykota.conf
$ chmod 600 ~pykota/pykotadmin.conf
Depending on your needs, you may want to put the user the printing
system is run as in the group 'pykota', and relax permissions a bit
so that this user can read the pykotadmin.conf file while printing.
For example :
$ chmod 640 ~pykota/pykotadmin.conf
$ adduser lp pykota
(this makes user 'lp' a member of group 'pykota')
Another solution, needed on some systems :
$ chmod a+rx ~pykota/
$ chown lp.pykota ~pykota/pykota.conf ~pykota/pykotadmin.conf
Letting any user read PyKota administrator's configuration file may
expose passwords or database information which would allow write
access to the database, and so may transform your print quota
management in a nightmare.
If you want to let users generate their own print quota reports,
then ensure that /etc/pykota/pykota.conf is readable by these users.
To do this you can either put this users in the group 'pykota' while
ensuring they can't read pykotadmin.conf with 'chmod 600 pykotadmin.conf'
or simply allow everyone to read pykota.conf with 'chmod 644 pykota.conf'
- Secure your database connections :
Depending on the database backend used,
you may have to take additionnal measures to render your database
more secure. Please refer to your database system's documentation
to learn how to do so. This is out of the scope of the present
document which will only give basic informations.
Keep in mind that if you use a centralized database, the first thing
you may want to do is to restrict which hosts can access to it, i.e.
only the print servers.
PostgreSQL :
For the PostgreSQL backend, PyKota already defines a user with
read/write access and another user with read-only access to the
Print Quota Database. PyKota already sets default passwords for these
users, but you can change them later and and here's how to do :
From the root shell do :
$ su - postgres
$ psql template1
template1=# ALTER USER pykotauser WITH PASSWORD 'a.difficult.password';
template1=# ALTER USER pykotaadmin WITH PASSWORD 'another.password';
template1=# \q
$ exit
Now modify PostgreSQL's pg_hba.conf to restrict access to the PyKota
database to PostgreSQL users 'pykotauser' and 'pykotaadmin' only,
and only if they connect from localhost and provide the correct
password. Here's an excerpt from our own pg_hba.conf :
--- CUT ---
local all postgres ident sameuser
local all all reject
host pykota pykotauser 127.0.0.1 255.255.255.255 crypt
host pykota pykotaadmin 127.0.0.1 255.255.255.255 crypt
host pykota all 127.0.0.1 255.255.255.255 reject
--- CUT ---
As an alternative, which may depend on the default encryption setting
used by your version of PostgreSQL, you may want to use the following
settings instead :
--- CUT ---
local all postgres ident sameuser
local all all reject
host pykota pykotauser 127.0.0.1 255.255.255.255 md5
host pykota pykotaadmin 127.0.0.1 255.255.255.255 md5
host pykota all 127.0.0.1 255.255.255.255 reject
--- CUT ---
Finally restart PostgreSQL so that the changes will be applied :
$ /etc/init.d/postgresql restart
Of course, depending on your needs, you may want to secure
your database connections in a completely different way or
add other security layers on top of this. To do so please
refer to PostgreSQL's documentation because this is out of
the scope of the present document.
LDAP :
For the LDAP backend, you have to ensure that no regular user can
write to any PyKota specific attribute or objectClass. Otherwise
they could modify their quota at will. Here too you will have to
create two LDAP users which will be used for readonly and read+write
access to PyKota's datas. PyKota currently doesn't do this, so
you have to create an LDIF file this way (please adapt the
DNs to your own environment) :
--- CUT ---
dn: cn=pykotauser,dc=example,dc=com
cn: pykotauser
objectClass: simpleSecurityObject
objectClass: organizationalRole
description: PyKota ReadOnly User
userPassword: {CRYPT}jfdsk653dsZFL
dn: cn=pykotaadmin,dc=example,dc=com
cn: pykotaadmin
objectClass: simpleSecurityObject
objectClass: organizationalRole
description: PyKota Read+Write User
userPassword: {CRYPT}kqsIu43Exoi5s
--- CUT ---
Then add these two users to your existing LDAP tree :
$ ldapadd -W -x -D "cn=admin,dc=example,dc=com" -f users.ldif
Now modify your LDAP server's configuration to respectively allow
read+write and readonly access to the datas :
--- CUT ---
by dn="cn=pykotaadmin,dc=example,dc=com" write
by dn="cn=pykotauser,dc=example,dc=com" read
--- CUT ---
Finally restart your LDAP server so that the changes will be applied :
$ /etc/init.d/slapd restart
Of course, depending on your needs, you may want to secure
your database connections in a completely different way or
add other security layers on top of this. To do so please
refer to your LDAP server's documentation because this is out
of the scope of the present document.
- Secure your CGI scripts :
If you use printquota.cgi or dumpykota.cgi, ensure that the user
they are run as can read the pykota.conf file but NOT the
pykotadmin.conf file.
The particular user they will be run as depends on your web server's
settings.
If you want to further restrict the access to these CGI scripts,
please read your web server's documentation to add either
encryption, authentication or both.
The CGI scripts will honor the content of the REMOTE_USER CGI
environment variable which is set by your web server if an
authentication took place. If REMOTE_USER contains 'root' then, even
if you didn't authenticate using the real root account and password,
the scripts will consider they have been run by a PyKota
administrator and will report all datas if asked to do so. If
REMOTE_USER is not present, which means that you didn't chose to
secure access to your CGI scripts, the same will happen. If
REMOTE_USER contains something else, only datas pertaining to this
user will be made available through the web.
NB : In any case, the CGI scripts actually included in PyKota only
do readonly accesses to PyKota's database.
====================================================================