diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | clientloop.c | 26 | ||||
-rw-r--r-- | clientloop.h | 4 | ||||
-rw-r--r-- | mux.c | 9 | ||||
-rw-r--r-- | readconf.c | 14 | ||||
-rw-r--r-- | readconf.h | 3 | ||||
-rw-r--r-- | ssh.c | 9 | ||||
-rw-r--r-- | ssh_config.5 | 14 |
8 files changed, 66 insertions, 20 deletions
@@ -74,6 +74,13 @@ | |||
74 | servers with trusted keys that accept authentication silently and | 74 | servers with trusted keys that accept authentication silently and |
75 | automatically before presenting fake password/passphrase prompts; | 75 | automatically before presenting fake password/passphrase prompts; |
76 | "nice!" markus@ | 76 | "nice!" markus@ |
77 | - djm@cvs.openbsd.org 2010/06/25 23:10:30 | ||
78 | [ssh.c] | ||
79 | log the hostname and address that we connected to at LogLevel=verbose | ||
80 | after authentication is successful to mitigate "phishing" attacks by | ||
81 | servers with trusted keys that accept authentication silently and | ||
82 | automatically before presenting fake password/passphrase prompts; | ||
83 | "nice!" markus@ | ||
77 | 84 | ||
78 | 20100622 | 85 | 20100622 |
79 | - (djm) [loginrec.c] crank LINFO_NAMESIZE (username length) to 512 | 86 | - (djm) [loginrec.c] crank LINFO_NAMESIZE (username length) to 512 |
diff --git a/clientloop.c b/clientloop.c index 76de37213..5608bcc2e 100644 --- a/clientloop.c +++ b/clientloop.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: clientloop.c,v 1.220 2010/04/10 02:08:44 djm Exp $ */ | 1 | /* $OpenBSD: clientloop.c,v 1.221 2010/06/25 23:15:36 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -155,11 +155,12 @@ static int stdin_eof; /* EOF has been encountered on stderr. */ | |||
155 | static Buffer stdin_buffer; /* Buffer for stdin data. */ | 155 | static Buffer stdin_buffer; /* Buffer for stdin data. */ |
156 | static Buffer stdout_buffer; /* Buffer for stdout data. */ | 156 | static Buffer stdout_buffer; /* Buffer for stdout data. */ |
157 | static Buffer stderr_buffer; /* Buffer for stderr data. */ | 157 | static Buffer stderr_buffer; /* Buffer for stderr data. */ |
158 | static u_int buffer_high;/* Soft max buffer size. */ | 158 | static u_int buffer_high; /* Soft max buffer size. */ |
159 | static int connection_in; /* Connection to server (input). */ | 159 | static int connection_in; /* Connection to server (input). */ |
160 | static int connection_out; /* Connection to server (output). */ | 160 | static int connection_out; /* Connection to server (output). */ |
161 | static int need_rekeying; /* Set to non-zero if rekeying is requested. */ | 161 | static int need_rekeying; /* Set to non-zero if rekeying is requested. */ |
162 | static int session_closed = 0; /* In SSH2: login session closed. */ | 162 | static int session_closed; /* In SSH2: login session closed. */ |
163 | static int x11_refuse_time; /* If >0, refuse x11 opens after this time. */ | ||
163 | 164 | ||
164 | static void client_init_dispatch(void); | 165 | static void client_init_dispatch(void); |
165 | int session_ident = -1; | 166 | int session_ident = -1; |
@@ -254,7 +255,7 @@ get_current_time(void) | |||
254 | #define SSH_X11_PROTO "MIT-MAGIC-COOKIE-1" | 255 | #define SSH_X11_PROTO "MIT-MAGIC-COOKIE-1" |
255 | void | 256 | void |
256 | client_x11_get_proto(const char *display, const char *xauth_path, | 257 | client_x11_get_proto(const char *display, const char *xauth_path, |
257 | u_int trusted, char **_proto, char **_data) | 258 | u_int trusted, u_int timeout, char **_proto, char **_data) |
258 | { | 259 | { |
259 | char cmd[1024]; | 260 | char cmd[1024]; |
260 | char line[512]; | 261 | char line[512]; |
@@ -264,6 +265,7 @@ client_x11_get_proto(const char *display, const char *xauth_path, | |||
264 | int got_data = 0, generated = 0, do_unlink = 0, i; | 265 | int got_data = 0, generated = 0, do_unlink = 0, i; |
265 | char *xauthdir, *xauthfile; | 266 | char *xauthdir, *xauthfile; |
266 | struct stat st; | 267 | struct stat st; |
268 | u_int now; | ||
267 | 269 | ||
268 | xauthdir = xauthfile = NULL; | 270 | xauthdir = xauthfile = NULL; |
269 | *_proto = proto; | 271 | *_proto = proto; |
@@ -299,11 +301,18 @@ client_x11_get_proto(const char *display, const char *xauth_path, | |||
299 | xauthdir); | 301 | xauthdir); |
300 | snprintf(cmd, sizeof(cmd), | 302 | snprintf(cmd, sizeof(cmd), |
301 | "%s -f %s generate %s " SSH_X11_PROTO | 303 | "%s -f %s generate %s " SSH_X11_PROTO |
302 | " untrusted timeout 1200 2>" _PATH_DEVNULL, | 304 | " untrusted timeout %u 2>" _PATH_DEVNULL, |
303 | xauth_path, xauthfile, display); | 305 | xauth_path, xauthfile, display, timeout); |
304 | debug2("x11_get_proto: %s", cmd); | 306 | debug2("x11_get_proto: %s", cmd); |
305 | if (system(cmd) == 0) | 307 | if (system(cmd) == 0) |
306 | generated = 1; | 308 | generated = 1; |
309 | if (x11_refuse_time == 0) { | ||
310 | now = time(NULL) + 1; | ||
311 | if (UINT_MAX - timeout < now) | ||
312 | x11_refuse_time = UINT_MAX; | ||
313 | else | ||
314 | x11_refuse_time = now + timeout; | ||
315 | } | ||
307 | } | 316 | } |
308 | } | 317 | } |
309 | 318 | ||
@@ -1686,6 +1695,11 @@ client_request_x11(const char *request_type, int rchan) | |||
1686 | "malicious server."); | 1695 | "malicious server."); |
1687 | return NULL; | 1696 | return NULL; |
1688 | } | 1697 | } |
1698 | if (x11_refuse_time != 0 && time(NULL) >= x11_refuse_time) { | ||
1699 | verbose("Rejected X11 connection after ForwardX11Timeout " | ||
1700 | "expired"); | ||
1701 | return NULL; | ||
1702 | } | ||
1689 | originator = packet_get_string(NULL); | 1703 | originator = packet_get_string(NULL); |
1690 | if (datafellows & SSH_BUG_X11FWD) { | 1704 | if (datafellows & SSH_BUG_X11FWD) { |
1691 | debug2("buggy server: x11 request w/o originator_port"); | 1705 | debug2("buggy server: x11 request w/o originator_port"); |
diff --git a/clientloop.h b/clientloop.h index a5bc246a3..52115db6e 100644 --- a/clientloop.h +++ b/clientloop.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: clientloop.h,v 1.24 2010/05/16 12:55:51 markus Exp $ */ | 1 | /* $OpenBSD: clientloop.h,v 1.25 2010/06/25 23:15:36 djm Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
@@ -39,7 +39,7 @@ | |||
39 | 39 | ||
40 | /* Client side main loop for the interactive session. */ | 40 | /* Client side main loop for the interactive session. */ |
41 | int client_loop(int, int, int); | 41 | int client_loop(int, int, int); |
42 | void client_x11_get_proto(const char *, const char *, u_int, | 42 | void client_x11_get_proto(const char *, const char *, u_int, u_int, |
43 | char **, char **); | 43 | char **, char **); |
44 | void client_global_request_reply_fwd(int, u_int32_t, void *); | 44 | void client_global_request_reply_fwd(int, u_int32_t, void *); |
45 | void client_session2_setup(int, int, int, const char *, struct termios *, | 45 | void client_session2_setup(int, int, int, const char *, struct termios *, |
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: mux.c,v 1.20 2010/06/25 07:14:46 djm Exp $ */ | 1 | /* $OpenBSD: mux.c,v 1.21 2010/06/25 23:15:36 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2002-2008 Damien Miller <djm@openbsd.org> | 3 | * Copyright (c) 2002-2008 Damien Miller <djm@openbsd.org> |
4 | * | 4 | * |
@@ -1107,11 +1107,14 @@ mux_session_confirm(int id, int success, void *arg) | |||
1107 | display = getenv("DISPLAY"); | 1107 | display = getenv("DISPLAY"); |
1108 | if (cctx->want_x_fwd && options.forward_x11 && display != NULL) { | 1108 | if (cctx->want_x_fwd && options.forward_x11 && display != NULL) { |
1109 | char *proto, *data; | 1109 | char *proto, *data; |
1110 | |||
1110 | /* Get reasonable local authentication information. */ | 1111 | /* Get reasonable local authentication information. */ |
1111 | client_x11_get_proto(display, options.xauth_location, | 1112 | client_x11_get_proto(display, options.xauth_location, |
1112 | options.forward_x11_trusted, &proto, &data); | 1113 | options.forward_x11_trusted, options.forward_x11_timeout, |
1114 | &proto, &data); | ||
1113 | /* Request forwarding with authentication spoofing. */ | 1115 | /* Request forwarding with authentication spoofing. */ |
1114 | debug("Requesting X11 forwarding with authentication spoofing."); | 1116 | debug("Requesting X11 forwarding with authentication " |
1117 | "spoofing."); | ||
1115 | x11_request_forwarding_with_spoofing(id, display, proto, data); | 1118 | x11_request_forwarding_with_spoofing(id, display, proto, data); |
1116 | /* XXX wait for reply */ | 1119 | /* XXX wait for reply */ |
1117 | } | 1120 | } |
diff --git a/readconf.c b/readconf.c index aae9cef4b..da48ae7da 100644 --- a/readconf.c +++ b/readconf.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: readconf.c,v 1.185 2010/06/25 07:14:46 djm Exp $ */ | 1 | /* $OpenBSD: readconf.c,v 1.186 2010/06/25 23:15:36 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -110,8 +110,8 @@ | |||
110 | 110 | ||
111 | typedef enum { | 111 | typedef enum { |
112 | oBadOption, | 112 | oBadOption, |
113 | oForwardAgent, oForwardX11, oForwardX11Trusted, oGatewayPorts, | 113 | oForwardAgent, oForwardX11, oForwardX11Trusted, oForwardX11Timeout, |
114 | oExitOnForwardFailure, | 114 | oGatewayPorts, oExitOnForwardFailure, |
115 | oPasswordAuthentication, oRSAAuthentication, | 115 | oPasswordAuthentication, oRSAAuthentication, |
116 | oChallengeResponseAuthentication, oXAuthLocation, | 116 | oChallengeResponseAuthentication, oXAuthLocation, |
117 | oIdentityFile, oHostName, oPort, oCipher, oRemoteForward, oLocalForward, | 117 | oIdentityFile, oHostName, oPort, oCipher, oRemoteForward, oLocalForward, |
@@ -143,6 +143,7 @@ static struct { | |||
143 | { "forwardagent", oForwardAgent }, | 143 | { "forwardagent", oForwardAgent }, |
144 | { "forwardx11", oForwardX11 }, | 144 | { "forwardx11", oForwardX11 }, |
145 | { "forwardx11trusted", oForwardX11Trusted }, | 145 | { "forwardx11trusted", oForwardX11Trusted }, |
146 | { "forwardx11timeout", oForwardX11Timeout }, | ||
146 | { "exitonforwardfailure", oExitOnForwardFailure }, | 147 | { "exitonforwardfailure", oExitOnForwardFailure }, |
147 | { "xauthlocation", oXAuthLocation }, | 148 | { "xauthlocation", oXAuthLocation }, |
148 | { "gatewayports", oGatewayPorts }, | 149 | { "gatewayports", oGatewayPorts }, |
@@ -414,6 +415,10 @@ parse_flag: | |||
414 | case oForwardX11Trusted: | 415 | case oForwardX11Trusted: |
415 | intptr = &options->forward_x11_trusted; | 416 | intptr = &options->forward_x11_trusted; |
416 | goto parse_flag; | 417 | goto parse_flag; |
418 | |||
419 | case oForwardX11Timeout: | ||
420 | intptr = &options->forward_x11_timeout; | ||
421 | goto parse_time; | ||
417 | 422 | ||
418 | case oGatewayPorts: | 423 | case oGatewayPorts: |
419 | intptr = &options->gateway_ports; | 424 | intptr = &options->gateway_ports; |
@@ -1018,6 +1023,7 @@ initialize_options(Options * options) | |||
1018 | options->forward_agent = -1; | 1023 | options->forward_agent = -1; |
1019 | options->forward_x11 = -1; | 1024 | options->forward_x11 = -1; |
1020 | options->forward_x11_trusted = -1; | 1025 | options->forward_x11_trusted = -1; |
1026 | options->forward_x11_timeout = -1; | ||
1021 | options->exit_on_forward_failure = -1; | 1027 | options->exit_on_forward_failure = -1; |
1022 | options->xauth_location = NULL; | 1028 | options->xauth_location = NULL; |
1023 | options->gateway_ports = -1; | 1029 | options->gateway_ports = -1; |
@@ -1104,6 +1110,8 @@ fill_default_options(Options * options) | |||
1104 | options->forward_x11 = 0; | 1110 | options->forward_x11 = 0; |
1105 | if (options->forward_x11_trusted == -1) | 1111 | if (options->forward_x11_trusted == -1) |
1106 | options->forward_x11_trusted = 0; | 1112 | options->forward_x11_trusted = 0; |
1113 | if (options->forward_x11_timeout == -1) | ||
1114 | options->forward_x11_timeout = 1200; | ||
1107 | if (options->exit_on_forward_failure == -1) | 1115 | if (options->exit_on_forward_failure == -1) |
1108 | options->exit_on_forward_failure = 0; | 1116 | options->exit_on_forward_failure = 0; |
1109 | if (options->xauth_location == NULL) | 1117 | if (options->xauth_location == NULL) |
diff --git a/readconf.h b/readconf.h index 3c8eae9d2..66acafdef 100644 --- a/readconf.h +++ b/readconf.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: readconf.h,v 1.84 2010/06/25 07:14:46 djm Exp $ */ | 1 | /* $OpenBSD: readconf.h,v 1.85 2010/06/25 23:15:36 djm Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
@@ -32,6 +32,7 @@ typedef struct { | |||
32 | typedef struct { | 32 | typedef struct { |
33 | int forward_agent; /* Forward authentication agent. */ | 33 | int forward_agent; /* Forward authentication agent. */ |
34 | int forward_x11; /* Forward X11 display. */ | 34 | int forward_x11; /* Forward X11 display. */ |
35 | int forward_x11_timeout; /* Expiration for Cookies */ | ||
35 | int forward_x11_trusted; /* Trust Forward X11 display. */ | 36 | int forward_x11_trusted; /* Trust Forward X11 display. */ |
36 | int exit_on_forward_failure; /* Exit if bind(2) fails for -L/-R */ | 37 | int exit_on_forward_failure; /* Exit if bind(2) fails for -L/-R */ |
37 | char *xauth_location; /* Location for xauth program */ | 38 | char *xauth_location; /* Location for xauth program */ |
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh.c,v 1.339 2010/06/25 23:10:30 djm Exp $ */ | 1 | /* $OpenBSD: ssh.c,v 1.340 2010/06/25 23:15:36 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -1103,7 +1103,9 @@ ssh_session(void) | |||
1103 | char *proto, *data; | 1103 | char *proto, *data; |
1104 | /* Get reasonable local authentication information. */ | 1104 | /* Get reasonable local authentication information. */ |
1105 | client_x11_get_proto(display, options.xauth_location, | 1105 | client_x11_get_proto(display, options.xauth_location, |
1106 | options.forward_x11_trusted, &proto, &data); | 1106 | options.forward_x11_trusted, |
1107 | options.forward_x11_timeout, | ||
1108 | &proto, &data); | ||
1107 | /* Request forwarding with authentication spoofing. */ | 1109 | /* Request forwarding with authentication spoofing. */ |
1108 | debug("Requesting X11 forwarding with authentication " | 1110 | debug("Requesting X11 forwarding with authentication " |
1109 | "spoofing."); | 1111 | "spoofing."); |
@@ -1199,7 +1201,8 @@ ssh_session2_setup(int id, int success, void *arg) | |||
1199 | char *proto, *data; | 1201 | char *proto, *data; |
1200 | /* Get reasonable local authentication information. */ | 1202 | /* Get reasonable local authentication information. */ |
1201 | client_x11_get_proto(display, options.xauth_location, | 1203 | client_x11_get_proto(display, options.xauth_location, |
1202 | options.forward_x11_trusted, &proto, &data); | 1204 | options.forward_x11_trusted, |
1205 | options.forward_x11_timeout, &proto, &data); | ||
1203 | /* Request forwarding with authentication spoofing. */ | 1206 | /* Request forwarding with authentication spoofing. */ |
1204 | debug("Requesting X11 forwarding with authentication " | 1207 | debug("Requesting X11 forwarding with authentication " |
1205 | "spoofing."); | 1208 | "spoofing."); |
diff --git a/ssh_config.5 b/ssh_config.5 index 2df948e62..6968a4488 100644 --- a/ssh_config.5 +++ b/ssh_config.5 | |||
@@ -34,8 +34,8 @@ | |||
34 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 34 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
35 | .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 35 | .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
36 | .\" | 36 | .\" |
37 | .\" $OpenBSD: ssh_config.5,v 1.133 2010/04/16 06:45:01 jmc Exp $ | 37 | .\" $OpenBSD: ssh_config.5,v 1.134 2010/06/25 23:15:36 djm Exp $ |
38 | .Dd $Mdocdate: April 16 2010 $ | 38 | .Dd $Mdocdate: June 25 2010 $ |
39 | .Dt SSH_CONFIG 5 | 39 | .Dt SSH_CONFIG 5 |
40 | .Os | 40 | .Os |
41 | .Sh NAME | 41 | .Sh NAME |
@@ -432,6 +432,16 @@ An attacker may then be able to perform activities such as keystroke monitoring | |||
432 | if the | 432 | if the |
433 | .Cm ForwardX11Trusted | 433 | .Cm ForwardX11Trusted |
434 | option is also enabled. | 434 | option is also enabled. |
435 | .It Cm ForwardX11Timeout | ||
436 | Specify a timeout for untrusted X11 forwarding using the format described in | ||
437 | .Sx TIME FORMATS | ||
438 | section of | ||
439 | .Xr sshd_config 5 . | ||
440 | X11 connections received by | ||
441 | .Xr ssh 1 | ||
442 | after this time will be refused. | ||
443 | The default is to disable untrusted X11 forwarding after twenty minutes has | ||
444 | elapsed. | ||
435 | .It Cm ForwardX11Trusted | 445 | .It Cm ForwardX11Trusted |
436 | If this option is set to | 446 | If this option is set to |
437 | .Dq yes , | 447 | .Dq yes , |