2021-02-09 12:11:03 +01:00
In Unix, "others" class refers to all users except the owner of the file and the members of the group assigned to this file.
In Windows, "Everyone" group is similar and includes all members of the Authenticated Users group as well as the built-in Guest account, and several other built-in security accounts.
Granting permissions to these groups can lead to unintended access to files.
include::../ask-yourself.adoc[]
include::../recommended.adoc[]
== Sensitive Code Example
2021-02-16 11:54:08 +01:00
{empty}.Net Framework:
2021-02-09 12:11:03 +01:00
----
2021-02-15 17:20:44 +01:00
Dim unsafeAccessRule = new FileSystemAccessRule("Everyone", FileSystemRights.FullControl, AccessControlType.Allow)
Dim fileSecurity = File.GetAccessControl("path")
fileSecurity.AddAccessRule(unsafeAccessRule) ' Sensitive
fileSecurity.SetAccessRule(unsafeAccessRule) ' Sensitive
File.SetAccessControl("fileName", fileSecurity)
2021-02-09 12:11:03 +01:00
----
2021-02-16 11:54:08 +01:00
{empty}.Net / .Net Core
2021-02-09 12:11:03 +01:00
----
2021-02-15 12:31:39 +01:00
Dim fileInfo = new FileInfo("path")
Dim fileSecurity = fileInfo.GetAccessControl()
fileSecurity.AddAccessRule(new FileSystemAccessRule("Everyone", FileSystemRights.Write, AccessControlType.Allow)) ' Sensitive
fileInfo.SetAccessControl(fileSecurity)
2021-02-09 12:11:03 +01:00
----
2021-02-16 11:54:08 +01:00
{empty}.Net / .Net Core using Mono.Posix.NETStandard
2021-02-09 12:11:03 +01:00
----
2021-02-15 12:31:39 +01:00
Dim fileSystemEntry = UnixFileSystemInfo.GetFileSystemEntry("path")
fileSystemEntry.FileAccessPermissions = FileAccessPermissions.OtherReadWriteExecute ' Sensitive
2021-02-09 12:11:03 +01:00
----
== Compliant Solution
2021-02-16 11:54:08 +01:00
{empty}.Net Framework
2021-02-09 12:11:03 +01:00
2022-02-04 17:28:24 +01:00
[source,vbnet]
2021-02-09 12:11:03 +01:00
----
2021-02-15 17:20:44 +01:00
Dim safeAccessRule = new FileSystemAccessRule("Everyone", FileSystemRights.FullControl, AccessControlType.Deny)
Dim fileSecurity = File.GetAccessControl("path")
fileSecurity.AddAccessRule(safeAccessRule)
File.SetAccessControl("path", fileSecurity)
2021-02-09 12:11:03 +01:00
----
2021-02-16 11:54:08 +01:00
{empty}.Net / .Net Core
2021-02-09 12:11:03 +01:00
2022-02-04 17:28:24 +01:00
[source,vbnet]
2021-02-09 12:11:03 +01:00
----
2021-02-15 17:20:44 +01:00
Dim safeAccessRule = new FileSystemAccessRule("Everyone", FileSystemRights.FullControl, AccessControlType.Deny)
2021-02-15 12:31:39 +01:00
Dim fileInfo = new FileInfo("path")
Dim fileSecurity = fileInfo.GetAccessControl()
fileSecurity.SetAccessRule(safeAccessRule)
fileInfo.SetAccessControl(fileSecurity)
2021-02-09 12:11:03 +01:00
----
2021-02-16 11:54:08 +01:00
{empty}.Net / .Net Core using Mono.Posix.NETStandard
2021-02-09 12:11:03 +01:00
2022-02-04 17:28:24 +01:00
[source,vbnet]
2021-02-09 12:11:03 +01:00
----
2021-02-15 12:31:39 +01:00
Dim fs = UnixFileSystemInfo.GetFileSystemEntry("path")
fs.FileAccessPermissions = FileAccessPermissions.UserExecute
2021-02-09 12:11:03 +01:00
----
include::../see.adoc[]
2021-06-02 20:44:38 +02:00
2021-06-03 09:05:38 +02:00
ifdef::env-github,rspecator-view[]
2021-09-20 15:38:42 +02:00
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
2021-06-08 15:52:13 +02:00
'''
2021-06-02 20:44:38 +02:00
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
2023-06-22 10:38:01 +02:00
2021-06-03 09:05:38 +02:00
endif::env-github,rspecator-view[]