]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - package/openocd/0003-CVE-2018-5704-Prevent-some-forms-of-Cross-Protocol-S.patch
openocd: add security fix for CVE-2018-5704
[coffee/buildroot.git] / package / openocd / 0003-CVE-2018-5704-Prevent-some-forms-of-Cross-Protocol-S.patch
1 From 3a223ca3ebc7ac24d7726a0cd58e5695bc813657 Mon Sep 17 00:00:00 2001
2 From: Andreas Fritiofson <andreas.fritiofson@gmail.com>
3 Date: Sat, 13 Jan 2018 21:00:47 +0100
4 Subject: [PATCH] CVE-2018-5704: Prevent some forms of Cross Protocol Scripting
5  attacks
6
7 OpenOCD can be targeted by a Cross Protocol Scripting attack from
8 a web browser running malicious code, such as the following PoC:
9
10 var x = new XMLHttpRequest();
11 x.open("POST", "http://127.0.0.1:4444", true);
12 x.send("exec xcalc\r\n");
13
14 This mitigation should provide some protection from browser-based
15 attacks and is based on the corresponding fix in Redis:
16
17 https://github.com/antirez/redis/blob/8075572207b5aebb1385c4f233f5302544439325/src/networking.c#L1758
18
19
20 Upstream-status: Under review: http://openocd.zylin.com/#/c/4335/
21 Change-Id: Ia96ebe19b74b5805dc228bf7364c7971a90a4581
22 Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
23 Reported-by: Josef Gajdusek <atx@atx.name>
24 Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
25 ---
26  src/server/startup.tcl | 11 +++++++++++
27  1 file changed, 11 insertions(+)
28
29 diff --git a/src/server/startup.tcl b/src/server/startup.tcl
30 index 64ace407..dd1b31e4 100644
31 --- a/src/server/startup.tcl
32 +++ b/src/server/startup.tcl
33 @@ -8,3 +8,14 @@ proc ocd_gdb_restart {target_id} {
34         # one target
35         reset halt
36  }
37 +
38 +proc prevent_cps {} {
39 +       echo "Possible SECURITY ATTACK detected."
40 +       echo "It looks like somebody is sending POST or Host: commands to OpenOCD."
41 +       echo "This is likely due to an attacker attempting to use Cross Protocol Scripting"
42 +       echo "to compromise your OpenOCD instance. Connection aborted."
43 +       exit
44 +}
45 +
46 +proc POST {args} { prevent_cps }
47 +proc Host: {args} { prevent_cps }
48 -- 
49 2.11.0
50