|
Jan F. Chadima |
b7b582 |
diff -up openssh-5.6p1/audit-bsm.c.audit2 openssh-5.6p1/audit-bsm.c
|
|
Jan F |
f8f722 |
--- openssh-5.6p1/audit-bsm.c.audit2 2010-11-02 21:04:27.000000000 +0100
|
|
Jan F |
f8f722 |
+++ openssh-5.6p1/audit-bsm.c 2010-11-02 21:04:28.000000000 +0100
|
|
Jan F. Chadima |
b7b582 |
@@ -316,6 +316,12 @@ audit_session_close(struct logininfo *li
|
|
Jan F. Chadima |
b7b582 |
/* not implemented */
|
|
Jan F. Chadima |
b7b582 |
}
|
|
Jan F. Chadima |
b7b582 |
|
|
Jan F. Chadima |
b7b582 |
+int
|
|
Jan F. Chadima |
b7b582 |
+audit_keyusage(const char *type, unsigned len, char *fp, int rv)
|
|
Jan F. Chadima |
b7b582 |
+{
|
|
Jan F. Chadima |
b7b582 |
+ /* not implemented */
|
|
Jan F. Chadima |
b7b582 |
+}
|
|
Jan F. Chadima |
b7b582 |
+
|
|
Jan F. Chadima |
b7b582 |
void
|
|
Jan F. Chadima |
b7b582 |
audit_event(ssh_audit_event_t event)
|
|
Jan F. Chadima |
b7b582 |
{
|
|
Jan F. Chadima |
b7b582 |
diff -up openssh-5.6p1/audit.c.audit2 openssh-5.6p1/audit.c
|
|
Jan F |
f8f722 |
--- openssh-5.6p1/audit.c.audit2 2010-11-02 21:04:27.000000000 +0100
|
|
Jan F |
f8f722 |
+++ openssh-5.6p1/audit.c 2010-11-02 21:04:28.000000000 +0100
|
|
Jan F. Chadima |
b7b582 |
@@ -182,5 +182,17 @@ audit_run_command(const char *command)
|
|
Jan F. Chadima |
b7b582 |
debug("audit run command euid %d user %s command '%.200s'", geteuid(),
|
|
Jan F. Chadima |
b7b582 |
audit_username(), command);
|
|
Jan F. Chadima |
b7b582 |
}
|
|
Jan F. Chadima |
b7b582 |
+
|
|
Jan F. Chadima |
b7b582 |
+/*
|
|
Jan F. Chadima |
b7b582 |
+ * This will be called when user is successfully autherized by the RSA1/RSA/DSA key.
|
|
Jan F. Chadima |
b7b582 |
+ *
|
|
Jan F. Chadima |
b7b582 |
+ * Type is the key type, len is the key length(byte) and fp is the fingerprint of the key.
|
|
Jan F. Chadima |
b7b582 |
+ */
|
|
Jan F. Chadima |
b7b582 |
+int
|
|
Jan F. Chadima |
b7b582 |
+audit_keyusage(const char *type, unsigned len, char *fp, int rv)
|
|
Jan F. Chadima |
b7b582 |
+{
|
|
Jan F. Chadima |
b7b582 |
+ debug("audit key usage euid %d user %s key type %s key length %d fingerprint %s, result %d", geteuid(),
|
|
Jan F. Chadima |
b7b582 |
+ audit_username(), type, len, fp, rv);
|
|
Jan F. Chadima |
b7b582 |
+}
|
|
Jan F. Chadima |
b7b582 |
# endif /* !defined CUSTOM_SSH_AUDIT_EVENTS */
|
|
Jan F. Chadima |
b7b582 |
#endif /* SSH_AUDIT_EVENTS */
|
|
Jan F. Chadima |
b7b582 |
diff -up openssh-5.6p1/audit.h.audit2 openssh-5.6p1/audit.h
|
|
Jan F |
f8f722 |
--- openssh-5.6p1/audit.h.audit2 2010-11-02 21:04:27.000000000 +0100
|
|
Jan F |
f8f722 |
+++ openssh-5.6p1/audit.h 2010-11-02 21:04:28.000000000 +0100
|
|
Jan F. Chadima |
b7b582 |
@@ -53,5 +53,6 @@ void audit_session_open(struct logininfo
|
|
Jan F. Chadima |
b7b582 |
void audit_session_close(struct logininfo *);
|
|
Jan F. Chadima |
b7b582 |
void audit_run_command(const char *);
|
|
Jan F. Chadima |
b7b582 |
ssh_audit_event_t audit_classify_auth(const char *);
|
|
Jan F. Chadima |
b7b582 |
+int audit_keyusage(const char *, unsigned, char *, int);
|
|
Jan F. Chadima |
b7b582 |
|
|
Jan F. Chadima |
b7b582 |
#endif /* _SSH_AUDIT_H */
|
|
Jan F. Chadima |
b7b582 |
diff -up openssh-5.6p1/audit-linux.c.audit2 openssh-5.6p1/audit-linux.c
|
|
Jan F |
f8f722 |
--- openssh-5.6p1/audit-linux.c.audit2 2010-11-02 21:04:27.000000000 +0100
|
|
Jan F |
f8f722 |
+++ openssh-5.6p1/audit-linux.c 2010-11-02 21:04:28.000000000 +0100
|
|
Jan F. Chadima |
b7b582 |
@@ -37,6 +37,8 @@
|
|
Jan F. Chadima |
b7b582 |
#include "audit.h"
|
|
Jan F. Chadima |
b7b582 |
#include "canohost.h"
|
|
Jan F. Chadima |
b7b582 |
|
|
Jan F. Chadima |
b7b582 |
+#define AUDIT_LOG_SIZE 128
|
|
Jan F. Chadima |
b7b582 |
+
|
|
Jan F. Chadima |
b7b582 |
const char* audit_username(void);
|
|
Jan F. Chadima |
b7b582 |
|
|
Jan F. Chadima |
b7b582 |
int
|
|
Jan F. Chadima |
b7b582 |
@@ -62,6 +64,36 @@ linux_audit_record_event(int uid, const
|
|
Jan F. Chadima |
b7b582 |
return (rc >= 0);
|
|
Jan F. Chadima |
b7b582 |
}
|
|
Jan F. Chadima |
b7b582 |
|
|
Jan F. Chadima |
b7b582 |
+int
|
|
Jan F. Chadima |
b7b582 |
+audit_keyusage(const char *type, unsigned len, char *fp, int rv)
|
|
Jan F. Chadima |
b7b582 |
+{
|
|
Jan F. Chadima |
b7b582 |
+ char buf[AUDIT_LOG_SIZE];
|
|
Jan F. Chadima |
b7b582 |
+ int audit_fd, rc, saved_errno;
|
|
Jan F. Chadima |
b7b582 |
+
|
|
Jan F. Chadima |
b7b582 |
+ audit_fd = audit_open();
|
|
Jan F. Chadima |
b7b582 |
+ if (audit_fd < 0) {
|
|
Jan F. Chadima |
b7b582 |
+ if (errno == EINVAL || errno == EPROTONOSUPPORT ||
|
|
Jan F. Chadima |
b7b582 |
+ errno == EAFNOSUPPORT)
|
|
Jan F. Chadima |
b7b582 |
+ return 1; /* No audit support in kernel */
|
|
Jan F. Chadima |
b7b582 |
+ else
|
|
Jan F. Chadima |
b7b582 |
+ return 0; /* Must prevent login */
|
|
Jan F. Chadima |
b7b582 |
+ }
|
|
Jan F. Chadima |
b7b582 |
+ snprintf(buf, sizeof(buf), "pubkey_auth rport=%d", get_remote_port());
|
|
Jan F. Chadima |
b7b582 |
+ rc = audit_log_acct_message(audit_fd, AUDIT_USER_AUTH, NULL,
|
|
Jan F. Chadima |
b7b582 |
+ buf, audit_username(), -1, NULL, get_remote_ipaddr(), NULL, rv);
|
|
Jan F. Chadima |
b7b582 |
+ if (rc < 0)
|
|
Jan F. Chadima |
b7b582 |
+ goto out;
|
|
Jan F. Chadima |
b7b582 |
+ snprintf(buf, sizeof(buf), "pubkey_auth algo=%s size=%d fp=%s rport=%d",
|
|
Jan F. Chadima |
b7b582 |
+ type, 8 * len, fp, get_remote_port());
|
|
Jan F. Chadima |
b7b582 |
+ rc = audit_log_acct_message(audit_fd, AUDIT_USER_AUTH, NULL,
|
|
Jan F. Chadima |
b7b582 |
+ buf, audit_username(), -1, NULL, get_remote_ipaddr(), NULL, rv);
|
|
Jan F. Chadima |
b7b582 |
+out:
|
|
Jan F. Chadima |
b7b582 |
+ saved_errno = errno;
|
|
Jan F. Chadima |
b7b582 |
+ audit_close(audit_fd);
|
|
Jan F. Chadima |
b7b582 |
+ errno = saved_errno;
|
|
Jan F. Chadima |
b7b582 |
+ return (rc >= 0);
|
|
Jan F. Chadima |
b7b582 |
+}
|
|
Jan F. Chadima |
b7b582 |
+
|
|
Jan F. Chadima |
b7b582 |
/* Below is the sshd audit API code */
|
|
Jan F. Chadima |
b7b582 |
|
|
Jan F. Chadima |
b7b582 |
void
|
|
Jan F. Chadima |
b7b582 |
diff -up openssh-5.6p1/auth2-pubkey.c.audit2 openssh-5.6p1/auth2-pubkey.c
|
|
Jan F. Chadima |
b7b582 |
--- openssh-5.6p1/auth2-pubkey.c.audit2 2010-07-02 05:35:19.000000000 +0200
|
|
Jan F |
f8f722 |
+++ openssh-5.6p1/auth2-pubkey.c 2010-11-02 21:04:28.000000000 +0100
|
|
Jan F. Chadima |
b7b582 |
@@ -177,6 +177,40 @@ done:
|
|
Jan F. Chadima |
b7b582 |
return authenticated;
|
|
Jan F. Chadima |
b7b582 |
}
|
|
Jan F. Chadima |
b7b582 |
|
|
Jan F. Chadima |
b7b582 |
+int
|
|
Jan F. Chadima |
b7b582 |
+pubkey_key_verify(const Key *key, const u_char *sig, u_int slen, const u_char *data, u_int datalen)
|
|
Jan F. Chadima |
b7b582 |
+{
|
|
Jan F. Chadima |
b7b582 |
+ int rv;
|
|
Jan F. Chadima |
b7b582 |
+#ifdef SSH_AUDIT_EVENTS
|
|
Jan F. Chadima |
b7b582 |
+ char *fp;
|
|
Jan F. Chadima |
b7b582 |
+ unsigned size = 0;
|
|
Jan F. Chadima |
b7b582 |
+ const char *crypto_name[] = {
|
|
Jan F. Chadima |
b7b582 |
+ "ssh-rsa1",
|
|
Jan F. Chadima |
b7b582 |
+ "ssh-rsa",
|
|
Jan F. Chadima |
b7b582 |
+ "ssh-dsa",
|
|
Jan F. Chadima |
b7b582 |
+ "unknown" };
|
|
Jan F. Chadima |
b7b582 |
+#endif
|
|
Jan F. Chadima |
b7b582 |
+
|
|
Jan F. Chadima |
b7b582 |
+ rv = key_verify(key, sig, slen, data, datalen);
|
|
Jan F. Chadima |
b7b582 |
+#ifdef SSH_AUDIT_EVENTS
|
|
Jan F. Chadima |
b7b582 |
+ fp = key_fingerprint(key, SSH_FP_MD5, SSH_FP_HEX);
|
|
Jan F. Chadima |
b7b582 |
+ switch(key->type) {
|
|
Jan F. Chadima |
b7b582 |
+ case KEY_RSA1:
|
|
Jan F. Chadima |
b7b582 |
+ case KEY_RSA:
|
|
Jan F. Chadima |
b7b582 |
+ size = RSA_size(key->rsa);
|
|
Jan F. Chadima |
b7b582 |
+ break;
|
|
Jan F. Chadima |
b7b582 |
+ case KEY_DSA:
|
|
Jan F. Chadima |
b7b582 |
+ size = DSA_size(key->dsa);
|
|
Jan F. Chadima |
b7b582 |
+ break;
|
|
Jan F. Chadima |
b7b582 |
+ }
|
|
Jan F. Chadima |
b7b582 |
+
|
|
Jan F. Chadima |
b7b582 |
+ if (audit_keyusage(crypto_name[key->type], size, fp, rv) == 0)
|
|
Jan F. Chadima |
b7b582 |
+ rv = 0;
|
|
Jan F. Chadima |
b7b582 |
+ xfree(fp);
|
|
Jan F. Chadima |
b7b582 |
+#endif
|
|
Jan F. Chadima |
b7b582 |
+ return rv;
|
|
Jan F. Chadima |
b7b582 |
+}
|
|
Jan F. Chadima |
b7b582 |
+
|
|
Jan F. Chadima |
b7b582 |
static int
|
|
Jan F. Chadima |
b7b582 |
match_principals_option(const char *principal_list, struct KeyCert *cert)
|
|
Jan F. Chadima |
b7b582 |
{
|
|
Jan F |
f8f722 |
diff -up openssh-5.6p1/auth.h.audit2 openssh-5.6p1/auth.h
|
|
Jan F |
f8f722 |
--- openssh-5.6p1/auth.h.audit2 2010-11-02 21:06:05.000000000 +0100
|
|
Jan F |
f8f722 |
+++ openssh-5.6p1/auth.h 2010-11-02 21:07:32.000000000 +0100
|
|
Jan F |
f8f722 |
@@ -170,6 +170,7 @@ void abandon_challenge_response(Authctxt
|
|
Jan F |
f8f722 |
char *authorized_keys_file(struct passwd *);
|
|
Jan F |
f8f722 |
char *authorized_keys_file2(struct passwd *);
|
|
Jan F |
f8f722 |
char *authorized_principals_file(struct passwd *);
|
|
Jan F |
f8f722 |
+int pubkey_key_verify(const Key *, const u_char *, u_int, const u_char *, u_int);
|
|
Jan F |
f8f722 |
|
|
Jan F |
f8f722 |
FILE *auth_openkeyfile(const char *, struct passwd *, int);
|
|
Jan F |
f8f722 |
FILE *auth_openprincipals(const char *, struct passwd *, int);
|
|
Jan F. Chadima |
b7b582 |
diff -up openssh-5.6p1/auth-rsa.c.audit2 openssh-5.6p1/auth-rsa.c
|
|
Jan F. Chadima |
b7b582 |
--- openssh-5.6p1/auth-rsa.c.audit2 2010-07-16 05:58:37.000000000 +0200
|
|
Jan F |
f8f722 |
+++ openssh-5.6p1/auth-rsa.c 2010-11-02 21:04:28.000000000 +0100
|
|
Jan F. Chadima |
b7b582 |
@@ -92,7 +92,10 @@ auth_rsa_verify_response(Key *key, BIGNU
|
|
Jan F. Chadima |
b7b582 |
{
|
|
Jan F. Chadima |
b7b582 |
u_char buf[32], mdbuf[16];
|
|
Jan F. Chadima |
b7b582 |
MD5_CTX md;
|
|
Jan F. Chadima |
b7b582 |
- int len;
|
|
Jan F. Chadima |
b7b582 |
+ int len, rv;
|
|
Jan F. Chadima |
b7b582 |
+#ifdef SSH_AUDIT_EVENTS
|
|
Jan F. Chadima |
b7b582 |
+ char *fp;
|
|
Jan F. Chadima |
b7b582 |
+#endif
|
|
Jan F. Chadima |
b7b582 |
|
|
Jan F. Chadima |
b7b582 |
if (auth_key_is_revoked(key))
|
|
Jan F. Chadima |
b7b582 |
return 0;
|
|
Jan F. Chadima |
b7b582 |
@@ -116,12 +119,18 @@ auth_rsa_verify_response(Key *key, BIGNU
|
|
Jan F. Chadima |
b7b582 |
MD5_Final(mdbuf, &md);
|
|
Jan F. Chadima |
b7b582 |
|
|
Jan F. Chadima |
b7b582 |
/* Verify that the response is the original challenge. */
|
|
Jan F. Chadima |
b7b582 |
- if (timingsafe_bcmp(response, mdbuf, 16) != 0) {
|
|
Jan F. Chadima |
b7b582 |
- /* Wrong answer. */
|
|
Jan F. Chadima |
b7b582 |
- return (0);
|
|
Jan F. Chadima |
b7b582 |
+ rv = timingsafe_bcmp(response, mdbuf, 16) == 0;
|
|
Jan F. Chadima |
b7b582 |
+
|
|
Jan F. Chadima |
b7b582 |
+#ifdef SSH_AUDIT_EVENTS
|
|
Jan F. Chadima |
b7b582 |
+ fp = key_fingerprint(key, SSH_FP_MD5, SSH_FP_HEX);
|
|
Jan F. Chadima |
b7b582 |
+ if (audit_keyusage("ssh-rsa1", RSA_size(key->rsa), fp, rv) == 0) {
|
|
Jan F. Chadima |
b7b582 |
+ debug("unsuccessful audit");
|
|
Jan F. Chadima |
b7b582 |
+ rv = 0;
|
|
Jan F. Chadima |
b7b582 |
}
|
|
Jan F. Chadima |
b7b582 |
- /* Correct answer. */
|
|
Jan F. Chadima |
b7b582 |
- return (1);
|
|
Jan F. Chadima |
b7b582 |
+ xfree(fp);
|
|
Jan F. Chadima |
b7b582 |
+#endif
|
|
Jan F. Chadima |
b7b582 |
+
|
|
Jan F. Chadima |
b7b582 |
+ return rv;
|
|
Jan F. Chadima |
b7b582 |
}
|
|
Jan F. Chadima |
b7b582 |
|
|
Jan F. Chadima |
b7b582 |
/*
|
|
Jan F. Chadima |
b7b582 |
diff -up openssh-5.6p1/monitor.c.audit2 openssh-5.6p1/monitor.c
|
|
Jan F. Chadima |
b7b582 |
--- openssh-5.6p1/monitor.c.audit2 2010-08-03 07:50:16.000000000 +0200
|
|
Jan F |
f8f722 |
+++ openssh-5.6p1/monitor.c 2010-11-02 21:04:28.000000000 +0100
|
|
Jan F. Chadima |
b7b582 |
@@ -1235,7 +1235,19 @@ mm_answer_keyverify(int sock, Buffer *m)
|
|
Jan F. Chadima |
b7b582 |
if (!valid_data)
|
|
Jan F. Chadima |
b7b582 |
fatal("%s: bad signature data blob", __func__);
|
|
Jan F. Chadima |
b7b582 |
|
|
Jan F. Chadima |
b7b582 |
- verified = key_verify(key, signature, signaturelen, data, datalen);
|
|
Jan F. Chadima |
b7b582 |
+ switch (key_blobtype) {
|
|
Jan F. Chadima |
b7b582 |
+ case MM_USERKEY:
|
|
Jan F. Chadima |
b7b582 |
+ verified = pubkey_key_verify(key, signature, signaturelen, data, datalen);
|
|
Jan F. Chadima |
b7b582 |
+ break;
|
|
Jan F. Chadima |
b7b582 |
+ case MM_HOSTKEY:
|
|
Jan F. Chadima |
b7b582 |
+ verified = key_verify(key, signature, signaturelen, data, datalen);
|
|
Jan F. Chadima |
b7b582 |
+ valid_data = monitor_valid_hostbasedblob(data, datalen,
|
|
Jan F. Chadima |
b7b582 |
+ hostbased_cuser, hostbased_chost);
|
|
Jan F. Chadima |
b7b582 |
+ break;
|
|
Jan F. Chadima |
b7b582 |
+ default:
|
|
Jan F. Chadima |
b7b582 |
+ verified = 0;
|
|
Jan F. Chadima |
b7b582 |
+ break;
|
|
Jan F. Chadima |
b7b582 |
+ }
|
|
Jan F. Chadima |
b7b582 |
debug3("%s: key %p signature %s",
|
|
Jan F. Chadima |
b7b582 |
__func__, key, (verified == 1) ? "verified" : "unverified");
|
|
Jan F. Chadima |
b7b582 |
|