Rule Definition
Unrestricted FileIOPermission grants permission for all paths within a file system, including multiple pathnames that can be used to access a single given file.
Remediation
Ensure not using File IO unrestricted access
Violation Code Sample
using System;
using System.Reflection;
using System.Security.Permissions;
using System.Security;
using System.IO;
class MyClass
{
// This method demonstrates the use of the FileIOPermissionAttribute to create a PermitOnly permission.
// Set the Read property.
[FileIOPermissionAttribute(SecurityAction.Demand, Unrestricted=true)]
public static void PermitOnlyMethod()
{
Console.WriteLine("Executing PermitOnlyMethod.");
PermitOnlyTestMethod();
}
}
Fixed Code Sample
using System;
using System.Reflection;
using System.Security.Permissions;
using System.Security;
using System.IO;
class MyClass
{
// This method demonstrates the use of the FileIOPermissionAttribute to create a PermitOnly permission.
// Set the Read property.
[FileIOPermissionAttribute(SecurityAction.PermitOnly, Read = "C:\\")]
public static void PermitOnlyMethod()
{
Console.WriteLine("Executing PermitOnlyMethod.");
PermitOnlyTestMethod();
}
}
Reference
https://docs.microsoft.com/en-us/dotnet/api/system.security.permissions.fileiopermissionattribute?view=dotnet-plat-ext-3.1
Related Technologies
Technical Criterion
CWE-502 - Deserialization of Untrusted Data
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.