diff options
author | Damien Miller <djm@mindrot.org> | 2014-02-27 10:17:49 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2014-02-27 10:17:49 +1100 |
commit | e6a74aeeacd01d885262ff8e50eb28faee8c8039 (patch) | |
tree | 5e3bb4872b341d7364268634c7cfeb64658cb50e | |
parent | 08b57c67f3609340ff703fe2782d7058acf2529e (diff) |
- djm@cvs.openbsd.org 2014/02/26 20:28:44
[auth2-gss.c gss-serv.c ssh-gss.h sshd.c]
bz#2107 - cache OIDs of supported GSSAPI mechanisms before privsep
sandboxing, as running this code in the sandbox can cause violations;
ok markus@
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | auth2-gss.c | 9 | ||||
-rw-r--r-- | gss-serv.c | 21 | ||||
-rw-r--r-- | ssh-gss.h | 4 | ||||
-rw-r--r-- | sshd.c | 6 |
5 files changed, 35 insertions, 10 deletions
@@ -4,6 +4,11 @@ | |||
4 | [ssh.c] | 4 | [ssh.c] |
5 | bz#2205: avoid early hostname lookups unless canonicalisation is enabled; | 5 | bz#2205: avoid early hostname lookups unless canonicalisation is enabled; |
6 | ok dtucker@ markus@ | 6 | ok dtucker@ markus@ |
7 | - djm@cvs.openbsd.org 2014/02/26 20:28:44 | ||
8 | [auth2-gss.c gss-serv.c ssh-gss.h sshd.c] | ||
9 | bz#2107 - cache OIDs of supported GSSAPI mechanisms before privsep | ||
10 | sandboxing, as running this code in the sandbox can cause violations; | ||
11 | ok markus@ | ||
7 | 12 | ||
8 | 20140224 | 13 | 20140224 |
9 | - OpenBSD CVS Sync | 14 | - OpenBSD CVS Sync |
diff --git a/auth2-gss.c b/auth2-gss.c index 638d8f88e..c28a705cb 100644 --- a/auth2-gss.c +++ b/auth2-gss.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: auth2-gss.c,v 1.20 2013/05/17 00:13:13 djm Exp $ */ | 1 | /* $OpenBSD: auth2-gss.c,v 1.21 2014/02/26 20:28:44 djm Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved. | 4 | * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved. |
@@ -62,7 +62,6 @@ userauth_gssapi(Authctxt *authctxt) | |||
62 | gss_OID_desc goid = {0, NULL}; | 62 | gss_OID_desc goid = {0, NULL}; |
63 | Gssctxt *ctxt = NULL; | 63 | Gssctxt *ctxt = NULL; |
64 | int mechs; | 64 | int mechs; |
65 | gss_OID_set supported; | ||
66 | int present; | 65 | int present; |
67 | OM_uint32 ms; | 66 | OM_uint32 ms; |
68 | u_int len; | 67 | u_int len; |
@@ -77,7 +76,6 @@ userauth_gssapi(Authctxt *authctxt) | |||
77 | return (0); | 76 | return (0); |
78 | } | 77 | } |
79 | 78 | ||
80 | ssh_gssapi_supported_oids(&supported); | ||
81 | do { | 79 | do { |
82 | mechs--; | 80 | mechs--; |
83 | 81 | ||
@@ -90,15 +88,12 @@ userauth_gssapi(Authctxt *authctxt) | |||
90 | doid[1] == len - 2) { | 88 | doid[1] == len - 2) { |
91 | goid.elements = doid + 2; | 89 | goid.elements = doid + 2; |
92 | goid.length = len - 2; | 90 | goid.length = len - 2; |
93 | gss_test_oid_set_member(&ms, &goid, supported, | 91 | ssh_gssapi_test_oid_supported(&ms, &goid, &present); |
94 | &present); | ||
95 | } else { | 92 | } else { |
96 | logit("Badly formed OID received"); | 93 | logit("Badly formed OID received"); |
97 | } | 94 | } |
98 | } while (mechs > 0 && !present); | 95 | } while (mechs > 0 && !present); |
99 | 96 | ||
100 | gss_release_oid_set(&ms, &supported); | ||
101 | |||
102 | if (!present) { | 97 | if (!present) { |
103 | free(doid); | 98 | free(doid); |
104 | authctxt->server_caused_failure = 1; | 99 | authctxt->server_caused_failure = 1; |
diff --git a/gss-serv.c b/gss-serv.c index b61e6e140..e61b37bec 100644 --- a/gss-serv.c +++ b/gss-serv.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: gss-serv.c,v 1.25 2014/02/02 03:44:31 djm Exp $ */ | 1 | /* $OpenBSD: gss-serv.c,v 1.26 2014/02/26 20:28:44 djm Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved. | 4 | * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved. |
@@ -66,6 +66,25 @@ ssh_gssapi_mech* supported_mechs[]= { | |||
66 | &gssapi_null_mech, | 66 | &gssapi_null_mech, |
67 | }; | 67 | }; |
68 | 68 | ||
69 | /* | ||
70 | * ssh_gssapi_supported_oids() can cause sandbox violations, so prepare the | ||
71 | * list of supported mechanisms before privsep is set up. | ||
72 | */ | ||
73 | static gss_OID_set supported_oids; | ||
74 | |||
75 | void | ||
76 | ssh_gssapi_prepare_supported_oids(void) | ||
77 | { | ||
78 | ssh_gssapi_supported_oids(&supported_oids); | ||
79 | } | ||
80 | |||
81 | OM_uint32 | ||
82 | ssh_gssapi_test_oid_supported(OM_uint32 *ms, gss_OID member, int *present) | ||
83 | { | ||
84 | if (supported_oids == NULL) | ||
85 | ssh_gssapi_prepare_supported_oids(); | ||
86 | return gss_test_oid_set_member(ms, member, supported_oids, present); | ||
87 | } | ||
69 | 88 | ||
70 | /* | 89 | /* |
71 | * Acquire credentials for a server running on the current host. | 90 | * Acquire credentials for a server running on the current host. |
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh-gss.h,v 1.10 2007/06/12 08:20:00 djm Exp $ */ | 1 | /* $OpenBSD: ssh-gss.h,v 1.11 2014/02/26 20:28:44 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved. | 3 | * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved. |
4 | * | 4 | * |
@@ -104,6 +104,8 @@ void ssh_gssapi_set_oid_data(Gssctxt *, void *, size_t); | |||
104 | void ssh_gssapi_set_oid(Gssctxt *, gss_OID); | 104 | void ssh_gssapi_set_oid(Gssctxt *, gss_OID); |
105 | void ssh_gssapi_supported_oids(gss_OID_set *); | 105 | void ssh_gssapi_supported_oids(gss_OID_set *); |
106 | ssh_gssapi_mech *ssh_gssapi_get_ctype(Gssctxt *); | 106 | ssh_gssapi_mech *ssh_gssapi_get_ctype(Gssctxt *); |
107 | void ssh_gssapi_prepare_supported_oids(void); | ||
108 | OM_uint32 ssh_gssapi_test_oid_supported(OM_uint32 *, gss_OID, int *); | ||
107 | 109 | ||
108 | OM_uint32 ssh_gssapi_import_name(Gssctxt *, const char *); | 110 | OM_uint32 ssh_gssapi_import_name(Gssctxt *, const char *); |
109 | OM_uint32 ssh_gssapi_init_ctx(Gssctxt *, int, | 111 | OM_uint32 ssh_gssapi_init_ctx(Gssctxt *, int, |
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: sshd.c,v 1.418 2014/02/02 03:44:32 djm Exp $ */ | 1 | /* $OpenBSD: sshd.c,v 1.419 2014/02/26 20:28:44 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 |
@@ -618,6 +618,10 @@ privsep_preauth_child(void) | |||
618 | /* Enable challenge-response authentication for privilege separation */ | 618 | /* Enable challenge-response authentication for privilege separation */ |
619 | privsep_challenge_enable(); | 619 | privsep_challenge_enable(); |
620 | 620 | ||
621 | /* Cache supported mechanism OIDs for later use */ | ||
622 | if (options.gss_authentication) | ||
623 | ssh_gssapi_prepare_supported_oids(); | ||
624 | |||
621 | arc4random_stir(); | 625 | arc4random_stir(); |
622 | arc4random_buf(rnd, sizeof(rnd)); | 626 | arc4random_buf(rnd, sizeof(rnd)); |
623 | RAND_seed(rnd, sizeof(rnd)); | 627 | RAND_seed(rnd, sizeof(rnd)); |