소프트웨어 보안은 보안 소프트웨어가 아닙니다. 여기서는 인증, 액세스 제어, 기밀성, 암호화, 권한 관리 등의 항목에 대해 설명합니다.
예제 2: 다음 서버 페이지 지시문은 이벤트 유효성 검사를 비활성화합니다.
...
<system.web>
...
<pages enableEventValidation="false">
...
</pages>
</system.web>
<%@ Page ... EnableEventValidation="false" %>
EnableHeaderChecking
속성을 HttpRuntimeSection
개체에서 false
로 설정하면 프로그래밍 방식으로 비활성화할 수 있습니다.
Configuration config = WebConfigurationManager.OpenWebConfiguration("/MyApp");
HttpRuntimeSection hrs = (HttpRuntimeSection) config.GetSection("system.web/httpRuntime");
hrs.EnableHeaderChecking = false;
W3Clogger.loggingFields
를 구성할 수 있습니다.
builder.Services.AddW3CLogging(logging =>
logging.LoggingFields = W3CLoggingFields.All;
... )
Example 1
All
플래그를 사용해 ClientIpAddress
, ServerName
, ServerIpAddress
, ServerPort
, UserName
, Cookie
등의 중요한 데이터를 비롯하여 Http 요청에 포함될 수 있는 모든 필드를 로깅하도록 W3Clogging을 구성하는 방법을 보여줍니다.FormsAuthentication.RedirectFromLoginPage()
메서드는 지정된 시간 동안 사용자를 인증 상태로 유지하는 authentication 티켓을 발행합니다. 이 메서드가 두 번째 인수 false
와 함께 호출되면 이 메서드는 web.config
에 지정된 시간 동안 유효한 임시 authentication 티켓을 발행합니다. 두 번째 인수 true
와 함께 호출되면 이 메서드는 persistent authentication 티켓을 발행합니다. .NET 2.0에서 persistent authentication 티켓의 수명은 web.config
의 값을 따르지만 .NET 1.1에서 persistent authentication 티켓은 지나치게 긴 수명 값(예: 50년)을 가집니다. useUnsafeHeaderParsing
속성을 true
로 설정하여 존재합니다. 이 설정을 사용하면 HTTP 헤더에 대한 유효성 검사 규칙이 충분하지 않기 때문에 취약한 응용 프로그램에 대한 공격이 가능해집니다. true
로 설정된 경우 다음 유효성 검사가 수행되지 않습니다. useUnsafeHeaderParsing
이 true로 설정됩니다.
...
<configuration>
<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing="true" />
</settings>
</system.net>
</configuration>
...
Page.EnableViewStateMac = false;
public ActionResult ActionName(Model model, string returnurl)
{
// ... controller logic
}
Example 2::The following Razor code creates a form in the resulting HTML without the built-in defense against cross-site request forgery. Note that parameter
@using (Html.BeginForm(new { ReturnUrl = ViewBag.ReturnUrl })) {
// ... form elements
}
antiforgery
is set to either false
or null
:
@using (Html.BeginForm("actionName", "controllerName", routeValues, FormMethod.Post, antiforgery: false, htmlAtts)) {
// ... form elements
}
NSURLConnectionDelegate.connection(_:willSendRequestFor:)
대리자 콜백 메서드를 구현하면 시스템이 NSURLConnectionDelegate.connection(_:canAuthenticateAgainstProtectionSpace:)
및 NSURLConnectionDelegate.connection(_:didReceive:)
메서드를 무시하게 합니다.NSURLConnectionDelegate.connection(_:willSendRequestFor:)
대리자 메서드를 사용하면 대리자가 연결 인증에 대해 정보에 기반한 결정을 즉시 내릴 수 있습니다. 대리자가 이 메서드를 구현하는 경우, NSURLConnectionDelegate.connection(_:canAuthenticateAgainstProtectionSpace:)
또는 NSURLConnectionDelegate.connection(_:didReceive:)
메서드를 구현할 필요가 없습니다. 사실, 이런 메서드는 호출되지 않으므로 해당 메서드에 대한 모든 보안 검사는 무시됩니다.NSURLConnectionDelegate.connection(_:willSendRequestFor:)
대리자 콜백 메서드를 구현하면 시스템이 NSURLConnectionDelegate.connection(_:canAuthenticateAgainstProtectionSpace:)
및 NSURLConnectionDelegate.connection(_:didReceive:)
메서드를 무시하게 합니다.NSURLConnectionDelegate.connection(_:willSendRequestFor:)
대리자 메서드를 사용하면 대리자가 연결 인증에 대해 정보에 기반한 결정을 즉시 내릴 수 있습니다. 대리자가 이 메서드를 구현하는 경우, NSURLConnectionDelegate.connection(_:canAuthenticateAgainstProtectionSpace:)
또는 NSURLConnectionDelegate.connection(_:didReceive:)
메서드를 구현할 필요가 없습니다. 사실, 이런 메서드는 호출되지 않으므로 해당 메서드에 대한 모든 보안 검사는 무시됩니다.NSURLConnection
개체, NSURLSession
개체 또는 NSURLDownload
개체 대리자의 책임입니다. NSURLCredential
을 초기화합니다.
-(void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential * credential)) completionHandler {
...
[challenge.sender useCredential:[NSURLCredential credentialForTrust: challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];
...
}
NSURLConnection
개체, NSURLSession
개체 또는 NSURLDownload
개체 대리자의 책임입니다. NSURLCredential
을 초기화합니다.
func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
...
let cred = URLCredential(user: "foo", password: "bar", persistence: .none)
let trust = challenge.protectionSpace.serverTrust
let cred = URLCredential(trust:trust!)
...
}
NSURLConnection
개체, NSURLSession
개체 또는 NSURLDownload
개체 대리자의 책임입니다. 서버 신뢰를 평가하기 위해 SecTrustEvaluate(_:_:)
메서드는 서버의 NSURLProtectionSpace
개체의 serverTrust
메서드로부터 얻은 신뢰를 사용하여 호출되어야 합니다. SecTrustEvaluate(_:_:)
메서드는 두 개의 다른 값을 반환합니다.OSStatus
값은 결과 코드를 나타냅니다.cancel(_:)
로 인증 챌린지를 취소해야 합니다.
SecTrustRef trust = [[challenge protectionSpace] serverTrust];
SecTrustResultType result = kSecTrustResultInvalid;
OSStatus status = SecTrustEvaluate(trust, &result);
completionHandler(NSURLSessionAuthChallengeUseCredential, [challenge proposedCredential]);
NSURLConnection
개체, NSURLSession
개체 또는 NSURLDownload
개체 대리자의 책임입니다. 서버 신뢰를 평가하기 위해 SecTrustEvaluate(_:_:)
메서드는 서버의 NSURLProtectionSpace
개체의 serverTrust
메서드로부터 얻은 신뢰를 사용하여 호출되어야 합니다. SecTrustEvaluate(_:_:)
메서드는 두 개의 다른 값을 반환합니다.OSStatus
값은 결과 코드를 나타냅니다.cancel(_:)
로 인증 챌린지를 취소해야 합니다.
let trust = challenge.protectionSpace.serverTrust
var result = SecTrustResultType.invalid
let status = SecTrustEvaluate(trust!,&secresult)
completionHandler(Foundation.URLSession.AuthChallengeDisposition.useCredential, challenge.proposedCredential)
NSURLConnection
대리자는 응용 프로그램이 특정 보호 공간에 대한 인증 챌린지를 처리하는 방법을 알고 있는지를 먼저 확인하지 않고 인증 챌린지를 처리합니다.NSURLProtectionSpace
개체는 서버 또는 서버의 영역(일반적으로 영역(realm)으로 불림)을 나타내며, 인증이 필요합니다.NSURLConnectionDelegate.connection(_:canAuthenticateAgainstProtectionSpace:)
메서드는 인증을 수행해야 하는 NSURLConnectionDelegate.connection(_:didReceive:)
메서드를 호출하기 바로 전에 호출됩니다. 이렇게 하면 보호 공간에 대한 인증을 시도하기 전에 NSURLConnectionDelegate
가 보호 공간을 검사할 수 있습니다. true
를 반환함으로써 대리자는 인증 형식을 처리할 수 있음을 나타냅니다(인증 형식 처리는 connection(_:didReceive:)
에 대한 후속 호출을 통해 처리됨). 해당 대리자가 이 메서드를 구현하지 않고 보호 공간이 클라이언트 인증서 인증 또는 서버 신뢰 인증을 사용하는 경우 시스템은 사용자의 키 집합을 사용하여 인증하려고 시도하는데, 이것은 원하는 동작이 아닐 수 있습니다.NSURLConnection
대리자는 응용 프로그램이 특정 보호 공간에 대한 인증 챌린지를 처리하는 방법을 알고 있는지를 먼저 확인하지 않고 인증 챌린지를 처리합니다.NSURLProtectionSpace
개체는 서버 또는 서버의 영역(일반적으로 영역(realm)으로 불림)을 나타내며, 인증이 필요합니다.NSURLConnectionDelegate.connection(_:canAuthenticateAgainstProtectionSpace:)
메서드는 인증을 수행해야 하는 NSURLConnectionDelegate.connection(_:didReceive:)
메서드를 호출하기 바로 전에 호출됩니다. 이렇게 하면 보호 공간에 대한 인증을 시도하기 전에 NSURLConnectionDelegate
가 보호 공간을 검사할 수 있습니다. true
를 반환함으로써 대리자는 인증 형식을 처리할 수 있음을 나타냅니다(인증 형식 처리는 connection(_:didReceive:)
에 대한 후속 호출을 통해 처리됨). 해당 대리자가 이 메서드를 구현하지 않고 보호 공간이 클라이언트 인증서 인증 또는 서버 신뢰 인증을 사용하는 경우 시스템은 사용자의 키 집합을 사용하여 인증하려고 시도하는데, 이것은 원하는 동작이 아닐 수 있습니다.NSURLConnection
또는 NSURLSession
에 대한 인증 처리 콜백이 어떤 호스트에 자격 증명을 보내는지 확인하지 못합니다.NSURLConnection
또는 NSURLSession
콜백을 구현하여 인증 요청을 처리합니다. 예상 호스트에서 인증 요청이 나오도록 확인하는 것을 잊어버리면 자격 증명은 응용 프로그램이 로드하는 모든 URL에 전송됩니다. 또한, 자격 증명이 안전하게 전송될 수 있음을 확인하지 못하면 자격 증명이 도난됩니다.
- (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NS URLAuthenticationChallenge *)challenge completionHandler:(void (^)(NS URLSessionAuthChallengeDisposition, NSURLCredential *))completionHandler {
NSString *user = [self getUser];
NSString *pass = [self getPassword];
NSURLCredential *cred = [NSURLCredential credentialWithUser:user
password:pass persistence:NSURLCredentialPersistenceForSession];
completionHandler(NSURLSessionAuthChallengeUseCredential, credential);
}
NSURLConnection
또는 NSURLSession
에 대한 인증 처리 콜백이 어떤 호스트에 자격 증명을 보내는지 확인하지 못합니다.NSURLConnection
또는 NSURLSession
콜백을 구현하여 인증 요청을 처리합니다. 예상 호스트에서 인증 요청이 나오도록 확인하는 것을 잊어버리면 자격 증명은 응용 프로그램이 로드하는 모든 URL에 전송됩니다. 또한, 자격 증명이 안전하게 전송될 수 있음을 확인하지 못하면 자격 증명이 도난됩니다.
func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
let user = getUser()
let pass = getPassword()
let credential = URLCredential(user: user, password: pass, persistence: .none)
completionHandler(Foundation.URLSession.AuthChallengeDisposition.useCredential, credential)
}
22
를 전 세계에 공개(0.0.0.0/0
)하는 AWS 보안 그룹을 정의합니다.
- name: Task to open SSH port
amazon.aws.ec2_group:
name: demo_security_group
description: Open the ssh port to the world
state: present
vpc_id: 123456
region: us-west-1
rules:
- proto: tcp
ports: 22
cidr_ip: 0.0.0.0/0
- name: Create Lambda policy statement for S3 event notification
community.aws.lambda_policy:
action: lambda:InvokeFunction
function_name: functionName
principal: *
statement_id: lambda-s3-demobucket-access-log
source_arn: arn:aws:s3:us-west-2:123456789012:demobucket
source_account: 123456789012
state: present
publicly_accessible
매개 변수를 yes
로 설정하여 Amazon Redshift 클러스터에 대한 공개 액세스를 명시적으로 활성화하는 Ansible 작업을 보여줍니다.
- name: example1
community.aws.redshift:
identifier: mycluster
command: create
db_name: mydb
node_type: ds1.xlarge
username: "{{ username }}"
password: "{{ password }}"
publicly_accessible: yes
encrypted
매개 변수가.false
로 설정되어 있기 때문에 다음 Ansible 작업은 Amazon EC2 AMI를 생성한 후 미사용 데이터 암호화 없이 블록 장치를 AMI에 연결합니다.
- name: Basic AMI Creation
amazon.aws.ec2_ami:
state: present
instance_id: i-xxxxxx
name: test_ami
device_mapping:
device_name: /dev/sda
encrypted: false
encrypt
매개 변수가 no
로 설정되어 있기 때문에 미사용 데이터 암호화 없이 EFS 파일 시스템을 설정합니다.
- name: EFS provisioning
community.aws.efs:
state: present
name: myTestEFS
encrypt: no
targets:
- subnet_id: subnet-12345678
security_groups: [ "sg-87654321" ]