@@ -52,8 +52,8 @@ curl -sSL akas.io/sysctl -o sysctl.conf
52
52
# Name: K4YT3X Hardened sysctl Configuration
53
53
# Author: K4YT3X
54
54
# Date Created: October 5, 2020
55
- # Last Updated: October 5 , 2020
56
- # Version: 1.0
55
+ # Last Updated: October 6 , 2020
56
+ # Version: 1.1
57
57
58
58
# Licensed under the GNU General Public License Version 3 (GNU GPL v3),
59
59
# available at: https://www.gnu.org/licenses/gpl-3.0.txt
@@ -93,6 +93,18 @@ kernel.kptr_restrict = 2
93
93
# - 3: disables ptrace completely, reboot is required to re-enable ptrace
94
94
kernel.yama.ptrace_scope = 3
95
95
96
+ # restrict kernel logs to root only
97
+ kernel.dmesg_restrict = 1
98
+
99
+ # restrict BPF JIT compiler to root only
100
+ kernel.unprivileged_bpf_disabled = 1
101
+
102
+ # disables kexec as it can be used to livepatch the running kernel
103
+ kernel.kexec_load_disabled = 1
104
+
105
+ # disable unprivileged user namespaces to decrease attack surface
106
+ kernel.unprivileged_userns_clone = 0
107
+
96
108
# allow for more PIDs
97
109
kernel.pid_max = 65536
98
110
@@ -116,9 +128,37 @@ fs.protected_hardlinks = 1
116
128
# - the owner of the directory is also the owner of the symbolic link
117
129
fs.protected_symlinks = 1
118
130
131
+ # enable extended FIFO protection
132
+ fs.protected_fifos = 2
133
+
134
+ # similar to protected_fifos, but it avoids writes to an attacker-controlled regular file
135
+ fs.protected_regular = 2
136
+
119
137
# increase system file descriptor limit
120
138
fs.file-max = 65535
121
139
140
+ # ######### Virtualization ##########
141
+
142
+ # improve mmap ASLR effectness
143
+ vm.mmap_rnd_bits =32
144
+ vm.mmap_rnd_compat_bits =16
145
+
146
+ # ######### Networking ##########
147
+
148
+ # increase the maximum length of processor input queues
149
+ net.core.netdev_max_backlog = 250000
150
+
151
+ # enable BPF JIT hardening for all users
152
+ # this trades off performance, but can mitigate JIT spraying
153
+ net.core.bpf_jit_harden = 2
154
+
155
+ # increase TCP max buffer size setable using setsockopt()
156
+ # net.core.rmem_max = 8388608
157
+ # net.core.wmem_max = 8388608
158
+ # net.core.rmem_default = 8388608
159
+ # net.core.wmem_default = 8388608
160
+ # net.core.optmem_max = 8388608
161
+
122
162
# ######### IPv4 Networking ##########
123
163
124
164
# enable BBR congestion control
@@ -147,32 +187,43 @@ net.ipv4.conf.default.rp_filter = 1
147
187
net.ipv4.conf.all.rp_filter = 1
148
188
149
189
# log packets with impossible addresses to kernel log
150
- net.ipv4.conf.all.log_martians = 1
151
190
net.ipv4.conf.default.log_martians = 1
191
+ net.ipv4.conf.all.log_martians = 1
152
192
153
193
# do not accept ICMP redirect messages
154
194
net.ipv4.conf.default.accept_redirects = 0
155
- net.ipv4.conf.all.accept_redirects = 0
156
195
net.ipv4.conf.default.secure_redirects = 0
196
+ net.ipv4.conf.all.accept_redirects = 0
157
197
net.ipv4.conf.all.secure_redirects = 0
158
198
159
199
# disable sending and receiving of shared media redirects
160
200
# this setting overwrites net.ipv4.conf.all.secure_redirects
161
201
# refer to RFC1620
202
+ net.ipv4.conf.default.shared_media = 0
162
203
net.ipv4.conf.all.shared_media = 0
163
204
164
- # ignore all ICMP ECHO and TIMESTAMP requests sent to broadcast/multicast
165
- net.ipv4.icmp_echo_ignore_broadcasts = 1
166
-
167
- # ignore bad ICMP errors
168
- net.ipv4.icmp_ignore_bogus_error_responses = 1
169
-
170
205
# always use the best local address for announcing local IP via ARP
206
+ net.ipv4.conf.default.arp_announce = 2
171
207
net.ipv4.conf.all.arp_announce = 2
172
208
173
209
# reply only if the target IP address is local address configured on the incoming interface
210
+ net.ipv4.conf.default.arp_ignore = 1
174
211
net.ipv4.conf.all.arp_ignore = 1
175
212
213
+ # drop Gratuitous ARP frames to prevent ARP poisoning
214
+ # this can cause issues when ARP proxies are used in the network
215
+ net.ipv4.conf.default.drop_gratuitous_arp = 1
216
+ net.ipv4.conf.all.drop_gratuitous_arp = 1
217
+
218
+ # ignore all ICMP echo requests
219
+ # net.ipv4.icmp_echo_ignore_all = 1
220
+
221
+ # ignore all ICMP echo and timestamp requests sent to broadcast/multicast
222
+ net.ipv4.icmp_echo_ignore_broadcasts = 1
223
+
224
+ # ignore bad ICMP errors
225
+ net.ipv4.icmp_ignore_bogus_error_responses = 1
226
+
176
227
# mitigate TIME-WAIT Assassination hazards in TCP
177
228
# refer to RFC1337
178
229
net.ipv4.tcp_rfc1337 = 1
@@ -187,49 +238,57 @@ net.ipv4.ip_local_port_range = 2000 65000
187
238
# disable TCP timestamps for better CPU utilization
188
239
net.ipv4.tcp_timestamps = 0
189
240
190
- # enable TCP selective ACKs for better throughput
191
- net.ipv4.tcp_sack = 1
241
+ # enabling SACK can increase the throughput
242
+ # but SACK is commonly exploited and rarely used
243
+ net.ipv4.tcp_sack = 0
192
244
193
245
# divide socket buffer evenly between TCP window size and application
194
246
net.ipv4.tcp_adv_win_scale = 1
195
247
196
- # increase the maximum length of processor input queues
197
- net.core.netdev_max_backlog = 250000
198
-
199
248
# increase memory thresholds to prevent packet dropping
200
249
# net.ipv4.tcp_rmem = 4096 87380 8388608
201
250
# net.ipv4.tcp_wmem = 4096 87380 8388608
202
251
203
- # increase TCP max buffer size setable using setsockopt()
204
- # net.core.rmem_max = 8388608
205
- # net.core.wmem_max = 8388608
206
- # net.core.rmem_default = 8388608
207
- # net.core.wmem_default = 8388608
208
- # net.core.optmem_max = 8388608
209
-
210
252
# ######### IPv6 Networking ##########
211
253
212
254
# disallow IPv6 packet forwarding
255
+ net.ipv6.conf.default.forwarding = 0
213
256
net.ipv6.conf.all.forwarding = 0
214
257
215
258
# number of Router Solicitations to send until assuming no routers are present
216
259
net.ipv6.conf.default.router_solicitations = 0
260
+ net.ipv6.conf.all.router_solicitations = 0
217
261
218
262
# do not accept Router Preference from RA
219
263
net.ipv6.conf.default.accept_ra_rtr_pref = 0
264
+ net.ipv6.conf.all.accept_ra_rtr_pref = 0
220
265
221
266
# learn prefix information in router advertisement
222
267
net.ipv6.conf.default.accept_ra_pinfo = 0
268
+ net.ipv6.conf.all.accept_ra_pinfo = 0
223
269
224
270
# setting controls whether the system will accept Hop Limit settings from a router advertisement
225
271
net.ipv6.conf.default.accept_ra_defrtr = 0
272
+ net.ipv6.conf.all.accept_ra_defrtr = 0
226
273
227
274
# router advertisements can cause the system to assign a global unicast address to an interface
228
275
net.ipv6.conf.default.autoconf = 0
276
+ net.ipv6.conf.all.autoconf = 0
229
277
230
278
# number of neighbor solicitations to send out per address
231
279
net.ipv6.conf.default.dad_transmits = 0
280
+ net.ipv6.conf.all.dad_transmits = 0
232
281
233
282
# number of global unicast IPv6 addresses can be assigned to each interface
234
283
net.ipv6.conf.default.max_addresses = 1
284
+ net.ipv6.conf.all.max_addresses = 1
285
+
286
+ # enable IPv6 Privacy Extensions (RFC3041) and prefer the temporary address
287
+ net.ipv6.conf.default.use_tempaddr = 2
288
+ net.ipv6.conf.all.use_tempaddr = 2
289
+
290
+ # ignore all ICMPv6 echo requests
291
+ # net.ipv6.icmp.echo_ignore_all = 1
292
+ # net.ipv6.icmp.echo_ignore_anycast = 1
293
+ # net.ipv6.icmp.echo_ignore_multicast = 1
235
294
```
0 commit comments