Closed
Description
The KPL binary is vulnerable to a race condition that yields a zero-byte binary file being installed. The sequence is:
- Process-1 determines that the binary does not exist and creates a new
FileOutputStream
, which will create a file-descriptor on the filesystem (link) - Process-2 determines that the file exists and creates a
FileInputStream
and shared lock: (link) - Process-1 attempts to create an exclusive lock but cannot because Process-2 has a shared-lock that prevents the creation of exclusive locks: (link)
- Process-2 verifies the contents of the binary and throws a
SecurityException
because the contents do not match the expected value: (link)
This can be avoided by using a dedicated lock-file separate from the binary file being written.
This issue is related to #55