DEV Community

Cover image for Implementing Zero Trust File Security in C# or C++
EaseFilterSDK
EaseFilterSDK

Posted on Edited on Originally published at github.com

Implementing Zero Trust File Security in C# or C++

🛡️ zero-trust-file-security

zero-trust-file-security implements a robust zero-trust architecture for file system access. By defaulting to a strict "deny-all" policy, this framework protects sensitive directories from unauthorized viewing, modification, or ransomware attacks, requiring explicit authorization for every read, write, and execute request.

Powered by the EaseFilter File Security SDK, this project gives you kernel-level, high-performance file interception and access control.

🏗️ Architecture

The following diagram illustrates how policy rules in user mode are enforced down at the Windows Kernel level, intercepting all I/O requests before they reach the file system:

Zero-Trust Architecture

🖥️ Demo Interface

Below is an example of the zero-trust filter service dashboard, showcasing how to dynamically handle and display file-access rule exceptions for processes and users:

Zero-Trust Demo UI

✨ Core Features

  • Default Deny (Zero-Trust): All users, applications, and network requests are blacklisted by default.
  • Process-Level Whitelisting: Explicitly authorize trusted applications (e.g., notepad.exe, your-app.exe) to access specific files.
  • Granular Access Rights: Define exact permissions (Read, Write, Delete, Rename, Execute) on a per-user or per-process basis.
  • Ransomware & Malware Prevention: Untrusted processes cannot encrypt, delete, or exfiltrate protected files out of the box.
  • Real-Time Auditing: Comprehensive logging of all allowed and denied file I/O operations for compliance and security monitoring.

📄 Implement Zero trust file access control with EaseFilter

EaseFilter File Control Filter Driver allows you to control the file I/O operations with the filter rule configuration by setting the whitelist and blacklist processes or users, you can allow or block the specific file I/O operation to the specific process or user, you can control who can read your file, allow or block the file modification, prevent your important file from being deleted, renamed.

To implement the Zero Trust file access control , you can setup the filter rule with the default least privilege access rights, by default all the processes or users don’t have privilege to access the files inside this filter rule, it is zero trust to all processes and users. You can setup the whitelist for the filter rule, to add the specific access rights to specific processes or users, so the processes or users who are in the whitelist can have the specific access rights to the files.

EaseFilter Encryption Filter Driver(EEFD) allows you to encrypt file automatically and transparently, combine with the File Control Filter Driver and Process Filter Driver, you can implement the Zero Trust File Access Control with encryption enabled, it can enhance the file security. By default all files will be encrypted automatically, all processes or users can't read the encrypted files, they will get the raw encrypted data. You can authorize the processes or users to access these encrypted files.

⚙️ Installation

  1. Clone this repository to your local machine:
   git clone https://github.com/EaseFilterSDK/Zero-Trust-File-Security.git
Enter fullscreen mode Exit fullscreen mode
  1. Open the solution in Visual Studio.
  2. Ensure the EaseFilter.FilterControl.dll is properly referenced in your project.
  3. Build the solution. Note: You will need to run the application with Administrator privileges to load the filter driver.

🚀 Getting Started

The core concept of this project is to deny all access by default and explicitly grant permissions to trusted processes.

The following example demonstrates how to protect a directory (C:\SecureData\) so that absolutely no user or program can read or modify the files—except for MySecureApp.exe.

Example: Whitelisting a Specific Process

using System;
using EaseFilter.FilterControl;

class Program
{
    static void Main(string[] args)
    {
        // 1. Initialize the Filter Control
        FilterControl filterControl = new FilterControl();

        // 2. Define the protected directory
        string protectedPath = @"C:\SecureData\*";
        FileFilter rule = new FileFilter(protectedPath);

        // 3. ZERO TRUST: Deny all file access by default
        // This blocks read, write, delete, and execution for everyone
        rule.AccessFlag = FilterAPI.ALLOW_MAX_RIGHT_ACCESS 
                        & ~FilterAPI.ALLOW_FILE_READ;
                        & ~FilterAPI.ALLOW_FILE_WRITE;
                        & ~FilterAPI.ALLOW_FILE_DELETE;                     

        // 4. WHITELIST: Grant full access ONLY to 'MySecureApp.exe'
        // EXPLICIT AUTHORIZATION WITH CRYPTOGRAPHIC VERIFICATION
        // Trust based on Digital Certificate (Best for commercial software)
        // If a rogue MySecureApp.exe tries to access the files but isn't signed 
        // by the real 'EaseFilter Technologies', it will be blocked instantly.
        rule.AddTrustedProcessRight(
            (uint)FilterAPI.ALLOW_MAX_ACCESS_RIGHT, 
            "MySecureApp.exe", 
            "EaseFilter Technologies", // Certificate Subject Name
            ""                       // Hash (omitted)
        );

        // 5. Add the rule and start the engine
        filterControl.AddFilter(rule);

        try
        {
            filterControl.StartFilter();
            Console.WriteLine("Zero-Trust File Security is active.");
            Console.WriteLine("Try opening files in C:\\SecureData\\ with anything other than MySecureApp!");
            Console.ReadLine();
        }
        catch (Exception ex)
        {
            Console.WriteLine("Failed to start filter: " + ex.Message);
        }
        finally
        {
            // Ensure the filter stops securely when the app closes
            filterControl.StopFilter();
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

Filter Driver Reference

Top comments (0)