|
Petr Lautrbach |
65ba94 |
diff -up openssh-6.0p1/audit-bsm.c.audit5 openssh-6.0p1/audit-bsm.c
|
|
Petr Lautrbach |
65ba94 |
--- openssh-6.0p1/audit-bsm.c.audit5 2012-08-06 20:37:50.036345216 +0200
|
|
Petr Lautrbach |
65ba94 |
+++ openssh-6.0p1/audit-bsm.c 2012-08-06 20:37:50.046345177 +0200
|
|
Petr Lautrbach |
65ba94 |
@@ -491,4 +491,22 @@ audit_session_key_free_body(int ctos, pi
|
|
Jan F. Chadima |
69dd72 |
{
|
|
Jan F. Chadima |
69dd72 |
/* not implemented */
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+void
|
|
Jan F. Chadima |
69dd72 |
+audit_destroy_sensitive_data(const char *fp)
|
|
Jan F. Chadima |
69dd72 |
+{
|
|
Jan F. Chadima |
69dd72 |
+ /* not implemented */
|
|
Jan F. Chadima |
69dd72 |
+}
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+void
|
|
Jan F. Chadima |
69dd72 |
+audit_destroy_sensitive_data(const char *fp, pid_t pid, uid_t uid)
|
|
Jan F. Chadima |
69dd72 |
+{
|
|
Jan F. Chadima |
69dd72 |
+ /* not implemented */
|
|
Jan F. Chadima |
69dd72 |
+}
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+void
|
|
Jan F. Chadima |
69dd72 |
+audit_generate_ephemeral_server_key(const char *fp)
|
|
Jan F. Chadima |
69dd72 |
+{
|
|
Jan F. Chadima |
69dd72 |
+ /* not implemented */
|
|
Jan F. Chadima |
69dd72 |
+}
|
|
Jan F. Chadima |
69dd72 |
#endif /* BSM */
|
|
Petr Lautrbach |
65ba94 |
diff -up openssh-6.0p1/audit.c.audit5 openssh-6.0p1/audit.c
|
|
Petr Lautrbach |
65ba94 |
--- openssh-6.0p1/audit.c.audit5 2012-08-06 20:37:50.036345216 +0200
|
|
Petr Lautrbach |
65ba94 |
+++ openssh-6.0p1/audit.c 2012-08-06 20:37:50.047345173 +0200
|
|
Petr Lautrbach |
65ba94 |
@@ -290,5 +290,24 @@ audit_session_key_free_body(int ctos, pi
|
|
Petr Lautrbach |
65ba94 |
debug("audit session key discard euid %u direction %d from pid %ld uid %u",
|
|
Petr Lautrbach |
65ba94 |
(unsigned)geteuid(), ctos, (long)pid, (unsigned)uid);
|
|
Petr Lautrbach |
65ba94 |
}
|
|
Petr Lautrbach |
65ba94 |
+
|
|
Petr Lautrbach |
65ba94 |
+/*
|
|
Petr Lautrbach |
65ba94 |
+ * This will be called on destroy private part of the server key
|
|
Petr Lautrbach |
65ba94 |
+ */
|
|
Petr Lautrbach |
65ba94 |
+void
|
|
Petr Lautrbach |
65ba94 |
+audit_destroy_sensitive_data(const char *fp, pid_t pid, uid_t uid)
|
|
Petr Lautrbach |
65ba94 |
+{
|
|
Petr Lautrbach |
65ba94 |
+ debug("audit destroy sensitive data euid %d fingerprint %s from pid %ld uid %u",
|
|
Petr Lautrbach |
65ba94 |
+ geteuid(), fp, (long)pid, (unsigned)uid);
|
|
Petr Lautrbach |
65ba94 |
+}
|
|
Petr Lautrbach |
65ba94 |
+
|
|
Petr Lautrbach |
65ba94 |
+/*
|
|
Petr Lautrbach |
65ba94 |
+ * This will be called on generation of the ephemeral server key
|
|
Petr Lautrbach |
65ba94 |
+ */
|
|
Petr Lautrbach |
65ba94 |
+void
|
|
Petr Lautrbach |
65ba94 |
+audit_generate_ephemeral_server_key(const char *)
|
|
Petr Lautrbach |
65ba94 |
+{
|
|
Petr Lautrbach |
65ba94 |
+ debug("audit create ephemeral server key euid %d fingerprint %s", geteuid(), fp);
|
|
Petr Lautrbach |
65ba94 |
+}
|
|
Petr Lautrbach |
65ba94 |
# endif /* !defined CUSTOM_SSH_AUDIT_EVENTS */
|
|
Petr Lautrbach |
65ba94 |
#endif /* SSH_AUDIT_EVENTS */
|
|
Petr Lautrbach |
65ba94 |
diff -up openssh-6.0p1/audit.h.audit5 openssh-6.0p1/audit.h
|
|
Petr Lautrbach |
65ba94 |
--- openssh-6.0p1/audit.h.audit5 2012-08-06 20:37:50.037345212 +0200
|
|
Petr Lautrbach |
65ba94 |
+++ openssh-6.0p1/audit.h 2012-08-06 20:37:50.047345173 +0200
|
|
Petr Lautrbach |
65ba94 |
@@ -48,6 +48,8 @@ enum ssh_audit_event_type {
|
|
Petr Lautrbach |
65ba94 |
};
|
|
Petr Lautrbach |
65ba94 |
typedef enum ssh_audit_event_type ssh_audit_event_t;
|
|
Petr Lautrbach |
65ba94 |
|
|
Petr Lautrbach |
65ba94 |
+int listening_for_clients(void);
|
|
Petr Lautrbach |
65ba94 |
+
|
|
Petr Lautrbach |
65ba94 |
void audit_connection_from(const char *, int);
|
|
Petr Lautrbach |
65ba94 |
void audit_event(ssh_audit_event_t);
|
|
Petr Lautrbach |
65ba94 |
void audit_count_session_open(void);
|
|
Petr Lautrbach |
65ba94 |
@@ -64,5 +66,7 @@ void audit_unsupported_body(int);
|
|
Petr Lautrbach |
65ba94 |
void audit_kex_body(int, char *, char *, char *, pid_t, uid_t);
|
|
Petr Lautrbach |
65ba94 |
void audit_session_key_free(int ctos);
|
|
Petr Lautrbach |
65ba94 |
void audit_session_key_free_body(int ctos, pid_t, uid_t);
|
|
Petr Lautrbach |
65ba94 |
+void audit_destroy_sensitive_data(const char *, pid_t, uid_t);
|
|
Petr Lautrbach |
65ba94 |
+void audit_generate_ephemeral_server_key(const char *);
|
|
Petr Lautrbach |
65ba94 |
|
|
Petr Lautrbach |
65ba94 |
#endif /* _SSH_AUDIT_H */
|
|
Petr Lautrbach |
65ba94 |
diff -up openssh-6.0p1/audit-linux.c.audit5 openssh-6.0p1/audit-linux.c
|
|
Petr Lautrbach |
65ba94 |
--- openssh-6.0p1/audit-linux.c.audit5 2012-08-06 20:37:50.037345212 +0200
|
|
Petr Lautrbach |
65ba94 |
+++ openssh-6.0p1/audit-linux.c 2012-08-06 20:37:50.046345177 +0200
|
|
Petr Lautrbach |
65ba94 |
@@ -356,4 +356,50 @@ audit_session_key_free_body(int ctos, pi
|
|
Jan F. Chadima |
69dd72 |
error("cannot write into audit");
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
+void
|
|
Jan F. Chadima |
69dd72 |
+audit_destroy_sensitive_data(const char *fp, pid_t pid, uid_t uid)
|
|
Jan F. Chadima |
69dd72 |
+{
|
|
Jan F. Chadima |
69dd72 |
+ char buf[AUDIT_LOG_SIZE];
|
|
Jan F. Chadima |
69dd72 |
+ int audit_fd, audit_ok;
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ snprintf(buf, sizeof(buf), "op=destroy kind=server fp=%s direction=? spid=%jd suid=%jd ",
|
|
Jan F. Chadima |
69dd72 |
+ fp, (intmax_t)pid, (intmax_t)uid);
|
|
Jan F. Chadima |
69dd72 |
+ audit_fd = audit_open();
|
|
Jan F. Chadima |
69dd72 |
+ if (audit_fd < 0) {
|
|
Jan F. Chadima |
69dd72 |
+ if (errno != EINVAL && errno != EPROTONOSUPPORT &&
|
|
Jan F. Chadima |
69dd72 |
+ errno != EAFNOSUPPORT)
|
|
Jan F. Chadima |
69dd72 |
+ error("cannot open audit");
|
|
Jan F. Chadima |
69dd72 |
+ return;
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
+ audit_ok = audit_log_user_message(audit_fd, AUDIT_CRYPTO_KEY_USER,
|
|
Jan F. Chadima |
69dd72 |
+ buf, NULL,
|
|
Jan F. Chadima |
69dd72 |
+ listening_for_clients() ? NULL : get_remote_ipaddr(),
|
|
Jan F. Chadima |
69dd72 |
+ NULL, 1);
|
|
Jan F. Chadima |
69dd72 |
+ audit_close(audit_fd);
|
|
Jan F. Chadima |
69dd72 |
+ /* do not abort if the error is EPERM and sshd is run as non root user */
|
|
Jan F. Chadima |
69dd72 |
+ if ((audit_ok < 0) && ((audit_ok != -1) || (getuid() == 0)))
|
|
Jan F. Chadima |
69dd72 |
+ error("cannot write into audit");
|
|
Jan F. Chadima |
69dd72 |
+}
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+void
|
|
Jan F. Chadima |
69dd72 |
+audit_generate_ephemeral_server_key(const char *fp)
|
|
Jan F. Chadima |
69dd72 |
+{
|
|
Jan F. Chadima |
69dd72 |
+ char buf[AUDIT_LOG_SIZE];
|
|
Jan F. Chadima |
69dd72 |
+ int audit_fd, audit_ok;
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ snprintf(buf, sizeof(buf), "op=create kind=server fp=%s direction=? ", fp);
|
|
Jan F. Chadima |
69dd72 |
+ audit_fd = audit_open();
|
|
Jan F. Chadima |
69dd72 |
+ if (audit_fd < 0) {
|
|
Jan F. Chadima |
69dd72 |
+ if (errno != EINVAL && errno != EPROTONOSUPPORT &&
|
|
Jan F. Chadima |
69dd72 |
+ errno != EAFNOSUPPORT)
|
|
Jan F. Chadima |
69dd72 |
+ error("cannot open audit");
|
|
Jan F. Chadima |
69dd72 |
+ return;
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
+ audit_ok = audit_log_user_message(audit_fd, AUDIT_CRYPTO_KEY_USER,
|
|
Jan F. Chadima |
69dd72 |
+ buf, NULL, 0, NULL, 1);
|
|
Jan F. Chadima |
69dd72 |
+ audit_close(audit_fd);
|
|
Jan F. Chadima |
69dd72 |
+ /* do not abort if the error is EPERM and sshd is run as non root user */
|
|
Jan F. Chadima |
69dd72 |
+ if ((audit_ok < 0) && ((audit_ok != -1) || (getuid() == 0)))
|
|
Jan F. Chadima |
69dd72 |
+ error("cannot write into audit");
|
|
Jan F. Chadima |
69dd72 |
+}
|
|
Jan F. Chadima |
69dd72 |
#endif /* USE_LINUX_AUDIT */
|
|
Petr Lautrbach |
65ba94 |
diff -up openssh-6.0p1/key.c.audit5 openssh-6.0p1/key.c
|
|
Petr Lautrbach |
65ba94 |
--- openssh-6.0p1/key.c.audit5 2012-08-06 20:37:49.992345388 +0200
|
|
Petr Lautrbach |
65ba94 |
+++ openssh-6.0p1/key.c 2012-08-06 20:37:50.048345169 +0200
|
|
Petr Lautrbach |
65ba94 |
@@ -1794,6 +1794,30 @@ key_demote(const Key *k)
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
int
|
|
Jan F. Chadima |
69dd72 |
+key_is_private(const Key *k)
|
|
Jan F. Chadima |
69dd72 |
+{
|
|
Jan F. Chadima |
69dd72 |
+ switch (k->type) {
|
|
Jan F. Chadima |
69dd72 |
+ case KEY_RSA_CERT_V00:
|
|
Jan F. Chadima |
69dd72 |
+ case KEY_RSA_CERT:
|
|
Jan F. Chadima |
69dd72 |
+ case KEY_RSA1:
|
|
Jan F. Chadima |
69dd72 |
+ case KEY_RSA:
|
|
Jan F. Chadima |
69dd72 |
+ return k->rsa->d != NULL;
|
|
Jan F. Chadima |
69dd72 |
+ case KEY_DSA_CERT_V00:
|
|
Jan F. Chadima |
69dd72 |
+ case KEY_DSA_CERT:
|
|
Jan F. Chadima |
69dd72 |
+ case KEY_DSA:
|
|
Jan F. Chadima |
69dd72 |
+ return k->dsa->priv_key != NULL;
|
|
Jan F. Chadima |
69dd72 |
+#ifdef OPENSSL_HAS_ECC
|
|
Jan F. Chadima |
69dd72 |
+ case KEY_ECDSA_CERT:
|
|
Jan F. Chadima |
69dd72 |
+ case KEY_ECDSA:
|
|
Jan F. Chadima |
69dd72 |
+ return EC_KEY_get0_private_key(k->ecdsa) != NULL;
|
|
Jan F. Chadima |
69dd72 |
+#endif
|
|
Jan F. Chadima |
69dd72 |
+ default:
|
|
Jan F. Chadima |
69dd72 |
+ fatal("key_is_private: bad key type %d", k->type);
|
|
Jan F. Chadima |
69dd72 |
+ return 1;
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
+}
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+int
|
|
Jan F. Chadima |
69dd72 |
key_is_cert(const Key *k)
|
|
Jan F. Chadima |
69dd72 |
{
|
|
Jan F. Chadima |
69dd72 |
if (k == NULL)
|
|
Petr Lautrbach |
65ba94 |
diff -up openssh-6.0p1/key.h.audit5 openssh-6.0p1/key.h
|
|
Petr Lautrbach |
65ba94 |
--- openssh-6.0p1/key.h.audit5 2012-08-06 20:37:49.993345384 +0200
|
|
Petr Lautrbach |
65ba94 |
+++ openssh-6.0p1/key.h 2012-08-06 20:37:50.049345165 +0200
|
|
Jan F. Chadima |
69dd72 |
@@ -109,6 +109,7 @@ Key *key_generate(int, u_int);
|
|
Jan F. Chadima |
69dd72 |
Key *key_from_private(const Key *);
|
|
Jan F. Chadima |
69dd72 |
int key_type_from_name(char *);
|
|
Jan F. Chadima |
69dd72 |
int key_is_cert(const Key *);
|
|
Jan F. Chadima |
69dd72 |
+int key_is_private(const Key *k);
|
|
Jan F. Chadima |
69dd72 |
int key_type_plain(int);
|
|
Jan F. Chadima |
69dd72 |
int key_to_certified(Key *, int);
|
|
Jan F. Chadima |
69dd72 |
int key_drop_cert(Key *);
|
|
Petr Lautrbach |
65ba94 |
diff -up openssh-6.0p1/monitor.c.audit5 openssh-6.0p1/monitor.c
|
|
Petr Lautrbach |
65ba94 |
--- openssh-6.0p1/monitor.c.audit5 2012-08-06 20:37:50.040345200 +0200
|
|
Petr Lautrbach |
65ba94 |
+++ openssh-6.0p1/monitor.c 2012-08-06 20:37:50.049345165 +0200
|
|
Jan F. Chadima |
69dd72 |
@@ -114,6 +114,8 @@ extern Buffer auth_debug;
|
|
Jan F. Chadima |
69dd72 |
extern int auth_debug_init;
|
|
Jan F. Chadima |
69dd72 |
extern Buffer loginmsg;
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
+extern void destroy_sensitive_data(int);
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
/* State exported from the child */
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
struct {
|
|
Petr Lautrbach |
65ba94 |
@@ -190,6 +192,7 @@ int mm_answer_audit_end_command(int, Buf
|
|
Jan F. Chadima |
69dd72 |
int mm_answer_audit_unsupported_body(int, Buffer *);
|
|
Jan F. Chadima |
69dd72 |
int mm_answer_audit_kex_body(int, Buffer *);
|
|
Jan F. Chadima |
69dd72 |
int mm_answer_audit_session_key_free_body(int, Buffer *);
|
|
Jan F. Chadima |
69dd72 |
+int mm_answer_audit_server_key_free(int, Buffer *);
|
|
Jan F. Chadima |
69dd72 |
#endif
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
static int monitor_read_log(struct monitor *);
|
|
Jan F. Chadima |
69dd72 |
@@ -244,6 +247,7 @@ struct mon_table mon_dispatch_proto20[]
|
|
Jan F. Chadima |
69dd72 |
{MONITOR_REQ_AUDIT_UNSUPPORTED, MON_PERMIT, mm_answer_audit_unsupported_body},
|
|
Jan F. Chadima |
69dd72 |
{MONITOR_REQ_AUDIT_KEX, MON_PERMIT, mm_answer_audit_kex_body},
|
|
Jan F. Chadima |
69dd72 |
{MONITOR_REQ_AUDIT_SESSION_KEY_FREE, MON_PERMIT, mm_answer_audit_session_key_free_body},
|
|
Jan F. Chadima |
69dd72 |
+ {MONITOR_REQ_AUDIT_SERVER_KEY_FREE, MON_PERMIT, mm_answer_audit_server_key_free},
|
|
Jan F. Chadima |
69dd72 |
#endif
|
|
Jan F. Chadima |
69dd72 |
#ifdef BSD_AUTH
|
|
Jan F. Chadima |
69dd72 |
{MONITOR_REQ_BSDAUTHQUERY, MON_ISAUTH, mm_answer_bsdauthquery},
|
|
Petr Lautrbach |
65ba94 |
@@ -284,6 +288,7 @@ struct mon_table mon_dispatch_postauth20
|
|
Jan F. Chadima |
69dd72 |
{MONITOR_REQ_AUDIT_UNSUPPORTED, MON_PERMIT, mm_answer_audit_unsupported_body},
|
|
Jan F. Chadima |
69dd72 |
{MONITOR_REQ_AUDIT_KEX, MON_PERMIT, mm_answer_audit_kex_body},
|
|
Jan F. Chadima |
69dd72 |
{MONITOR_REQ_AUDIT_SESSION_KEY_FREE, MON_PERMIT, mm_answer_audit_session_key_free_body},
|
|
Jan F. Chadima |
69dd72 |
+ {MONITOR_REQ_AUDIT_SERVER_KEY_FREE, MON_PERMIT, mm_answer_audit_server_key_free},
|
|
Jan F. Chadima |
69dd72 |
#endif
|
|
Jan F. Chadima |
69dd72 |
{0, 0, NULL}
|
|
Jan F. Chadima |
69dd72 |
};
|
|
Petr Lautrbach |
65ba94 |
@@ -318,6 +323,7 @@ struct mon_table mon_dispatch_proto15[]
|
|
Jan F. Chadima |
69dd72 |
{MONITOR_REQ_AUDIT_UNSUPPORTED, MON_PERMIT, mm_answer_audit_unsupported_body},
|
|
Jan F. Chadima |
69dd72 |
{MONITOR_REQ_AUDIT_KEX, MON_PERMIT, mm_answer_audit_kex_body},
|
|
Jan F. Chadima |
69dd72 |
{MONITOR_REQ_AUDIT_SESSION_KEY_FREE, MON_PERMIT, mm_answer_audit_session_key_free_body},
|
|
Jan F. Chadima |
69dd72 |
+ {MONITOR_REQ_AUDIT_SERVER_KEY_FREE, MON_PERMIT, mm_answer_audit_server_key_free},
|
|
Jan F. Chadima |
69dd72 |
#endif
|
|
Jan F. Chadima |
69dd72 |
{0, 0, NULL}
|
|
Jan F. Chadima |
69dd72 |
};
|
|
Petr Lautrbach |
65ba94 |
@@ -333,6 +339,7 @@ struct mon_table mon_dispatch_postauth15
|
|
Jan F. Chadima |
69dd72 |
{MONITOR_REQ_AUDIT_UNSUPPORTED, MON_PERMIT, mm_answer_audit_unsupported_body},
|
|
Jan F. Chadima |
69dd72 |
{MONITOR_REQ_AUDIT_KEX, MON_PERMIT, mm_answer_audit_kex_body},
|
|
Jan F. Chadima |
69dd72 |
{MONITOR_REQ_AUDIT_SESSION_KEY_FREE, MON_PERMIT, mm_answer_audit_session_key_free_body},
|
|
Jan F. Chadima |
69dd72 |
+ {MONITOR_REQ_AUDIT_SERVER_KEY_FREE, MON_PERMIT, mm_answer_audit_server_key_free},
|
|
Jan F. Chadima |
69dd72 |
#endif
|
|
Jan F. Chadima |
69dd72 |
{0, 0, NULL}
|
|
Jan F. Chadima |
69dd72 |
};
|
|
Petr Lautrbach |
65ba94 |
@@ -1744,6 +1751,8 @@ mm_answer_term(int sock, Buffer *req)
|
|
Jan F. Chadima |
69dd72 |
sshpam_cleanup();
|
|
Jan F. Chadima |
69dd72 |
#endif
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
+ destroy_sensitive_data(0);
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
while (waitpid(pmonitor->m_pid, &status, 0) == -1)
|
|
Jan F. Chadima |
69dd72 |
if (errno != EINTR)
|
|
Jan F. Chadima |
69dd72 |
exit(1);
|
|
Petr Lautrbach |
65ba94 |
@@ -2485,4 +2494,25 @@ mm_answer_audit_session_key_free_body(in
|
|
Jan F. Chadima |
69dd72 |
mm_request_send(sock, MONITOR_ANS_AUDIT_SESSION_KEY_FREE, m);
|
|
Jan F. Chadima |
69dd72 |
return 0;
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+int
|
|
Jan F. Chadima |
69dd72 |
+mm_answer_audit_server_key_free(int sock, Buffer *m)
|
|
Jan F. Chadima |
69dd72 |
+{
|
|
Jan F. Chadima |
69dd72 |
+ int len;
|
|
Jan F. Chadima |
69dd72 |
+ char *fp;
|
|
Jan F. Chadima |
69dd72 |
+ pid_t pid;
|
|
Jan F. Chadima |
69dd72 |
+ uid_t uid;
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ fp = buffer_get_string(m, &len;;
|
|
Jan F. Chadima |
69dd72 |
+ pid = buffer_get_int64(m);
|
|
Jan F. Chadima |
69dd72 |
+ uid = buffer_get_int64(m);
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ audit_destroy_sensitive_data(fp, pid, uid);
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
cff1d0 |
+ xfree(fp);
|
|
Jan F. Chadima |
69dd72 |
+ buffer_clear(m);
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ mm_request_send(sock, MONITOR_ANS_AUDIT_SERVER_KEY_FREE, m);
|
|
Jan F. Chadima |
69dd72 |
+ return 0;
|
|
Jan F. Chadima |
69dd72 |
+}
|
|
Jan F. Chadima |
69dd72 |
#endif /* SSH_AUDIT_EVENTS */
|
|
Petr Lautrbach |
65ba94 |
diff -up openssh-6.0p1/monitor.h.audit5 openssh-6.0p1/monitor.h
|
|
Petr Lautrbach |
65ba94 |
--- openssh-6.0p1/monitor.h.audit5 2012-08-06 20:37:50.040345200 +0200
|
|
Petr Lautrbach |
65ba94 |
+++ openssh-6.0p1/monitor.h 2012-08-06 20:37:50.050345161 +0200
|
|
Jan F. Chadima |
69dd72 |
@@ -64,6 +64,7 @@ enum monitor_reqtype {
|
|
Jan F. Chadima |
69dd72 |
MONITOR_REQ_AUDIT_UNSUPPORTED, MONITOR_ANS_AUDIT_UNSUPPORTED,
|
|
Jan F. Chadima |
69dd72 |
MONITOR_REQ_AUDIT_KEX, MONITOR_ANS_AUDIT_KEX,
|
|
Jan F. Chadima |
69dd72 |
MONITOR_REQ_AUDIT_SESSION_KEY_FREE, MONITOR_ANS_AUDIT_SESSION_KEY_FREE,
|
|
Jan F. Chadima |
69dd72 |
+ MONITOR_REQ_AUDIT_SERVER_KEY_FREE, MONITOR_ANS_AUDIT_SERVER_KEY_FREE,
|
|
Jan F. Chadima |
69dd72 |
MONITOR_REQ_TERM,
|
|
Jan F. Chadima |
69dd72 |
MONITOR_REQ_JPAKE_STEP1, MONITOR_ANS_JPAKE_STEP1,
|
|
Jan F. Chadima |
69dd72 |
MONITOR_REQ_JPAKE_GET_PWDATA, MONITOR_ANS_JPAKE_GET_PWDATA,
|
|
Petr Lautrbach |
65ba94 |
diff -up openssh-6.0p1/monitor_wrap.c.audit5 openssh-6.0p1/monitor_wrap.c
|
|
Petr Lautrbach |
65ba94 |
--- openssh-6.0p1/monitor_wrap.c.audit5 2012-08-06 20:37:50.041345196 +0200
|
|
Petr Lautrbach |
65ba94 |
+++ openssh-6.0p1/monitor_wrap.c 2012-08-06 20:37:50.050345161 +0200
|
|
Petr Lautrbach |
65ba94 |
@@ -1539,4 +1539,20 @@ mm_audit_session_key_free_body(int ctos,
|
|
Jan F. Chadima |
69dd72 |
&m);
|
|
Jan F. Chadima |
69dd72 |
buffer_free(&m);
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+void
|
|
Jan F. Chadima |
69dd72 |
+mm_audit_destroy_sensitive_data(const char *fp, pid_t pid, uid_t uid)
|
|
Jan F. Chadima |
69dd72 |
+{
|
|
Jan F. Chadima |
69dd72 |
+ Buffer m;
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ buffer_init(&m);
|
|
Jan F. Chadima |
69dd72 |
+ buffer_put_cstring(&m, fp);
|
|
Jan F. Chadima |
69dd72 |
+ buffer_put_int64(&m, pid);
|
|
Jan F. Chadima |
69dd72 |
+ buffer_put_int64(&m, uid);
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUDIT_SERVER_KEY_FREE, &m);
|
|
Jan F. Chadima |
69dd72 |
+ mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_AUDIT_SERVER_KEY_FREE,
|
|
Jan F. Chadima |
69dd72 |
+ &m);
|
|
Jan F. Chadima |
69dd72 |
+ buffer_free(&m);
|
|
Jan F. Chadima |
69dd72 |
+}
|
|
Jan F. Chadima |
69dd72 |
#endif /* SSH_AUDIT_EVENTS */
|
|
Petr Lautrbach |
65ba94 |
diff -up openssh-6.0p1/monitor_wrap.h.audit5 openssh-6.0p1/monitor_wrap.h
|
|
Petr Lautrbach |
65ba94 |
--- openssh-6.0p1/monitor_wrap.h.audit5 2012-08-06 20:37:50.041345196 +0200
|
|
Petr Lautrbach |
65ba94 |
+++ openssh-6.0p1/monitor_wrap.h 2012-08-06 20:37:50.051345157 +0200
|
|
Petr Lautrbach |
65ba94 |
@@ -80,6 +80,7 @@ void mm_audit_end_command(int, const cha
|
|
Jan F. Chadima |
69dd72 |
void mm_audit_unsupported_body(int);
|
|
Jan F. Chadima |
69dd72 |
void mm_audit_kex_body(int, char *, char *, char *, pid_t, uid_t);
|
|
Jan F. Chadima |
69dd72 |
void mm_audit_session_key_free_body(int, pid_t, uid_t);
|
|
Jan F. Chadima |
69dd72 |
+void mm_audit_destroy_sensitive_data(const char *, pid_t, uid_t);
|
|
Jan F. Chadima |
69dd72 |
#endif
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
struct Session;
|
|
Petr Lautrbach |
65ba94 |
diff -up openssh-6.0p1/session.c.audit5 openssh-6.0p1/session.c
|
|
Petr Lautrbach |
65ba94 |
--- openssh-6.0p1/session.c.audit5 2012-08-06 20:37:50.043345189 +0200
|
|
Petr Lautrbach |
65ba94 |
+++ openssh-6.0p1/session.c 2012-08-06 20:37:50.052345153 +0200
|
|
Jan F. Chadima |
69dd72 |
@@ -136,7 +136,7 @@ extern int log_stderr;
|
|
Jan F. Chadima |
69dd72 |
extern int debug_flag;
|
|
Jan F. Chadima |
69dd72 |
extern u_int utmp_len;
|
|
Jan F. Chadima |
69dd72 |
extern int startup_pipe;
|
|
Jan F. Chadima |
69dd72 |
-extern void destroy_sensitive_data(void);
|
|
Jan F. Chadima |
69dd72 |
+extern void destroy_sensitive_data(int);
|
|
Jan F. Chadima |
69dd72 |
extern Buffer loginmsg;
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
/* original command from peer. */
|
|
Jan F. Chadima |
69dd72 |
@@ -1633,7 +1633,7 @@ do_child(Session *s, const char *command
|
|
Jan F. Chadima |
69dd72 |
int r = 0;
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
/* remove hostkey from the child's memory */
|
|
Jan F. Chadima |
69dd72 |
- destroy_sensitive_data();
|
|
Jan F. Chadima |
69dd72 |
+ destroy_sensitive_data(1);
|
|
Jan F. Chadima |
69dd72 |
/* Don't audit this - both us and the parent would be talking to the
|
|
Jan F. Chadima |
69dd72 |
monitor over a single socket, with no synchronization. */
|
|
Jan F. Chadima |
69dd72 |
packet_destroy_all(0, 1);
|
|
Petr Lautrbach |
65ba94 |
diff -up openssh-6.0p1/sshd.c.audit5 openssh-6.0p1/sshd.c
|
|
Petr Lautrbach |
65ba94 |
--- openssh-6.0p1/sshd.c.audit5 2012-08-06 20:37:50.044345185 +0200
|
|
Petr Lautrbach |
65ba94 |
+++ openssh-6.0p1/sshd.c 2012-08-06 20:37:50.053345149 +0200
|
|
Petr Lautrbach |
65ba94 |
@@ -255,7 +255,7 @@ Buffer loginmsg;
|
|
Jan F. Chadima |
69dd72 |
struct passwd *privsep_pw = NULL;
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
/* Prototypes for various functions defined later in this file. */
|
|
Jan F. Chadima |
69dd72 |
-void destroy_sensitive_data(void);
|
|
Jan F. Chadima |
69dd72 |
+void destroy_sensitive_data(int);
|
|
Jan F. Chadima |
69dd72 |
void demote_sensitive_data(void);
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
static void do_ssh1_kex(void);
|
|
Petr Lautrbach |
65ba94 |
@@ -274,6 +274,15 @@ close_listen_socks(void)
|
|
Jan F. Chadima |
69dd72 |
num_listen_socks = -1;
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
+/*
|
|
Jan F. Chadima |
69dd72 |
+ * Is this process listening for clients (i.e. not specific to any specific
|
|
Jan F. Chadima |
69dd72 |
+ * client connection?)
|
|
Jan F. Chadima |
69dd72 |
+ */
|
|
Jan F. Chadima |
69dd72 |
+int listening_for_clients(void)
|
|
Jan F. Chadima |
69dd72 |
+{
|
|
Jan F. Chadima |
69dd72 |
+ return num_listen_socks > 0;
|
|
Jan F. Chadima |
69dd72 |
+}
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
static void
|
|
Jan F. Chadima |
69dd72 |
close_startup_pipes(void)
|
|
Jan F. Chadima |
69dd72 |
{
|
|
Petr Lautrbach |
65ba94 |
@@ -534,22 +543,47 @@ sshd_exchange_identification(int sock_in
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
-/* Destroy the host and server keys. They will no longer be needed. */
|
|
Jan F. Chadima |
69dd72 |
+/*
|
|
Jan F. Chadima |
69dd72 |
+ * Destroy the host and server keys. They will no longer be needed. Careful,
|
|
Jan F. Chadima |
69dd72 |
+ * this can be called from cleanup_exit() - i.e. from just about anywhere.
|
|
Jan F. Chadima |
69dd72 |
+ */
|
|
Jan F. Chadima |
69dd72 |
void
|
|
Jan F. Chadima |
69dd72 |
-destroy_sensitive_data(void)
|
|
Jan F. Chadima |
69dd72 |
+destroy_sensitive_data(int privsep)
|
|
Jan F. Chadima |
69dd72 |
{
|
|
Jan F. Chadima |
69dd72 |
int i;
|
|
Jan F. Chadima |
69dd72 |
+ pid_t pid;
|
|
Jan F. Chadima |
69dd72 |
+ uid_t uid;
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
if (sensitive_data.server_key) {
|
|
Jan F. Chadima |
69dd72 |
key_free(sensitive_data.server_key);
|
|
Jan F. Chadima |
69dd72 |
sensitive_data.server_key = NULL;
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
+ pid = getpid();
|
|
Jan F. Chadima |
69dd72 |
+ uid = getuid();
|
|
Jan F. Chadima |
69dd72 |
for (i = 0; i < options.num_host_key_files; i++) {
|
|
Jan F. Chadima |
69dd72 |
if (sensitive_data.host_keys[i]) {
|
|
Jan F. Chadima |
69dd72 |
+ char *fp;
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ if (key_is_private(sensitive_data.host_keys[i]))
|
|
Jan F. Chadima |
69dd72 |
+ fp = key_fingerprint(sensitive_data.host_keys[i],
|
|
Jan F. Chadima |
69dd72 |
+ FIPS_mode() ? SSH_FP_SHA1 : SSH_FP_MD5,
|
|
Jan F. Chadima |
69dd72 |
+ SSH_FP_HEX);
|
|
Jan F. Chadima |
69dd72 |
+ else
|
|
Jan F. Chadima |
69dd72 |
+ fp = NULL;
|
|
Jan F. Chadima |
69dd72 |
key_free(sensitive_data.host_keys[i]);
|
|
Jan F. Chadima |
69dd72 |
sensitive_data.host_keys[i] = NULL;
|
|
Jan F. Chadima |
69dd72 |
+ if (fp != NULL) {
|
|
Jan F. Chadima |
69dd72 |
+ if (privsep)
|
|
Jan F. Chadima |
69dd72 |
+ PRIVSEP(audit_destroy_sensitive_data(fp,
|
|
Jan F. Chadima |
69dd72 |
+ pid, uid));
|
|
Jan F. Chadima |
69dd72 |
+ else
|
|
Jan F. Chadima |
69dd72 |
+ audit_destroy_sensitive_data(fp,
|
|
Jan F. Chadima |
69dd72 |
+ pid, uid);
|
|
Jan F. Chadima |
69dd72 |
+ xfree(fp);
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
- if (sensitive_data.host_certificates[i]) {
|
|
Jan F. Chadima |
69dd72 |
+ if (sensitive_data.host_certificates
|
|
Jan F. Chadima |
69dd72 |
+ && sensitive_data.host_certificates[i]) {
|
|
Jan F. Chadima |
69dd72 |
key_free(sensitive_data.host_certificates[i]);
|
|
Jan F. Chadima |
69dd72 |
sensitive_data.host_certificates[i] = NULL;
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Petr Lautrbach |
65ba94 |
@@ -563,6 +597,8 @@ void
|
|
Jan F. Chadima |
69dd72 |
demote_sensitive_data(void)
|
|
Jan F. Chadima |
69dd72 |
{
|
|
Jan F. Chadima |
69dd72 |
Key *tmp;
|
|
Jan F. Chadima |
69dd72 |
+ pid_t pid;
|
|
Jan F. Chadima |
69dd72 |
+ uid_t uid;
|
|
Jan F. Chadima |
69dd72 |
int i;
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
if (sensitive_data.server_key) {
|
|
Petr Lautrbach |
65ba94 |
@@ -571,13 +607,27 @@ demote_sensitive_data(void)
|
|
Jan F. Chadima |
69dd72 |
sensitive_data.server_key = tmp;
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
+ pid = getpid();
|
|
Jan F. Chadima |
69dd72 |
+ uid = getuid();
|
|
Jan F. Chadima |
69dd72 |
for (i = 0; i < options.num_host_key_files; i++) {
|
|
Jan F. Chadima |
69dd72 |
if (sensitive_data.host_keys[i]) {
|
|
Jan F. Chadima |
69dd72 |
+ char *fp;
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ if (key_is_private(sensitive_data.host_keys[i]))
|
|
Jan F. Chadima |
69dd72 |
+ fp = key_fingerprint(sensitive_data.host_keys[i],
|
|
Jan F. Chadima |
69dd72 |
+ FIPS_mode() ? SSH_FP_SHA1 : SSH_FP_MD5,
|
|
Jan F. Chadima |
69dd72 |
+ SSH_FP_HEX);
|
|
Jan F. Chadima |
69dd72 |
+ else
|
|
Jan F. Chadima |
69dd72 |
+ fp = NULL;
|
|
Jan F. Chadima |
69dd72 |
tmp = key_demote(sensitive_data.host_keys[i]);
|
|
Jan F. Chadima |
69dd72 |
key_free(sensitive_data.host_keys[i]);
|
|
Jan F. Chadima |
69dd72 |
sensitive_data.host_keys[i] = tmp;
|
|
Jan F. Chadima |
69dd72 |
if (tmp->type == KEY_RSA1)
|
|
Jan F. Chadima |
69dd72 |
sensitive_data.ssh1_host_key = tmp;
|
|
Jan F. Chadima |
69dd72 |
+ if (fp != NULL) {
|
|
Jan F. Chadima |
69dd72 |
+ audit_destroy_sensitive_data(fp, pid, uid);
|
|
Jan F. Chadima |
69dd72 |
+ xfree(fp);
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
/* Certs do not need demotion */
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Petr Lautrbach |
65ba94 |
@@ -1149,6 +1199,7 @@ server_accept_loop(int *sock_in, int *so
|
|
Jan F. Chadima |
69dd72 |
if (received_sigterm) {
|
|
Jan F. Chadima |
69dd72 |
logit("Received signal %d; terminating.",
|
|
Jan F. Chadima |
69dd72 |
(int) received_sigterm);
|
|
Jan F. Chadima |
69dd72 |
+ destroy_sensitive_data(0);
|
|
Jan F. Chadima |
69dd72 |
close_listen_socks();
|
|
Jan F. Chadima |
69dd72 |
unlink(options.pid_file);
|
|
Jan F. Chadima |
69dd72 |
exit(received_sigterm == SIGTERM ? 0 : 255);
|
|
Petr Lautrbach |
65ba94 |
@@ -2054,7 +2105,7 @@ main(int ac, char **av)
|
|
Jan F. Chadima |
69dd72 |
privsep_postauth(authctxt);
|
|
Jan F. Chadima |
69dd72 |
/* the monitor process [priv] will not return */
|
|
Jan F. Chadima |
69dd72 |
if (!compat20)
|
|
Jan F. Chadima |
69dd72 |
- destroy_sensitive_data();
|
|
Jan F. Chadima |
69dd72 |
+ destroy_sensitive_data(0);
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
packet_set_timeout(options.client_alive_interval,
|
|
Petr Lautrbach |
65ba94 |
@@ -2065,6 +2116,7 @@ main(int ac, char **av)
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
/* The connection has been terminated. */
|
|
Jan F. Chadima |
69dd72 |
packet_destroy_all(1, 1);
|
|
Jan F. Chadima |
69dd72 |
+ destroy_sensitive_data(1);
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
packet_get_state(MODE_IN, NULL, NULL, NULL, &ibytes);
|
|
Jan F. Chadima |
69dd72 |
packet_get_state(MODE_OUT, NULL, NULL, NULL, &obytes);
|
|
Petr Lautrbach |
65ba94 |
@@ -2293,7 +2345,7 @@ do_ssh1_kex(void)
|
|
Jan F. Chadima |
69dd72 |
session_id[i] = session_key[i] ^ session_key[i + 16];
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
/* Destroy the private and public keys. No longer. */
|
|
Jan F. Chadima |
69dd72 |
- destroy_sensitive_data();
|
|
Jan F. Chadima |
69dd72 |
+ destroy_sensitive_data(0);
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
if (use_privsep)
|
|
Jan F. Chadima |
69dd72 |
mm_ssh1_session_id(session_id);
|
|
Petr Lautrbach |
65ba94 |
@@ -2404,6 +2456,8 @@ cleanup_exit(int i)
|
|
Petr Lautrbach |
65ba94 |
}
|
|
Petr Lautrbach |
65ba94 |
}
|
|
Jan F. Chadima |
39b26b |
is_privsep_child = use_privsep && pmonitor != NULL && !mm_is_monitor();
|
|
Jan F. Chadima |
69dd72 |
+ if (sensitive_data.host_keys != NULL)
|
|
Jan F. Chadima |
69dd72 |
+ destroy_sensitive_data(is_privsep_child);
|
|
Jan F. Chadima |
69dd72 |
packet_destroy_all(1, is_privsep_child);
|
|
Jan F. Chadima |
69dd72 |
#ifdef SSH_AUDIT_EVENTS
|
|
Jan F. Chadima |
69dd72 |
/* done after do_cleanup so it can cancel the PAM auth 'thread' */
|