summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Rühsen <tim.ruehsen@gmx.de>2019-02-12 15:09:11 +0100
committerTim Rühsen <tim.ruehsen@gmx.de>2019-02-22 13:11:01 +0100
commitd39778e43d1674cb3ab3685157fd299816d535c0 (patch)
treee850b329e3b3b27f344aae980ad6159159ab8d93
parentb4abf441ae1686fd602971dd0c0493a3c7e15fd1 (diff)
downloadgnutls-d39778e43d1674cb3ab3685157fd299816d535c0.tar.gz
Automatically NULLify after gnutls_free()
This method prevents direct use-after-free and double-free issues. Signed-off-by: Tim Rühsen <tim.ruehsen@gmx.de>
-rw-r--r--NEWS13
-rw-r--r--lib/includes/gnutls/gnutls.h.in4
2 files changed, 17 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index b171ef71e8..a59c12091f 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,19 @@ See the end for copying conditions.
* Version 3.6.7 (unreleased)
+** libgnutls, gnutls tools: Every gnutls_free() will automatically set
+ the free'd pointer to NULL. This prevents possible use-after-free and
+ double free issues. Use-after-free will be turned into NULL dereference.
+ The counter-measure does not extend to applications using gnutls_free().
+
+** libgnutls, gnutls tools: Every gnutls_free() will automatically set
+ the free'd pointer to NULL. This prevents possible use-after-free and
+ double free issues. Use-after-free will be turned into NULL dereference,
+ effectively turning harmful attacks like remote-code-executions (RCE) into
+ segmentation faults. Double frees may also be used to achieve RCEs - turning
+ them into no-ops counter measures this attack at this point.
+ This measurement is only active when building libgnutls and the gnutls tools.
+
** libgnutls: enforce key usage limitations on certificates more actively.
Previously we would enforce it for TLS1.2 protocol, now we enforce it
even when TLS1.3 is negotiated, or on client certificates as well. When
diff --git a/lib/includes/gnutls/gnutls.h.in b/lib/includes/gnutls/gnutls.h.in
index 2965889664..eb808e40b4 100644
--- a/lib/includes/gnutls/gnutls.h.in
+++ b/lib/includes/gnutls/gnutls.h.in
@@ -2194,6 +2194,10 @@ extern _SYM_EXPORT gnutls_realloc_function gnutls_realloc;
extern _SYM_EXPORT gnutls_calloc_function gnutls_calloc;
extern _SYM_EXPORT gnutls_free_function gnutls_free;
+#ifdef GNUTLS_INTERNAL_BUILD
+#define gnutls_free(a) gnutls_free((void *) (a)), a=NULL
+#endif
+
extern _SYM_EXPORT char *(*gnutls_strdup) (const char *);
/* a variant of memset that doesn't get optimized out */