diff --git src/wp-includes/post.php src/wp-includes/post.php
index 1796dde..ee66869 100644
--- src/wp-includes/post.php
+++ src/wp-includes/post.php
@@ -3214,6 +3214,23 @@ function wp_insert_post( $postarr, $wp_error = false ) {
 
 	$postarr = wp_parse_args( $postarr, $defaults );
 
+	// The data is innocent until proven guilty.
+	$is_valid = true;
+
+	/**
+	 * Hooks in before insert post is properly run.
+	 *
+	 * @since 4.9
+	 *
+	 * @param bool $is_valid An indicator of whether the post data is valid.
+	 * @param array $postarr An array of raw post data.
+	*/
+	$is_valid = apply_filters( 'pre_insert_post', $is_valid, $postarr );
+
+	if ( ! $is_valid ) {
+		return new WP_Error( 'invalid_data', __( "The data supplied isn't valid." ) );
+	}
+
 	unset( $postarr['filter'] );
 
 	$postarr = sanitize_post( $postarr, 'db' );
