File System Monitoring Queue Overflow
The Linux folder watcher registers paths with inotify but does not handle the queue-overflow event, and its read loop does not grow the buffer as intended. An attacker who can generate many file events in a watched folder could overflow the kernel queue, causing events to be dropped and the client to show and sync files incorrectly.
- Disclosed after 18 months
in the source code "owncloud/client" in the file "src/gui/folderwatcher_linux.cpp" in the function "void FolderWatcherPrivate :: inotifyRegisterPath (const QString & path)" by calling "inotify_add_watch" the file paths are set for monitoring
int wd = inotify_add_watch(_fd, path.toUtf8().constData(),
IN_CLOSE_WRITE | IN_ATTRIB | IN_MOVE | IN_CREATE | IN_DELETE | IN_DELETE_SELF | IN_MOVE_SELF | IN_UNMOUNT | IN_ONLYDIR);
But in the specified call, the flag "IN_Q_OVERFLOW" is omitted, which allows an attacker to influence the operation of the software. The essence of the impact is to form a large number of events overflowing the monitoring queue. In my opinion, the most effective and not noticeable will be creating a hidden file, writing data to it, closing and deleting.
It is worth noting that the function code "void FolderWatcherPrivate :: slotReceivedNotification (int fd)"
do {
len = read(fd, buffer.data(), buffer.size());
error = errno;
/**
* From inotify documentation:
*
* The behavior when the buffer given to read(2) is too
* small to return information about the next event
* depends on the kernel version: in kernels before 2.6.21,
* read(2) returns 0; since kernel 2.6.21, read(2) fails with
* the error EINVAL.
*/
if (len < 0 && error == EINVAL) {
// double the buffer size
buffer.resize(buffer.size() * 2);
/* and try again ... */
continue;
}
} while (false);
As my tests showed, it does not provide an increase in the buffer, which could offset the impact. The function reads part of the data from the queue, since the minimum buffer necessary for reading is much less than 2048.
Specifying a buffer of size
sizeof(struct inotify_event) + NAME_MAX + 1
will be sufficient to read at least one event.
Impact
Thus, the essence of the impact will consist in overflowing the monitoring queue. What will force the system to discard incoming events and the program will skip them. Skipping program monitoring events will lead to incorrect display of files and directories in the program, and will also affect the synchronization with the server.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the watcher neither subscribes to nor handles the inotify queue-overflow event, and its buffer-growth retry does not actually enlarge the buffer, so dropped events go unnoticed.
Impact
Overflowing the queue makes the system discard events, so the client may skip them, display files and directories incorrectly and sync incorrectly with the server; the report does not show a full exploit.
What the attacker needed
Local access to a watched folder; ability to create many file events
How it was found
- Create a hidden file inside a watched folder.
- Write data to the file and close it.
- Delete the file, repeating this to generate many events.
- Observe that the monitoring queue overflows and events are discarded.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
The desktop client watches folders for changes using a Linux kernel feature called inotify, which reports file events through a queue. If too many events arrive at once, the kernel drops them and sends a special overflow notice, but this code never looks for that notice. Someone able to create lots of file changes in a watched folder could therefore make the client miss changes, so its file list and server sync go wrong.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.