C++의 최선의 보안 구현 방법

This article contains information about security tools and practices.Using them does not make applications immune from attack, but it makes successful attacks less likely.

Visual C++ 보안 기능

These security features are built into the Visual C++ compiler and linker:

  • /GS(버퍼 보안 검사)
    Instructs the compiler to insert overrun detection code into functions that are at risk of being exploited.오버런이 감지되면 실행이 중지됩니다.By default, this option is on.

  • /SAFESEH(이미지에 안전한 예외 처리기 포함)
    Instructs the linker to include in the output image a table that contains the address of each exception handler.At run time, the operating system uses this table to make sure that only legitimate exception handlers are executed.This helps prevent the execution of exception handlers that are introduced by a malicious attack at run time.By default, this option is off.

  • /NXCOMPAT, /NXCOMPAT(데이터 실행 방지 기능과 호환)
    These compiler and linker options enable Data Execution Prevention (DEP) compatibility.DEP guards the CPU against the execution of non-code pages.

  • /analyze(코드 분석)
    이 컴파일러 옵션은 버퍼 오버런, 초기화되지 않은 메모리, null 포인터 역참조 및 메모리 누수와 같은 잠재적인 보안 문제를 보고하는 코드 분석을 활성화합니다.By default, this option is off.자세한 내용은 C/C++용 코드 분석 개요을 참조하십시오.

  • /DYNAMICBASE(주소 공간 레이아웃을 임의로 지정)
    This linker option enables the building of an executable image that can be loaded at different locations in memory at the beginning of execution.또한 이 옵션을 사용하면 메모리에서의 스택 위치를 훨씬 더 예측하기 어려워집니다.

보안이 강화된 CRT

The C Runtime Library (CRT) has been augmented to include secure versions of functions that pose security risks—for example, the unchecked strcpy string copy function.Because the older, nonsecure versions of these functions are deprecated, they cause compile-time warnings.We encourage you to use the secure versions of these CRT functions instead of suppressing the compilation warnings.자세한 내용은 CRT의 보안 기능을 참조하십시오.

SafeInt 라이브러리

SafeInt 라이브러리 helps prevent integer overflows and other exploitable errors that might occur when the application performs mathematical operations.SafeInt 라이브러리에는 SafeInt 클래스, SafeIntException 클래스 및 여러 SafeInt 함수가 포함됩니다.

SafeInt 클래스는 정수 오버플로 및 0으로 나누기가 수행되지 않도록 방지합니다.You can use it to handle comparisons between values of different types.I provides two error handling policies.기본 정책은 SafeInt 클래스에서 SafeIntException 클래스 예외를 throw하여 수학 연산을 수행할 수 없는 이유를 보고하는 것입니다.두 번째 정책은 SafeInt 클래스에서 프로그램 실행을 중지하는 것입니다.사용자 지정 정책을 정의할 수도 있습니다.

SafeInt 함수는 하나의 수학 연산에서 악용될 수 있는 오류가 발생하지 않도록 보호합니다.You can use two different kinds of parameters without converting them to the same type.To protect multiple mathematical operations, use the SafeInt class.

확인된 반복기

A checked iterator enforces container boundaries.기본적으로 확인된 반복기가 범위를 벗어나면 예외가 생성되고 프로그램 실행이 종료됩니다.A checked iterator provides other levels of response that depend on values that are assigned to preprocessor defines such as _SECURE_SCL_THROWS and _ITERATOR_DEBUG_LEVEL.For example, at _ITERATOR_DEBUG_LEVEL=2, a checked iterator provides comprehensive correctness checks in debug mode, which are made available by using asserts.자세한 내용은 확인 된 반복기을 참조하십시오.

관리 코드에 대한 코드 분석

Code Analysis for Managed Code, also known as FxCop, checks assemblies for conformance to the.NET Framework design guidelines.FxCop analyzes the code and metadata in each assembly to check for defects in the following areas:

  • 라이브러리 디자인

  • 지역화

  • 명명 규칙

  • 성능

  • 보안

Windows 응용 프로그램 검증 도구

The Application Verifier (AppVerifier) can help you identify potential application compatibility, stability, and security issues.

AppVerifier는 응용 프로그램에서 운영 체제를 사용하는 방법을 모니터링합니다.It watches the file system, registry, memory, and APIs while the application is running, and recommends source-code fixes for issues that it uncovers.

You can use the AppVerifier to:

  • Test for potential application compatibility errors that are caused by common programming mistakes.

  • 응용 프로그램에서 메모리 관련 문제를 검사합니다.

  • 응용 프로그램의 잠재적 보안 문제를 확인합니다.

The AppVerifier is part of the Application Compatibility Toolkit, which is available from the Application Compatibility on the TechNet web site.

.NET Framework 보안 기능

Configuring Security Policy describes guidelines and tools for adjusting the .NET Framework security policies.

Windows 사용자 계정

관리자 그룹에 속한 Windows 사용자 계정을 사용하면 개발자와 사용자가 보안 위험에 처할 수 있습니다.자세한 내용은 사용자 그룹의 멤버로 실행UAC(사용자 계정 컨트롤)가 응용 프로그램에 주는 영향을 참조하십시오.

참고 항목

참조

System.Security

개념

UAC(사용자 계정 컨트롤)가 응용 프로그램에 주는 영향

기타 리소스

.NET Framework의 보안