CVE-2019-15879 - Missing Release of Resource after Effective Lifetime

Severity

74%

Complexity

22%

Confidentiality

86%

In FreeBSD 12.1-STABLE before r356908, 12.1-RELEASE before p5, 11.3-STABLE before r356908, and 11.3-RELEASE before p9, a race condition in the cryptodev module permitted a data structure in the kernel to be used after it was freed, allowing an unprivileged process can overwrite arbitrary kernel memory.

CVSS 3.1 Base Score 7.4. CVSS Attack Vector: network. CVSS Attack Complexity: high. CVSS Vector: (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:H).

CVSS 2.0 Base Score 5.8. CVSS Attack Vector: network. CVSS Attack Complexity: medium. CVSS Vector: (AV:N/AC:M/Au:N/C:N/I:P/A:P).

Demo Examples

Missing Release of Resource after Effective Lifetime

CWE-772

The following code attempts to process a file by reading it in line by line until the end has been reached.


               
}
}
processLine(line);

The problem with the above code is that it never closes the file handle it opens. The Finalize() method for BufferReader eventually calls Close(), but there is no guarantee as to how long it will take before the Finalize() method is invoked. In fact, there is no guarantee that Finalize() will ever be invoked. In a busy environment, this can result in the VM using up all of its available file handles.

Missing Release of Resource after Effective Lifetime

CWE-772

The following code attempts to open a new connection to a database, process the results returned by the database, and close the allocated SqlConnection object.


               
conn.Connection.Close();

The problem with the above code is that if an exception occurs while executing the SQL or processing the results, the SqlConnection object is not closed. If this happens often enough, the database will run out of available cursors and not be able to execute any more SQL queries.

Missing Release of Resource after Effective Lifetime

CWE-772

The following method never closes the file handle it opens. The Finalize() method for StreamReader eventually calls Close(), but there is no guarantee as to how long it will take before the Finalize() method is invoked. In fact, there is no guarantee that Finalize() will ever be invoked. In a busy environment, this can result in the VM using up all of its available file handles.


               
}
}
processLine(line);

Missing Release of Resource after Effective Lifetime

CWE-772

This code attempts to open a connection to a database and catches any exceptions that may occur.


               
}
Connection con = DriverManager.getConnection(some_connection_string);
log( e );

If an exception occurs after establishing the database connection and before the same connection closes, the pool of database connections may become exhausted. If the number of available connections is exceeded, other users cannot access this resource, effectively denying access to the application.

Missing Release of Resource after Effective Lifetime

CWE-772

Under normal conditions the following C# code executes a database query, processes the results returned by the database, and closes the allocated SqlConnection object. But if an exception occurs while executing the SQL or processing the results, the SqlConnection object is not closed. If this happens often enough, the database will run out of available cursors and not be able to execute any more SQL queries.


               
...

Missing Release of Resource after Effective Lifetime

CWE-772

The following C function does not close the file handle it opens if an error occurs. If the process is long-lived, the process can run out of file handles.


               
}
return DECODE_SUCCESS;
return DECODE_FAIL;
}
}
return DECODE_FAIL;
decodeBlock(buf);

Demo Examples

Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')

CWE-362

This code could be used in an e-commerce application that supports transfers between accounts. It takes the total amount of the transfer, sends it to the new account, and deducts the amount from the original account.


               
NotifyUser("New balance: $newbalance");
FatalError("Bad Transfer Amount");
FatalError("Insufficient Funds");

A race condition could occur between the calls to GetBalanceFromDatabase() and SendNewBalanceToDatabase().

Suppose the balance is initially 100.00. An attack could be constructed as follows:


               
PROGRAM-2 sends a request to update the database, setting the balance to 99.00

At this stage, the attacker should have a balance of 19.00 (due to 81.00 worth of transfers), but the balance is 99.00, as recorded in the database.

To prevent this weakness, the programmer has several options, including using a lock to prevent multiple simultaneous requests to the web application, or using a synchronization mechanism that includes all the code between GetBalanceFromDatabase() and SendNewBalanceToDatabase().

Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')

CWE-362

The following function attempts to acquire a lock in order to perform operations on a shared resource.


               
}
pthread_mutex_unlock(mutex);/* access shared resource */

However, the code does not check the value returned by pthread_mutex_lock() for errors. If pthread_mutex_lock() cannot acquire the mutex for any reason, the function may introduce a race condition into the program and result in undefined behavior.

In order to avoid data races, correctly written programs must check the result of thread synchronization functions and appropriately handle all errors, either by attempting to recover from them or reporting it to higher levels.


               
}
return pthread_mutex_unlock(mutex);
return result;
/* access shared resource */

Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')

CWE-362

Suppose a processor's Memory Management Unit (MMU) has 5 other shadow MMUs to distribute its workload for its various cores. Each MMU has the start address and end address of "accessible" memory. Any time this accessible range changes (as per the processor's boot status), the main MMU sends an update message to all the shadow MMUs.

Suppose the interconnect fabric does not prioritize such "update" packets over other general traffic packets. This introduces a race condition. If an attacker can flood the target with enough messages so that some of those attack packets reach the target before the new access ranges gets updated, then the attacker can leverage this scenario.

Overview

Type

FreeBSD

First reported 4 years ago

2020-05-13 16:15:00

Last updated 4 years ago

2020-05-18 05:15:00

Affected Software

FreeBSD FreeBSD 11.3

11.3

FreeBSD 11.3 Patch 1

11.3

FreeBSD 11.3 Patch 2

11.3

FreeBSD 11.3 Patch 3

11.3

FreeBSD FreeBSD 11.3 Patch 4

11.3

FreeBSD FreeBSD 11.3 Patch 5

11.3

FreeBSD 11.3 Patch 6

11.3

FreeBSD 11.3 Patch 7

11.3

FreeBSD 11.3 Patch 8

11.3

FreeBSD FreeBSD 12.1

12.1

FreeBSD FreeBSD 12.1 Patch 1

12.1

FreeBSD 12.1 Patch 2

12.1

FreeBSD 12.1 Patch 3

12.1

FreeBSD 12.1 Patch 4

12.1

Stay updated

ExploitPedia is constantly evolving. Sign up to receive a notification when we release additional functionality.

Get in touch

If you'd like to report a bug or have any suggestions for improvements then please do get in touch with us using this form. We will get back to you as soon as we can.