Skip to content
Tech News
← Back to articles

New GhostLock tool abuses Windows API to block file access

read original get Windows API Security Tool → more articles
Why This Matters

The GhostLock tool highlights a new method for malicious actors to intentionally block access to files on Windows systems using legitimate APIs, potentially disrupting workflows or causing denial-of-service scenarios. Its ease of use without elevated privileges and automation capabilities make it a concerning threat for both enterprise and consumer environments. This underscores the importance of monitoring file sharing behaviors and implementing safeguards against API abuse in Windows networks.

Key Takeaways

A security researcher has released a proof-of-concept tool named GhostLock that demonstrates how a legitimate Windows file API can be abused in attacks to block access to files stored locally or on SMB network shares.

This technique, created by Kim Dvash of Israel Aerospace Industries, abuses the Windows 'CreateFileW' API and file-sharing modes to prevent other users and applications from opening files while handles remain active.

The GhostLock technique abuses the 'dwShareMode' parameter in the CreateFileW() function, which specifies the type of access other processes have to a file while it is opened.

When a file is opened with ' dwShareMode = 0 `, Windows grants the process exclusive access to the file, preventing other users or applications from opening it.

For example, the following code will open the finance.xlsx file in exclusive mode, preventing any other process from accessing it.

HANDLE hFile = CreateFileW( L"\\\\server\\share\\finance.xlsx", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );

When attempting to do so, Windows will display the following 'STATUS_SHARING_VIOLATION' error instead.

Windows file sharing error

Source: Kim Dvash

The researcher has published a GhostLock tool on GitHub that automates this attack by recursively opening a large number of files on SMB shares. While these file handles are open, new attempts to access the files will fail with sharing violations.

... continue reading