]> git.ipfire.org Git - thirdparty/xtables-addons.git/blob - extensions/libxt_SYSRQ.man
d7b3da0684dfe0d1434fab563b679f1fc65624a4
[thirdparty/xtables-addons.git] / extensions / libxt_SYSRQ.man
1 .PP
2 The SYSRQ target allows one to remotely trigger sysrq on the local machine over
3 the network. This can be useful when vital parts of the machine hang, for
4 example an oops in a filesystem causing locks to be not released and processes
5 to get stuck as a result \(em if still possible, use /proc/sysrq-trigger. Even
6 when processes are stuck, interrupts are likely to be still processed, and as
7 such, sysrq can be triggered through incoming network packets.
8 .PP
9 The xt_SYSRQ implementation uses a salted hash and a sequence number to prevent
10 network sniffers from either guessing the password or replaying earlier
11 requests. The initial sequence number comes from the time of day so you will
12 have a small window of vulnerability should time go backwards at a reboot.
13 However, the file /sys/module/xt_SYSREQ/seqno can be used to both query and
14 update the current sequence number. Also, you should limit as to who can issue
15 commands using \fB\-s\fP and/or \fB\-m mac\fP, and also that the destination is
16 correct using \fB\-d\fP (to protect against potential broadcast packets),
17 noting that it is still short of MAC/IP spoofing:
18 .IP
19 \-A INPUT \-s 10.10.25.1 \-m mac \-\-mac\-source aa:bb:cc:dd:ee:ff \-d
20 10.10.25.7 \-p udp \-\-dport 9 \-j SYSRQ
21 .IP
22 (with IPsec) \-A INPUT \-s 10.10.25.1 \-d 10.10.25.7 \-m policy \-\-dir in
23 \-\-pol ipsec \-\-proto esp \-\-tunnel\-src 10.10.25.1 \-\-tunnel\-dst
24 10.10.25.7 \-p udp \-\-dport 9 \-j SYSRQ
25 .PP
26 You should also limit the rate at which connections can be received to limit
27 the CPU time taken by illegal requests, for example:
28 .IP
29 \-A INPUT \-s 10.10.25.1 \-m mac \-\-mac\-source aa:bb:cc:dd:ee:ff \-d
30 10.10.25.7 \-p udp \-\-dport 9 \-m limit \-\-limit 5/minute \-j SYSRQ
31 .PP
32 This extension does not take any options. The \fB\-p udp\fP options are
33 required.
34 .PP
35 The SYSRQ password can be changed through
36 /sys/module/xt_SYSRQ/parameters/password, for example:
37 .IP
38 echo \-n "password" >/sys/module/xt_SYSRQ/parameters/password
39 .PP
40 The module will not respond to sysrq requests until a password has been set.
41 .PP
42 Alternatively, the password may be specified at modprobe time, but this is
43 insecure as people can possible see it through ps(1). You can use an option
44 line in e.g. /etc/modprobe.d/xt_sysrq if it is properly guarded, that is, only
45 readable by root.
46 .IP
47 options xt_SYSRQ password=cookies
48 .PP
49 The hash algorithm can also be specified as a module option, for example, to
50 use SHA-256 instead of the default SHA-1:
51 .IP
52 options xt_SYSRQ hash=sha256
53 .PP
54 The xt_SYSRQ module is normally silent unless a successful request is received,
55 but the \fIdebug\fP module parameter can be used to find exactly why a
56 seemingly correct request is not being processed.
57 .PP
58 To trigger SYSRQ from a remote host, just use socat:
59 .PP
60 .nf
61 sysrq_key="s" # the SysRq key(s)
62 password="password"
63 seqno="$(date +%s)"
64 salt="$(dd bs=12 count=1 if=/dev/urandom 2>/dev/null |
65 openssl enc \-base64)"
66 ipaddr="2001:0db8:0000:0000:0000:ff00:0042:8329"
67 req="$sysrq_key,$seqno,$salt"
68 req="$req,$(echo \-n "$req,$ipaddr,$password" | sha1sum | cut \-c1\-40)"
69
70 echo "$req" | socat stdin udp\-sendto:$ipaddr:9
71 .fi
72 .PP
73 See the Linux docs for possible sysrq keys. Important ones are: re(b)oot,
74 power(o)ff, (s)ync filesystems, (u)mount and remount readonly. More than one
75 sysrq key can be used at once, but bear in mind that, for example, a sync may
76 not complete before a subsequent reboot or poweroff.
77 .PP
78 An IPv4 address should have no leading zeros, an IPv6 address should
79 be in the full expanded form (as shown above). The debug option will cause
80 output to be emitted in the same form.
81 .PP
82 The hashing scheme should be enough to prevent mis-use of SYSRQ in many
83 environments, but it is not perfect: take reasonable precautions to
84 protect your machines.