대부분의 코드 액세스 보안 API가 사용되지 않음
.NET의 CAS(코드 액세스 보안) 관련 형식은 대부분 경고로 표시되며 사용되지 않습니다. 여기에는 SecurityPermissionAttribute, CAS 권한 개체(예: SocketPermission), EvidenceBase 파생 형식 및 기타 지원되는 API와 같은 CAX 특성이 포함됩니다.
변경 내용 설명
.NET Framework 2.x - 4.x에서 CAS 특성 및 API는 CAS 요청 스택이 성공하거나 실패하도록 하는 등 코드 실행 과정에 영향을 줄 수 있습니다.
// In .NET Framework, the attribute causes CAS stack walks
// to terminate successfully when this permission is demanded.
[SocketPermission(SecurityAction.Assert, Host = "contoso.com", Port = "443")]
public void DoSomething()
{
// open a socket to contoso.com:443
}
.NET Core 2.x - 3.x에서 런타임은 CAS 특성이나 CAS API를 적용하지 않습니다. 런타임은 메서드 항목의 특성을 무시하고 대부분의 프로그래밍 API는 영향을 주지 않습니다.
// The .NET Core runtime ignores the following attribute.
[SocketPermission(SecurityAction.Assert, Host = "contoso.com", Port = "443")]
public void DoSomething()
{
// open a socket to contoso.com:443
}
또한 광범위한 API에 대한 프로그래밍 방식 호출(Assert
)은 항상 성공하지만 제한적 API에 대한 프로그래밍 방식 호출(Deny
, PermitOnly
)은 런타임에 항상 예외를 throw합니다. (PrincipalPermission은 이 규칙의 예외입니다. 아래의 권장 사항 섹션을 참조하세요.)
public void DoAssert()
{
// The line below has no effect at run time.
new SocketPermission(PermissionState.Unrestricted).Assert();
}
public void DoDeny()
{
// The line below throws PlatformNotSupportedException at run time.
new SocketPermission(PermissionState.Unrestricted).Deny();
}
.NET 5 이상 버전에서 대부분의 CAS 관련 API는 더 이상 사용되지 않으며 SYSLIB0003
컴파일 시간 경고를 생성합니다.
[SocketPermission(SecurityAction.Assert, Host = "contoso.com", Port = "443")] // warning SYSLIB0003
public void DoSomething()
{
new SocketPermission(PermissionState.Unrestricted).Assert(); // warning SYSLIB0003
new SocketPermission(PermissionState.Unrestricted).Deny(); // warning SYSLIB0003
}
이는 컴파일 시간 전용 변경입니다. .NET Core의 이전 버전에서 런타임 변경은 없습니다. .NET Core 2.x - 3.x에서 작업을 수행하지 않는 메서드는 .NET 5 이상에서도 런타임에 계속 작업을 수행하지 않습니다. .NET Core 2.x - 3.x에서 PlatformNotSupportedException을 throw하는 메서드는 .NET 5 이상에서도 런타임에 PlatformNotSupportedException을 계속 throw합니다.
변경 이유
CAS(코드 액세스 보안)는 지원되지 않는 레거시 기술입니다. CAS를 사용하도록 설정하는 인프라는 .NET Framework 2.x - 4.x에만 있지만 사용되지 않으며 서비스 또는 보안 수정을 받지 않습니다.
CAS가 사용되지 않기 때문에 지원 인프라가 .NET Core 또는 .NET 5 이상으로 전달되지 않았습니다. 그러나 앱이 .NET Framework 및 .NET Core에 대해 크로스 컴파일을 수행할 수 있도록 API가 전달되었습니다. 따라서 일부 CAS 관련 API가 존재하고 호출할 수 있지만 런타임에 작업을 수행하지 않는 “열기 실패” 시나리오가 됩니다. 그러면 런타임에서 CAS 관련 특성 또는 프로그래밍 API 호출을 적용하도록 하는 구성 요소에 대한 보안 문제가 발생할 수 있습니다. 런타임에서 이러한 특성이나 API를 사용하지 않음을 더욱 잘 전달하기 위해 .NET 5.0에서는 대부분 사용되지 않음으로 설정했습니다.
도입된 버전
5.0
권장 작업
보안 권한을 어설션하려면 사용 권한을 어설션하는 호출이나 특성을 제거하세요.
// REMOVE the attribute below. [SecurityPermission(SecurityAction.Assert, ControlThread = true)] public void DoSomething() { } public void DoAssert() { // REMOVE the line below. new SecurityPermission(SecurityPermissionFlag.ControlThread).Assert(); }
PermitOnly
를 통해 사용 권한을 거부하거나 제한하려면 보안 관리자에게 문의하세요. CAS 특성은 .NET 5 이상 런타임에 적용되지 않기 때문에 CAS 인프라를 사용하여 이러한 메서드에 대한 액세스를 제한하는 경우 애플리케이션에서 보안 허점이 발생할 수 있습니다.// REVIEW the attribute below; could indicate security vulnerability. [SecurityPermission(SecurityAction.Deny, ControlThread = true)] public void DoSomething() { } public void DoPermitOnly() { // REVIEW the line below; could indicate security vulnerability. new SecurityPermission(SecurityPermissionFlag.ControlThread).PermitOnly(); }
PrincipalPermission을 제외한 모든 사용 권한을 요청하려면 요청을 제거하세요. 모든 요청은 런타임에 성공합니다.
// REMOVE the attribute below; it will always succeed. [SecurityPermission(SecurityAction.Demand, ControlThread = true)] public void DoSomething() { } public void DoDemand() { // REMOVE the line below; it will always succeed. new SecurityPermission(SecurityPermissionFlag.ControlThread).Demand(); }
PrincipalPermission을 요청하려면 PrincipalPermissionAttribute가 오류로 사용되지 않음에 대한 지침을 참조하세요. 이 지침은 PrincipalPermission과 PrincipalPermissionAttribute 모두에 적용됩니다.
이러한 경고를 반드시 사용하지 않도록 설정해야 하는 경우(권장되지 않음) 코드에서
SYSLIB0003
경고를 표시하지 않을 수 있습니다.#pragma warning disable SYSLIB0003 // disable the warning [SecurityPermission(SecurityAction.Demand, ControlThread = true)] #pragma warning restore SYSLIB0003 // re-enable the warning public void DoSomething() { } public void DoDemand() { #pragma warning disable SYSLIB0003 // disable the warning new SecurityPermission(SecurityPermissionFlag.ControlThread).Demand(); #pragma warning restore SYSLIB0003 // re-enable the warning }
프로젝트 파일에서 경고를 표시하지 않을 수도 있습니다. 이렇게 하면 프로젝트 내의 모든 소스 파일에 대한 경고를 사용할 수 없게 됩니다.
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net5.0</TargetFramework> <!-- NoWarn below suppresses SYSLIB0003 project-wide --> <NoWarn>$(NoWarn);SYSLIB0003</NoWarn> </PropertyGroup> </Project>
참고 항목
SYSLIB0003
을 표시하지 않으면 CAS 관련 사용되지 않음 경고만 사용하지 않도록 설정합니다. 다른 경고를 사용하지 않도록 설정하거나 .NET 5 이상 런타임의 동작을 변경하지는 않습니다.보안
영향을 받는 API
- System.AppDomain.PermissionSet
- System.Configuration.ConfigurationPermission
- System.Configuration.ConfigurationPermissionAttribute
- System.Data.Common.DBDataPermission
- System.Data.Common.DBDataPermissionAttribute
- System.Data.Odbc.OdbcPermission
- System.Data.Odbc.OdbcPermissionAttribute
- System.Data.OleDb.OleDbPermission
- System.Data.OleDb.OleDbPermissionAttribute
- System.Data.OracleClient.OraclePermission
- System.Data.OracleClient.OraclePermissionAttribute
- System.Data.SqlClient.SqlClientPermission
- System.Data.SqlClient.SqlClientPermissionAttribute
- System.Diagnostics.EventLogPermission
- System.Diagnostics.EventLogPermissionAttribute
- System.Diagnostics.PerformanceCounterPermission
- System.Diagnostics.PerformanceCounterPermissionAttribute
- System.DirectoryServices.DirectoryServicesPermission
- System.DirectoryServices.DirectoryServicesPermissionAttribute
- System.Drawing.Printing.PrintingPermission
- System.Drawing.Printing.PrintingPermissionAttribute
- System.Net.DnsPermission
- System.Net.DnsPermissionAttribute
- System.Net.Mail.SmtpPermission
- System.Net.Mail.SmtpPermissionAttribute
- System.Net.NetworkInformation.NetworkInformationPermission
- System.Net.NetworkInformation.NetworkInformationPermissionAttribute
- System.Net.PeerToPeer.Collaboration.PeerCollaborationPermission
- System.Net.PeerToPeer.Collaboration.PeerCollaborationPermissionAttribute
- System.Net.PeerToPeer.PnrpPermission
- System.Net.PeerToPeer.PnrpPermissionAttribute
- System.Net.SocketPermission
- System.Net.SocketPermissionAttribute
- System.Net.WebPermission
- System.Net.WebPermissionAttribute
- System.Runtime.InteropServices.AllowReversePInvokeCallsAttribute
- System.Security.CodeAccessPermission
- System.Security.HostProtectionException
- System.Security.IPermission
- System.Security.IStackWalk
- System.Security.NamedPermissionSet
- System.Security.PermissionSet
- System.Security.Permissions.CodeAccessSecurityAttribute
- System.Security.Permissions.DataProtectionPermission
- System.Security.Permissions.DataProtectionPermissionAttribute
- System.Security.Permissions.DataProtectionPermissionFlags
- System.Security.Permissions.EnvironmentPermission
- System.Security.Permissions.EnvironmentPermissionAccess
- System.Security.Permissions.EnvironmentPermissionAttribute
- System.Security.Permissions.FileDialogPermission
- System.Security.Permissions.FileDialogPermissionAccess
- System.Security.Permissions.FileDialogPermissionAttribute
- System.Security.Permissions.FileIOPermission
- System.Security.Permissions.FileIOPermissionAccess
- System.Security.Permissions.FileIOPermissionAttribute
- System.Security.Permissions.GacIdentityPermission
- System.Security.Permissions.GacIdentityPermissionAttribute
- System.Security.Permissions.HostProtectionAttribute
- System.Security.Permissions.HostProtectionResource
- System.Security.Permissions.IUnrestrictedPermission
- System.Security.Permissions.IsolatedStorageContainment
- System.Security.Permissions.IsolatedStorageFilePermission
- System.Security.Permissions.IsolatedStorageFilePermissionAttribute
- System.Security.Permissions.IsolatedStoragePermission
- System.Security.Permissions.IsolatedStoragePermissionAttribute
- System.Security.Permissions.KeyContainerPermission
- System.Security.Permissions.KeyContainerPermissionAccessEntry
- System.Security.Permissions.KeyContainerPermissionAccessEntryCollection
- System.Security.Permissions.KeyContainerPermissionAccessEntryEnumerator
- System.Security.Permissions.KeyContainerPermissionAttribute
- System.Security.Permissions.KeyContainerPermissionFlags
- System.Security.Permissions.MediaPermission
- System.Security.Permissions.MediaPermissionAttribute
- System.Security.Permissions.MediaPermissionAudio
- System.Security.Permissions.MediaPermissionImage
- System.Security.Permissions.MediaPermissionVideo
- System.Security.Permissions.PermissionSetAttribute
- System.Security.Permissions.PermissionState
- System.Security.Permissions.PrincipalPermission
- System.Security.Permissions.PrincipalPermissionAttribute
- System.Security.Permissions.PublisherIdentityPermission
- System.Security.Permissions.PublisherIdentityPermissionAttribute
- System.Security.Permissions.ReflectionPermission
- System.Security.Permissions.ReflectionPermissionAttribute
- System.Security.Permissions.ReflectionPermissionFlag
- System.Security.Permissions.RegistryPermission
- System.Security.Permissions.RegistryPermissionAccess
- System.Security.Permissions.RegistryPermissionAttribute
- System.Security.Permissions.ResourcePermissionBase
- System.Security.Permissions.ResourcePermissionBaseEntry
- System.Security.Permissions.SecurityAction
- System.Security.Permissions.SecurityAttribute
- System.Security.Permissions.SecurityPermission
- System.Security.Permissions.SecurityPermissionAttribute
- System.Security.Permissions.SecurityPermissionFlag
- System.Security.Permissions.SiteIdentityPermission
- System.Security.Permissions.SiteIdentityPermissionAttribute
- System.Security.Permissions.StorePermission
- System.Security.Permissions.StorePermissionAttribute
- System.Security.Permissions.StorePermissionFlags
- System.Security.Permissions.StrongNameIdentityPermission
- System.Security.Permissions.StrongNameIdentityPermissionAttribute
- System.Security.Permissions.StrongNamePublicKeyBlob
- System.Security.Permissions.TypeDescriptorPermission
- System.Security.Permissions.TypeDescriptorPermissionAttribute
- System.Security.Permissions.TypeDescriptorPermissionFlags
- System.Security.Permissions.UIPermission
- System.Security.Permissions.UIPermissionAttribute
- System.Security.Permissions.UIPermissionClipboard
- System.Security.Permissions.UIPermissionWindow
- System.Security.Permissions.UrlIdentityPermission
- System.Security.Permissions.UrlIdentityPermissionAttribute
- System.Security.Permissions.WebBrowserPermission
- System.Security.Permissions.WebBrowserPermissionAttribute
- System.Security.Permissions.WebBrowserPermissionLevel
- System.Security.Permissions.ZoneIdentityPermission
- System.Security.Permissions.ZoneIdentityPermissionAttribute
- System.Security.Policy.ApplicationTrust.ApplicationTrust(PermissionSet, IEnumerable<StrongName>)
- System.Security.Policy.ApplicationTrust.FullTrustAssemblies
- System.Security.Policy.FileCodeGroup
- System.Security.Policy.GacInstalled
- System.Security.Policy.IIdentityPermissionFactory
- System.Security.Policy.PolicyLevel.AddNamedPermissionSet(NamedPermissionSet)
- System.Security.Policy.PolicyLevel.ChangeNamedPermissionSet(String, PermissionSet)
- System.Security.Policy.PolicyLevel.GetNamedPermissionSet(String)
- System.Security.Policy.PolicyLevel.RemoveNamedPermissionSet
- System.Security.Policy.PolicyStatement.PermissionSet
- System.Security.Policy.PolicyStatement.PolicyStatement
- System.Security.Policy.Publisher
- System.Security.Policy.Site
- System.Security.Policy.StrongName
- System.Security.Policy.StrongNameMembershipCondition
- System.Security.Policy.Url
- System.Security.Policy.Zone
- System.Security.SecurityManager
- System.ServiceProcess.ServiceControllerPermission
- System.ServiceProcess.ServiceControllerPermissionAttribute
- System.Transactions.DistributedTransactionPermission
- System.Transactions.DistributedTransactionPermissionAttribute
- System.Web.AspNetHostingPermission
- System.Web.AspNetHostingPermissionAttribute
- System.Xaml.Permissions.XamlLoadPermission
.NET