이 페이지는 아직 영어로 제공되지 않습니다. 번역 작업 중입니다.
현재 번역 프로젝트에 대한 질문이나 피드백이 있으신 경우 언제든지 연락주시기 바랍니다.

Metadata

ID: csharp-security/avoid-unsafe

Language: C#

Severity: Notice

Category: Security

CWE: 823

Description

Avoid unsafe code blocks as much as possible. While unsafe blocks provide access to some important features of the C# language, you need to avoid using them as much as possible. For example, unsafe code allows developers to use pointers, but pointers and pointers arithmetic can lead to critical security issues. Unsafe code should be avoided or at least clearly identified in a small scope.

Learn More

Non-Compliant Code Examples

using System.IO;
using System.Security.Cryptography;

class MyClass {
    public void myMethod
    {
        unsafe{
            // statements
        }
       
    }
}
using System.IO;
using System.Security.Cryptography;

class MyClass {
    public unsafe void myMethod
    {
       // statements
    }
}

Compliant Code Examples

using System.IO;
using System.Security.Cryptography;

class MyClass {
    public void myMethod
    {
       // statements
    }
}
PREVIEWING: aliciascott/DOCS-9725-Cloudcraft