Skip to main content
net10.0net11.0

.NET wrapper to get or set Mark of the Web, a metadata identifier used by Microsoft Windows to mark files downloaded from the Internet as potentially unsafe

Published
Sep 20, 2026
29d ago
Total Downloads
3.1K
3,146

Install

dotnet add package Meziantou.Framework.Win32.MarkOfTheWeb --version 2.0.4
ProductVersions
.NET
net10.0net11.0

README

Mark of the Web

The Mark of the Web (MOTW) is a security feature in Windows that helps protect users from potentially unsafe content downloaded from the internet. Windows records the security zone a file came from in an NTFS alternate data stream named Zone.Identifier, alongside the URLs it was downloaded from. When a user attempts to open a file with MOTW, Windows may display a warning message or restrict certain actions, such as running scripts or accessing certain features, to help prevent potential security risks.

Usage

To add the Mark of the Web to a file, you can use the MarkOfTheWeb class provided in this library. Here's an example of how to use it:

// Add the Mark of the Web to a file
MarkOfTheWeb.SetFileZone(path, UrlZone.Internet, referrerUrl: "https://example.com/", hostUrl: "https://example.com/file.zip");

// Get the zone Windows assigns to a file
var zone = MarkOfTheWeb.GetFileZone(path);

// Check whether a file comes from the Internet or Restricted Sites zones
if (MarkOfTheWeb.IsUntrusted(path))
{
    // ...
}

// Read what the Zone.Identifier stream records
var zoneIdentifier = MarkOfTheWeb.GetFileZoneIdentifier(path); // null when the file has no Mark of the Web
Console.WriteLine($"{zoneIdentifier?.Zone} {zoneIdentifier?.HostUrl} {zoneIdentifier?.ReferrerUrl}");

// Read the raw content of the Zone.Identifier stream
var content = MarkOfTheWeb.GetFileZoneContent(path);

// Remove the Mark of the Web from a file
MarkOfTheWeb.RemoveFileZone(path);

Use GetFileZone or IsUntrusted to make a security decision. GetFileZoneIdentifier and GetFileZoneContent report what the stream contains, which is not always the zone Windows applies to the file.

Changes from Previous Version

No structural changes between v2.0.3 and v2.0.4.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

Compatibility metadata lists 2 target frameworks; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.