계: Time and State

분산 컴퓨팅에서 중요한 것은 시간과 상태입니다. 즉, 둘 이상의 구성 요소가 통신하려면 상태를 공유해야 하며 시간이 걸립니다.

대부분의 프로그래머들은 자신들의 작업을 의인화합니다. 하나의 컨트롤 스레드로 마치 자신이 직접 작업한 것처럼 전체 프로그램을 수행할 수 있을 것으로 생각합니다. 하지만 최신 컴퓨터는 작업 간에 매우 빠르게 전환되므로 멀티코어, 멀티 CPU 또는 분산 시스템에서 두 이벤트가 정확히 동시에 발생할 수 있습니다. 프로그래머가 만든 프로그램 실행 모델과 실제 현실 간에 빠르게 결함이 생기기 마련입니다. 이러한 결함은 스레드, 프로세스, 시간 및 정보 간의 예기치 않은 상호작용과 관련이 있습니다. 이러한 상호 작용은 공유 상태를 통해 발생합니다. 세마포, 변수, 파일 시스템 그리고 정보를 저장할 수 있는 모든 것이 여기에 포함됩니다.

19 개 항목 찾음
취약점
Abstract
non-serializable 개체를 HttpSessionState 속성으로 저장하면 응용 프로그램 안정성을 해칠 수 있습니다.
Explanation
기본적으로 ASP.NET 서버는 HttpSessionState 개체, 해당 속성 및 메모리에서 참조하는 모든 개체를 저장합니다. 이 모델은 단일 시스템의 시스템 메모리가 수용할 수 있는 상태로 활성 세션 상태를 제한합니다. 이 제약의 범위를 넘어 용량을 확장하려면 전체적인 성능을 개선하기 위해 용량을 확장하고 여러 시스템 간의 복제를 허용하는 세션 상태 정보를 지속하도록 서버를 자주 구성해야 합니다. 해당 세션 상태를 유지하려면 저장된 모든 개체가 serializable 상태인 HttpSessionState를 서버가 직렬화해야 합니다.

세션을 올바로 직렬화하려면 응용 프로그램이 세션 속성으로 저장하는 모든 개체에 대해 [Serializable] 속성을 선언해야 합니다. 또한, 개체가 사용자 지정 serialization 메서드를 사용해야 하는 경우 ISerializable 인터페이스도 구현해야 합니다.

예제 1: 다음 클래스는 자신을 세션에 추가하지만 serializable 상태가 아니므로 세션을 올바로 직렬화할 수 없습니다.


public class DataGlob {
String GlobName;
String GlobValue;

public void AddToSession(HttpSessionState session) {
session["glob"] = this;
}
}
References
[1] Session State Providers Microsoft Corporation
[2] Underpinnings of the Session State Implementation in ASP.NET Microsoft Corporation
[3] Standards Mapping - CIS Azure Kubernetes Service Benchmark 1.0
[4] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 4.1
[5] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 2
[6] Standards Mapping - CIS Google Kubernetes Engine Benchmark normal
[7] Standards Mapping - Common Weakness Enumeration CWE ID 579
[8] Standards Mapping - OWASP Top 10 2004 A3 Broken Authentication and Session Management
[9] Standards Mapping - OWASP Top 10 2007 A7 Broken Authentication and Session Management
[10] Standards Mapping - OWASP Top 10 2010 A3 Broken Authentication and Session Management
[11] Standards Mapping - OWASP Top 10 2013 A2 Broken Authentication and Session Management
[12] Standards Mapping - OWASP Top 10 2017 A2 Broken Authentication
[13] Standards Mapping - OWASP Top 10 2021 A04 Insecure Design
[14] Standards Mapping - OWASP Mobile 2014 M1 Weak Server Side Controls
[15] Standards Mapping - Payment Card Industry Data Security Standard Version 1.1 Requirement 6.5.3
[16] Standards Mapping - Payment Card Industry Data Security Standard Version 1.2 Requirement 6.5.7
[17] Standards Mapping - Payment Card Industry Data Security Standard Version 2.0 Requirement 6.5.8
[18] Standards Mapping - Payment Card Industry Data Security Standard Version 3.0 Requirement 6.5.10
[19] Standards Mapping - Payment Card Industry Data Security Standard Version 3.1 Requirement 6.5.10
[20] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2 Requirement 6.5.10
[21] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2.1 Requirement 6.5.10
[22] Standards Mapping - Payment Card Industry Data Security Standard Version 4.0 Requirement 6.2.4
[23] Standards Mapping - Payment Card Industry Software Security Framework 1.0 Control Objective 4.2 - Critical Asset Protection
[24] Standards Mapping - Payment Card Industry Software Security Framework 1.1 Control Objective 4.2 - Critical Asset Protection
[25] Standards Mapping - Payment Card Industry Software Security Framework 1.2 Control Objective 4.2 - Critical Asset Protection
desc.structural.dotnet.asp_dotnet_bad_practices_non_serializable_object_stored_in_session
Abstract
잠금 상태에 있는 동안 sleep()을 호출하면 성능이 떨어질 수 있고 교착 상태(deadlock)가 발생할 수도 있습니다.
Explanation
여러 스레드가 리소스를 잠그려고 할 경우, 잠금 상태에 있는 동안 sleep()을 호출하면 다른 모든 스레드는 리소스가 해제되기를 기다리게 될 수 있어 성능이 저하되거나 교착 상태(deadlock)가 될 수 있습니다.

예제 1: 다음 코드는 잠금 상태에 있는 동안 sleep()을 호출합니다.

ReentrantLock rl = new ReentrantLock();
...
rl.lock();
Thread.sleep(500);
...
rl.unlock();
References
[1] LCK09-J. Do not perform operations that can block while holding a lock CERT
[2] Standards Mapping - CIS Azure Kubernetes Service Benchmark 1.0
[3] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 5.0
[4] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 1
[5] Standards Mapping - CIS Google Kubernetes Engine Benchmark normal
[6] Standards Mapping - Common Weakness Enumeration CWE ID 557
[7] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-000336, CCI-000366, CCI-001094
[8] Standards Mapping - NIST Special Publication 800-53 Revision 4 CM-4 Security Impact Analysis (P2), CM-6 Configuration Settings (P1), SC-5 Denial of Service Protection (P1)
[9] Standards Mapping - NIST Special Publication 800-53 Revision 5 CM-4 Impact Analyses, CM-6 Configuration Settings, SC-5 Denial of Service Protection
[10] Standards Mapping - OWASP Top 10 2004 A9 Application Denial of Service
[11] Standards Mapping - Payment Card Industry Data Security Standard Version 1.1 Requirement 6.5.9
[12] Standards Mapping - Security Technical Implementation Guide Version 3.1 APP6080 CAT II
[13] Standards Mapping - Security Technical Implementation Guide Version 3.4 APP6080 CAT II
[14] Standards Mapping - Security Technical Implementation Guide Version 3.5 APP6080 CAT II
[15] Standards Mapping - Security Technical Implementation Guide Version 3.6 APP6080 CAT II
[16] Standards Mapping - Security Technical Implementation Guide Version 3.7 APP6080 CAT II
[17] Standards Mapping - Security Technical Implementation Guide Version 3.9 APP6080 CAT II
[18] Standards Mapping - Security Technical Implementation Guide Version 3.10 APP6080 CAT II
[19] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-002400 CAT II
[20] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-002400 CAT II
[21] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-002400 CAT II
[22] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-002400 CAT II
[23] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-002400 CAT II
[24] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-002400 CAT II
[25] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-002400 CAT II
[26] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-002400 CAT II
[27] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-002400 CAT II
[28] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-002400 CAT II
[29] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-002400 CAT II
[30] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-002400 CAT II
[31] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-002400 CAT II
[32] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-002400 CAT II, APSC-DV-002950 CAT II
[33] Standards Mapping - Web Application Security Consortium Version 2.00 Denial of Service (WASC-10)
[34] Standards Mapping - Web Application Security Consortium 24 + 2 Denial of Service
desc.controlflow.java.code_correctness_call_to_sleep_in_lock
Abstract
double-checked locking은 의도한 효과를 발휘하지 못하는 잘못된 표현입니다.
Explanation
많은 재능있는 개발자들이 double-checked locking을 사용하여 성능을 개선할 방법을 찾기 위해 엄청난 시간을 쏟아 부었습니다. 하지만 아무도 성공하지 못했습니다.

예제 1: 언뜻 보기에 다음 코드 조각은 불필요한 동기화를 피하면서 스레드 안전을 보장하는 것처럼 보입니다.


if (fitz == null) {
synchronized (this) {
if (fitz == null) {
fitz = new Fitzer();
}
}
}
return fitz;


프로그래머가 하나의 Fitzer() 개체만 할당되는 것을 보장하려 하지만 이 코드를 호출할 때마다 동기화 비용을 지불하지는 않으려는 경우가 있습니다. 이런 경우를 double-checked locking이라고 합니다.

유감스럽게도 코드는 의도대로 동작하지 않고 여러 Fitzer() 개체를 할당합니다. 자세한 내용은 "Double-Checked Locking is Broken" Declaration을 참조하십시오[1].
References
[1] D. Bacon et al. The "Double-Checked Locking is Broken" Declaration
[2] LCK10-J. Use a correct form of the double-checked locking idiom CERT
[3] Standards Mapping - CIS Azure Kubernetes Service Benchmark 1.0
[4] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 3.0
[5] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 1
[6] Standards Mapping - CIS Google Kubernetes Engine Benchmark normal
[7] Standards Mapping - Common Weakness Enumeration CWE ID 609
[8] Standards Mapping - Payment Card Industry Data Security Standard Version 3.0 Requirement 6.5.6
[9] Standards Mapping - Payment Card Industry Data Security Standard Version 3.1 Requirement 6.5.6
[10] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2 Requirement 6.5.6
[11] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2.1 Requirement 6.5.6
[12] Standards Mapping - Payment Card Industry Software Security Framework 1.0 Control Objective 4.2 - Critical Asset Protection
[13] Standards Mapping - Payment Card Industry Software Security Framework 1.1 Control Objective 4.2 - Critical Asset Protection
[14] Standards Mapping - Payment Card Industry Software Security Framework 1.2 Control Objective 4.2 - Critical Asset Protection
desc.structural.java.code_correctness_double_checked_locking
Abstract
다른 스레드를 시그널 처리한 후 스레드가 뮤텍스의 잠금 해제에 실패하면 다른 스레드가 뮤텍스를 잠금 상태로 유지합니다.
Explanation
스레드가 뮤텍스에 대기 중인 다른 스레드를 신호 처리한 다음, 또 다른 스레드가 실행을 시작하기 전에 pthread_mutex_unlock()을 호출하여 뮤텍스를 잠금 해제해야 합니다. 스레드의 신호 처리가 뮤텍스의 잠금 해제를 실패하는 경우, 두 번째 스레드의 pthread_cond_wait() 호출은 반환되지 않고 이 스레드는 실행되지 않습니다.

예제 1: 다음 코드는 pthread_cond_signal()를 호출하여 뮤텍스에 대기 중인 또 다른 스레드를 신호 처리하지만, 대기 중인 나머지 스레드를 뮤텍스의 잠금 해제하는 것은 실패합니다.


...
pthread_mutex_lock(&count_mutex);

// Signal waiting thread
pthread_cond_signal(&count_threshold_cv);
...
References
[1] Standards Mapping - CIS Azure Kubernetes Service Benchmark 1.0
[2] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 2.0
[3] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 1
[4] Standards Mapping - CIS Google Kubernetes Engine Benchmark normal
[5] Standards Mapping - Common Weakness Enumeration CWE ID 373
[6] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-000336, CCI-000366, CCI-001094
[7] Standards Mapping - Motor Industry Software Reliability Association (MISRA) C Guidelines 2012 Rule 1.3
[8] Standards Mapping - NIST Special Publication 800-53 Revision 4 CM-4 Security Impact Analysis (P2), CM-6 Configuration Settings (P1), SC-5 Denial of Service Protection (P1)
[9] Standards Mapping - NIST Special Publication 800-53 Revision 5 CM-4 Impact Analyses, CM-6 Configuration Settings, SC-5 Denial of Service Protection
[10] Standards Mapping - OWASP Top 10 2004 A9 Application Denial of Service
[11] Standards Mapping - Payment Card Industry Data Security Standard Version 1.1 Requirement 6.5.9
[12] Standards Mapping - Security Technical Implementation Guide Version 3.1 APP6080 CAT II
[13] Standards Mapping - Security Technical Implementation Guide Version 3.4 APP6080 CAT II
[14] Standards Mapping - Security Technical Implementation Guide Version 3.5 APP6080 CAT II
[15] Standards Mapping - Security Technical Implementation Guide Version 3.6 APP6080 CAT II
[16] Standards Mapping - Security Technical Implementation Guide Version 3.7 APP6080 CAT II
[17] Standards Mapping - Security Technical Implementation Guide Version 3.9 APP6080 CAT II
[18] Standards Mapping - Security Technical Implementation Guide Version 3.10 APP6080 CAT II
[19] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-002400 CAT II
[20] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-002400 CAT II
[21] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-002400 CAT II
[22] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-002400 CAT II
[23] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-002400 CAT II
[24] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-002400 CAT II
[25] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-002400 CAT II
[26] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-002400 CAT II
[27] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-002400 CAT II
[28] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-002400 CAT II
[29] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-002400 CAT II
[30] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-002400 CAT II
[31] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-002400 CAT II
[32] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-002400 CAT II, APSC-DV-002950 CAT II
[33] Standards Mapping - Web Application Security Consortium Version 2.00 Denial of Service (WASC-10)
[34] Standards Mapping - Web Application Security Consortium 24 + 2 Denial of Service
desc.structural.cpp.code_correctness_erroneous_synchronization
Abstract
안전하지 않은 임시 파일을 만들어 사용하면 응용 프로그램과 시스템 데이터가 공격에 취약해질 수 있습니다.
Explanation
응용 프로그램이 임시 파일을 너무 자주 필요로 하기 때문에 C 라이브러리와 Windows(R) API에 이를 생성하기 위한 다양한 메커니즘이 많이 있습니다. 이 함수 대부분이 다양한 형태의 공격에 취약합니다.
예제: 다음 코드는 네트워크에서 수집한 중간 데이터를 처리하기 전에 저장하기 위해 임시 파일을 사용합니다.


...
if (tmpnam_r(filename)){
FILE* tmp = fopen(filename,"wb+");
while((recv(sock,recvbuf,DATA_SIZE, 0) > 0)&&(amt!=0))
amt = fwrite(recvbuf,1,DATA_SIZE,tmp);
}
...


안전하지 않은 방법으로 임시 파일을 만든다는 점 외에는 별다른 특징이 없는 이 코드는 바로 그 점 때문에 수많은 다양한 공격에 취약합니다. 다음 섹션에서 이런 함수들 때문에 생긴 취약점에 대해 설명합니다. 임시 파일 생성과 관련한 가장 심각한 보안 문제는 Unix 기반 운영 체제에서 발생하지만, Windows 응용 프로그램도 같은 위험을 안고 있습니다. 이 섹션에서는 Unix 및 Windows 시스템의 임시 파일 생성에 대해 모두 다룹니다.

방법과 동작은 시스템마다 다를 수 있지만 각각이 야기하는 근본적인 위험은 대체로 일정합니다. 안전한 코어 언어 함수에 대한 정보 및 안전한 임시 파일 생성 방법에 관한 조언은 권고 사항 섹션을 참조하십시오.

임시 파일 생성을 지원하도록 설계된 함수는 단순히 파일 이름만 제공하는지 또는 실제로 새 파일을 여는지에 따라 두 그룹으로 나눌 수 있습니다.

그룹 1 - "고유한" 파일 이름:

임시 파일 생성 프로세스를 지원하도록 설계된 첫 번째 그룹의 C 라이브러리 및 WinAPI 함수는 프로그램이 열 새 임시 파일에 고유한 파일 이름을 만들어 프로세스를 지원합니다. 이 그룹에는 Windows API의 GetTempFileName() 함수뿐 아니라 tmpnam(), tempnam(), mktemp() 및 이에 상응하는, 앞에 _(밑줄)이 붙은 C++ 함수 등의 C 라이브러리가 있습니다 이 그룹의 함수는 속성 상 선택한 파일 이름에 대한 경쟁 조건(race condition)이 발생합니다. 함수가 파일 이름 선택 시점에 이름이 고유하다는 것은 보장하지만 이름을 선택한 후 응용 프로그램이 파일을 열기 전에 다른 프로세서나 공격자가 같은 이름의 파일을 생성하는 것을 방지하는 메커니즘이 없습니다. 같은 함수의 다른 호출로 인해 발생하는 자연스러운 충돌의 위험 외에도 이들 함수가 생성한 파일 이름이 추측하기 어려울 만큼 무작위성이 보장되지 않기 때문에 공격자가 악의적으로 충돌을 일으킬 수 있습니다.

선택한 이름의 파일이 만들어지면 파일을 여는 방법에 따라 파일의 기존 내용 또는 접근 권한이 그대로 유지될 수 있습니다. 임시 파일의 기존 내용이 악성인 경우, 공격자는 응용 프로그램이 임시 파일에서 데이터를 읽을 때 위험한 데이터를 응용 프로그램에 삽입하게 됩니다. 공격자가 완화된 접근 권한의 임시 파일을 미리 만들게 되면 응용 프로그램이 임시 파일에 저장한 데이터에 접근, 수정 및 손상시킬 수 있습니다. Unix 기반 시스템에서는 공격자가 임시 파일을 다른 중요한 파일의 링크로 미리 만드는 경우 훨씬 심각한 공격이 될 수 있습니다. 이때 응용 프로그램이 임시 파일을 자르거나 임시 파일에 데이터를 쓰는 경우, 모르는 사이에 공격자 대신 시스템을 손상시키는 작업을 수행할 수 있습니다. 이는 프로그램을 높은 권한으로 실행할 때 특히 위험해집니다.

마지막으로 최선의 방법은 O_CREATO_EXCL 플래그를 사용한 open() 호출 또는 CREATE_NEW 속성을 사용한 CreateFile() 호출로 파일을 여는 것입니다. 이 방법은 파일이 이미 있을 때는 파일을 열지 않기 때문에 앞서 설명한 종류의 공격을 예방할 수 있습니다. 하지만 공격자가 임시 파일 이름의 순서를 정확하게 예측할 수 있는 경우 응용 프로그램이 필요한 임시 저장소를 여는 것을 막아 Denial Of Service(DoS) 공격을 일으킬 수 있습니다. 이런 종류의 공격은 이들 함수가 생성하는 파일의 이름 선택에 사용된 무작위성의 수준이 낮은 것을 감안하면 어렵지 않게 실행할 수 있습니다.

그룹 2 - "고유한" 파일:

두 번째 그룹의 C 라이브러리 함수는 고유한 파일 이름을 생성할 뿐 아니라 파일을 여는 방식으로 일부 임시 파일 관련 보안 문제를 해결하려 합니다. 이 그룹에는 tmpfile() 및 이에 상응하는, 앞에 _(밑줄)이 붙은 C++ 함수뿐 아니라 동작 기능이 좀 더 우수한 C 라이브러리 함수 mkstemp() 등의 C 라이브러리 함수가 있습니다.

tmpfile() 형식의 함수는 "wb+" 플래그가 전달되면(즉, 읽기/쓰기 모드의 이진 파일로 전달되면) 고유한 파일 이름을 생성하고 fopen()과 같은 방식으로 파일을 엽니다. 파일이 이미 있으면, 앞에서 언급한 고유한 파일 이름 선택과 이후의 선택한 파일 열기 사이에 존재하는 경쟁 조건(race condition) 관련 보안 문제를 해결하기 위해 tmpfile()은 크기 0으로 파일을 자릅니다. 하지만 이 동작으로 함수의 보안 문제를 해결하지는 못합니다. 첫째, 공격자는 대체로 tmpfile()이 연 파일이 보유하고 있을 완화된 접근 권한으로 파일을 미리 만들 수 있습니다. 뿐만 아니라, Unix 기반 시스템에서 공격자가 파일을 다른 중요한 파일의 링크로 미리 만드는 경우, 응용 프로그램은 높은 권한을 사용하여 해당 파일을 잘라 공격자 대신 시스템을 손상시킬 수 있습니다. 마지막으로 tmpfile()이 새 파일을 만들게 되면 해당 파일에 적용되는 접근 권한이 운영 체제 별로 다르기 때문에 공격자가 사용할 파일 이름을 미리 예측할 수 없는 경우에도 응용 프로그램 데이터가 취약해질 수 있습니다.

결국 임시 파일을 만드는 안전한 방법은 mkstemp()입니다. 이 함수는 사용자가 제공한 파일 이름 템플릿과 무작위로 생성된 일련의 문자를 기반으로 고유한 파일을 만들고 엽니다. 그런 파일을 만들 수 없는 경우 작업은 실패하고 -1을 반환합니다. 요즘의 시스템에서는 0600 모드를 사용하여 파일을 엽니다. 즉, 파일은 사용자가 접근 권한을 명시적으로 변경하는 경우를 제외하고 외부에서 조작할 수 없습니다. 하지만 mkstemp()도 예측 가능한 파일 이름 사용에서 자유롭지 못하며 공격자가 사용할 파일 이름을 예측하고 미리 만들어 mkstemp()가 실패하게 만들면 응용 프로그램이 denial of service 공격에 취약해질 수 있습니다.
References
[1] B. Schneier Yarrow: A secure pseudorandom number generator
[2] CryptLib
[3] Crypto++
[4] BeeCrypt
[5] OpenSSL
[6] CryptoAPI: CryptGenRandom() Microsoft
[7] RtlGenRandom() Microsoft
[8] .NET System.Security.Cryptography: Random Number Generation Microsoft
[9] Standards Mapping - CIS Azure Kubernetes Service Benchmark 1.0
[10] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 2.0
[11] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 2
[12] Standards Mapping - CIS Google Kubernetes Engine Benchmark confidentiality
[13] Standards Mapping - CIS Kubernetes Benchmark partial
[14] Standards Mapping - Common Weakness Enumeration CWE ID 377
[15] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-001090
[16] Standards Mapping - General Data Protection Regulation (GDPR) Indirect Access to Sensitive Data
[17] Standards Mapping - NIST Special Publication 800-53 Revision 4 SC-4 Information in Shared Resources (P1)
[18] Standards Mapping - NIST Special Publication 800-53 Revision 5 SC-4 Information in Shared System Resources
[19] Standards Mapping - Payment Card Industry Data Security Standard Version 4.0 Requirement 3.3.1, Requirement 3.5.1
[20] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-002380 CAT II
[21] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-002380 CAT II
[22] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-002380 CAT II
[23] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-002380 CAT II
[24] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-002380 CAT II
[25] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-002380 CAT II
[26] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-002380 CAT II
[27] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-002380 CAT II
[28] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-002380 CAT II
[29] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-002380 CAT II
[30] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-002380 CAT II
[31] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-002380 CAT II
[32] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-002380 CAT II
[33] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-002380 CAT II
desc.semantic.cpp.insecure_temporary_file
Abstract
안전하지 않은 임시 파일을 만들어 사용하면 응용 프로그램과 시스템 데이터가 공격에 취약해질 수 있습니다.
Explanation
응용 프로그램이 임시 파일을 너무 자주 필요로 하기 때문에 이를 생성하기 위한 여러 메커니즘이 존재합니다. 이 함수 대부분이 다양한 형태의 공격에 취약합니다.
예제: 다음 코드는 네트워크에서 수집한 중간 데이터를 처리하기 전에 저장하기 위해 임시 파일을 사용합니다.


...
try:
tmp_filename = os.tempnam()
tmp_file = open(tmp_filename, 'w')
data = s.recv(4096)
while True:
more = s.recv(4096)
tmp_file.write(more)
if not more:
break
except socket.timeout:
errMsg = "Connection timed-out while connecting"
self.logger.exception(errMsg)
raise Exception
...


안전하지 않은 방법으로 임시 파일을 만든다는 점 외에는 별다른 특징이 없는 이 코드는 바로 그 점 때문에 수많은 다양한 공격에 취약합니다. 다음 섹션에서 이런 함수들 때문에 생긴 취약점에 대해 설명합니다. 임시 파일 생성과 관련한 가장 심각한 보안 문제는 Unix 기반 운영 체제에서 발생하지만, Windows 응용 프로그램도 같은 위험을 안고 있습니다.

방법과 동작은 시스템마다 다를 수 있지만 각각이 야기하는 근본적인 위험은 대체로 일정합니다. 안전한 코어 언어 함수에 대한 정보 및 안전한 임시 파일 생성 방법에 관한 조언은 권고 사항 섹션을 참조하십시오.

임시 파일 생성을 지원하도록 설계된 함수는 단순히 파일 이름만 제공하는지 또는 실제로 새 파일을 여는지에 따라 두 그룹으로 나눌 수 있습니다.

그룹 1 - "고유한" 파일 이름:

임시 파일 생성 프로세스를 지원하도록 설계된 첫 번째 그룹의 함수는 프로그램이 열 새 임시 파일에 고유한 파일 이름을 만들어 프로세스를 지원합니다. 이 그룹의 함수는 속성 상 선택한 파일 이름에 대한 경쟁 조건(race condition)이 발생합니다. 함수가 파일 이름 선택 시점에 이름이 고유하다는 것은 보장하지만 이름을 선택한 후 응용 프로그램이 파일을 열기 전에 다른 프로세서나 공격자가 같은 이름의 파일을 생성하는 것을 방지하는 메커니즘이 없습니다. 같은 함수의 다른 호출로 인해 발생하는 자연스러운 충돌의 위험 외에도 이들 함수가 생성한 파일 이름이 추측하기 어려울 만큼 무작위성이 보장되지 않기 때문에 공격자가 악의적으로 충돌을 일으킬 수 있습니다.

선택한 이름의 파일이 만들어지면 파일을 여는 방법에 따라 파일의 기존 내용 또는 접근 권한이 그대로 유지될 수 있습니다. 임시 파일의 기존 내용이 악성인 경우, 공격자는 응용 프로그램이 임시 파일에서 데이터를 읽을 때 위험한 데이터를 응용 프로그램에 삽입하게 됩니다. 공격자가 완화된 접근 권한의 임시 파일을 미리 만들게 되면 응용 프로그램이 임시 파일에 저장한 데이터에 접근, 수정 및 손상시킬 수 있습니다. Unix 기반 시스템에서는 공격자가 임시 파일을 다른 중요한 파일의 링크로 미리 만드는 경우 훨씬 심각한 공격이 될 수 있습니다. 이때 응용 프로그램이 임시 파일을 자르거나 임시 파일에 데이터를 쓰는 경우, 모르는 사이에 공격자 대신 시스템을 손상시키는 작업을 수행할 수 있습니다. 이는 프로그램을 높은 권한으로 실행할 때 특히 위험해집니다.

마지막으로 최선의 방법은 os.O_CREATos.O_EXCL 플래그를 사용한 open() 호출을 사용하여 파일을 여는 것입니다. 이 방법은 파일이 이미 있을 때는 파일을 열지 않기 때문에 앞서 설명한 종류의 공격을 예방할 수 있습니다. 하지만 공격자가 임시 파일 이름의 순서를 정확하게 예측할 수 있는 경우 응용 프로그램이 필요한 임시 저장소를 여는 것을 막아 Denial Of Service(DoS) 공격을 일으킬 수 있습니다. 이런 종류의 공격은 이들 함수가 생성하는 파일의 이름 선택에 사용된 무작위성의 수준이 낮은 것을 감안하면 어렵지 않게 실행할 수 있습니다.

그룹 2 - "고유한" 파일:

두 번째 그룹의 함수는 고유한 파일 이름을 생성할 뿐 아니라 파일을 여는 방식으로 일부 임시 파일 관련 보안 문제를 해결하려 합니다. 이 그룹에는 tmpfile()과 같은 함수가 포함됩니다.

tmpfile() 형식의 함수는 "wb+" 플래그가 전달되면(즉, 읽기/쓰기 모드의 이진 파일로 전달되면) 고유한 파일 이름을 생성하고 open()과 같은 방식으로 파일을 엽니다. 파일이 이미 있으면, 앞에서 언급한 고유한 파일 이름 선택과 이후의 선택한 파일 열기 사이에 존재하는 경쟁 조건(race condition) 관련 보안 문제를 해결하기 위해 tmpfile()은 크기 0으로 파일을 자릅니다. 하지만 이 동작으로 함수의 보안 문제를 해결하지는 못합니다. 첫째, 공격자는 대체로 tmpfile()이 연 파일이 보유하고 있을 완화된 접근 권한으로 파일을 미리 만들 수 있습니다. 뿐만 아니라, Unix 기반 시스템에서 공격자가 파일을 다른 중요한 파일의 링크로 미리 만드는 경우, 응용 프로그램은 높은 권한을 사용하여 해당 파일을 잘라 공격자 대신 시스템을 손상시킬 수 있습니다. 마지막으로 tmpfile()이 새 파일을 만들게 되면 해당 파일에 적용되는 접근 권한이 운영 체제 별로 다르기 때문에 공격자가 사용할 파일 이름을 미리 예측할 수 없는 경우에도 응용 프로그램 데이터가 취약해질 수 있습니다.
References
[1] B. Schneier Yarrow: A secure pseudorandom number generator
[2] Python Library Reference: os Python
[3] Python Library Reference: tempfile Python
[4] Symlink race WikiPedia
[5] Time of check to time of use WikiPedia
[6] Standards Mapping - CIS Azure Kubernetes Service Benchmark 1.0
[7] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 2.0
[8] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 2
[9] Standards Mapping - CIS Google Kubernetes Engine Benchmark confidentiality
[10] Standards Mapping - CIS Kubernetes Benchmark partial
[11] Standards Mapping - Common Weakness Enumeration CWE ID 377
[12] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-001090
[13] Standards Mapping - General Data Protection Regulation (GDPR) Indirect Access to Sensitive Data
[14] Standards Mapping - NIST Special Publication 800-53 Revision 4 SC-4 Information in Shared Resources (P1)
[15] Standards Mapping - NIST Special Publication 800-53 Revision 5 SC-4 Information in Shared System Resources
[16] Standards Mapping - Payment Card Industry Data Security Standard Version 4.0 Requirement 3.3.1, Requirement 3.5.1
[17] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-002380 CAT II
[18] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-002380 CAT II
[19] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-002380 CAT II
[20] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-002380 CAT II
[21] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-002380 CAT II
[22] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-002380 CAT II
[23] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-002380 CAT II
[24] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-002380 CAT II
[25] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-002380 CAT II
[26] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-002380 CAT II
[27] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-002380 CAT II
[28] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-002380 CAT II
[29] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-002380 CAT II
[30] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-002380 CAT II
desc.semantic.python.insecure_temporary_file
Abstract
이 메서드는 만료되지 않는 세션을 설정합니다.
Explanation
세션을 더 오래 열어둘수록, 공격자가 사용자 계정을 손상시킬 수 있는 기회는 더 커집니다. 세션이 활성화 상태라면 공격자는 사용자의 암호를 무차별 대입하거나 사용자의 무선 암호화 키를 불법으로 복제하거나 열려 있는 브라우저에서 세션을 제멋대로 쓸 수도 있습니다. 또한 세션 초과 시간이 더 길어지면 메모리가 해제되지 못하도록 하여 결국 충분히 많은 세션이 만들어지는 경우 denial of service가 발생됩니다.

예제 1: 다음 예제의 코드는 최대 비활성 간격을 음수 값으로 설정하여 세션이 무기한으로 활성 상태를 유지하도록 합니다.

...
HttpSession sesssion = request.getSession(true);
sesssion.setMaxInactiveInterval(-1);
...
References
[1] Standards Mapping - CIS Azure Kubernetes Service Benchmark 2.0
[2] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 5.0
[3] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 1
[4] Standards Mapping - CIS Google Kubernetes Engine Benchmark confidentiality
[5] Standards Mapping - CIS Kubernetes Benchmark partial
[6] Standards Mapping - Common Weakness Enumeration CWE ID 613
[7] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-000879, CCI-002361
[8] Standards Mapping - FIPS200 IA
[9] Standards Mapping - NIST Special Publication 800-53 Revision 4 AC-12 Session Termination (P2), MA-4 Nonlocal Maintenance (P2)
[10] Standards Mapping - NIST Special Publication 800-53 Revision 5 AC-12 Session Termination
[11] Standards Mapping - OWASP Top 10 2004 A3 Broken Authentication and Session Management
[12] Standards Mapping - OWASP Top 10 2007 A7 Broken Authentication and Session Management
[13] Standards Mapping - OWASP Top 10 2010 A3 Broken Authentication and Session Management
[14] Standards Mapping - OWASP Top 10 2013 A2 Broken Authentication and Session Management
[15] Standards Mapping - OWASP Top 10 2017 A2 Broken Authentication
[16] Standards Mapping - OWASP Top 10 2021 A07 Identification and Authentication Failures
[17] Standards Mapping - OWASP Application Security Verification Standard 4.0 2.8.1 Single or Multi Factor One Time Verifier Requirements (L1 L2 L3), 2.8.6 Single or Multi Factor One Time Verifier Requirements (L2 L3), 3.3.1 Session Logout and Timeout Requirements (L1 L2 L3), 3.3.2 Session Logout and Timeout Requirements (L1 L2 L3), 3.3.4 Session Logout and Timeout Requirements (L2 L3), 3.6.1 Re-authentication from a Federation or Assertion (L3), 3.6.2 Re-authentication from a Federation or Assertion (L3)
[18] Standards Mapping - OWASP Mobile 2014 M9 Improper Session Handling
[19] Standards Mapping - OWASP Mobile 2024 M3 Insecure Authentication/Authorization
[20] Standards Mapping - Payment Card Industry Data Security Standard Version 1.1 Requirement 6.5.3, Requirement 8.5.15
[21] Standards Mapping - Payment Card Industry Data Security Standard Version 1.2 Requirement 6.5.7, Requirement 8.5.15
[22] Standards Mapping - Payment Card Industry Data Security Standard Version 2.0 Requirement 6.5.8, Requirement 8.5.15
[23] Standards Mapping - Payment Card Industry Data Security Standard Version 3.0 Requirement 6.5.10, Requirement 8.1.8
[24] Standards Mapping - Payment Card Industry Data Security Standard Version 3.1 Requirement 6.5.10, Requirement 8.1.8
[25] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2 Requirement 6.5.10, Requirement 8.1.8
[26] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2.1 Requirement 6.5.10, Requirement 8.1.8
[27] Standards Mapping - Payment Card Industry Data Security Standard Version 4.0 Requirement 6.2.4, Requirement 8.2.8
[28] Standards Mapping - Payment Card Industry Software Security Framework 1.0 Control Objective 4.2 - Critical Asset Protection, Control Objective 5.3 - Authentication and Access Control
[29] Standards Mapping - Payment Card Industry Software Security Framework 1.1 Control Objective 4.2 - Critical Asset Protection, Control Objective 5.3 - Authentication and Access Control
[30] Standards Mapping - Payment Card Industry Software Security Framework 1.2 Control Objective 4.2 - Critical Asset Protection, Control Objective 5.3 - Authentication and Access Control, Control Objective C.2.1.2 - Web Software Access Controls, Control Objective C.2.3.2 - Web Software Access Controls
[31] Standards Mapping - Security Technical Implementation Guide Version 3.1 APP3415 CAT II
[32] Standards Mapping - Security Technical Implementation Guide Version 3.4 APP3415 CAT II
[33] Standards Mapping - Security Technical Implementation Guide Version 3.5 APP3415 CAT II
[34] Standards Mapping - Security Technical Implementation Guide Version 3.6 APP3415 CAT II
[35] Standards Mapping - Security Technical Implementation Guide Version 3.7 APP3415 CAT II
[36] Standards Mapping - Security Technical Implementation Guide Version 3.9 APP3415 CAT II
[37] Standards Mapping - Security Technical Implementation Guide Version 3.10 APP3415 CAT II
[38] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-000070 CAT II, APSC-DV-000080 CAT II, APSC-DV-001980 CAT II
[39] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-000070 CAT II, APSC-DV-000080 CAT II, APSC-DV-001980 CAT II
[40] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-000070 CAT II, APSC-DV-000080 CAT II, APSC-DV-001980 CAT II
[41] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-000070 CAT II, APSC-DV-000080 CAT II, APSC-DV-001980 CAT II
[42] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-000070 CAT II, APSC-DV-000080 CAT II, APSC-DV-001980 CAT II
[43] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-000070 CAT II, APSC-DV-000080 CAT II, APSC-DV-001980 CAT II
[44] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-000070 CAT II, APSC-DV-000080 CAT II, APSC-DV-001980 CAT II
[45] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-000070 CAT II, APSC-DV-000080 CAT II, APSC-DV-001980 CAT II
[46] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-000070 CAT II, APSC-DV-000080 CAT II, APSC-DV-001980 CAT II
[47] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-000070 CAT II, APSC-DV-000080 CAT II, APSC-DV-001980 CAT II
[48] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-000070 CAT II, APSC-DV-000080 CAT II, APSC-DV-001980 CAT II
[49] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-000070 CAT II, APSC-DV-000080 CAT II, APSC-DV-001980 CAT II
[50] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-000070 CAT II, APSC-DV-000080 CAT II, APSC-DV-001980 CAT II
[51] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-000070 CAT II, APSC-DV-000080 CAT II, APSC-DV-001980 CAT II
[52] Standards Mapping - Web Application Security Consortium Version 2.00 Insufficient Session Expiration (WASC-47)
[53] Standards Mapping - Web Application Security Consortium 24 + 2 Insufficient Session Expiration
desc.structural.java.j2ee_bad_practices_insufficient_session_expiration
Abstract
웹 응용 프로그램은 컨테이너를 종료하면 안됩니다.
Explanation
웹 응용 프로그램을 통해 응용 프로그램 컨테이너를 종료하려 하는 것은 좋은 방법이 아닙니다. 종료 메서드 호출은 제거되지 않은 leftover debug code의 일부분이거나 Non-J2EE 응용 프로그램에서 가져온 코드일 것입니다.
References
[1] ERR09-J. Do not allow untrusted code to terminate the JVM CERT
[2] Standards Mapping - CIS Azure Kubernetes Service Benchmark 1.0
[3] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 1.0
[4] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 3
[5] Standards Mapping - CIS Google Kubernetes Engine Benchmark normal
[6] Standards Mapping - Common Weakness Enumeration CWE ID 382
[7] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-001094
[8] Standards Mapping - NIST Special Publication 800-53 Revision 4 SC-5 Denial of Service Protection (P1)
[9] Standards Mapping - NIST Special Publication 800-53 Revision 5 SC-5 Denial of Service Protection
[10] Standards Mapping - OWASP Top 10 2004 A9 Application Denial of Service
[11] Standards Mapping - Payment Card Industry Data Security Standard Version 1.1 Requirement 6.5.9
[12] Standards Mapping - Security Technical Implementation Guide Version 3.1 APP6080 CAT II
[13] Standards Mapping - Security Technical Implementation Guide Version 3.4 APP6080 CAT II
[14] Standards Mapping - Security Technical Implementation Guide Version 3.5 APP6080 CAT II
[15] Standards Mapping - Security Technical Implementation Guide Version 3.6 APP6080 CAT II
[16] Standards Mapping - Security Technical Implementation Guide Version 3.7 APP6080 CAT II
[17] Standards Mapping - Security Technical Implementation Guide Version 3.9 APP6080 CAT II
[18] Standards Mapping - Security Technical Implementation Guide Version 3.10 APP6080 CAT II
[19] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-002400 CAT II
[20] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-002400 CAT II
[21] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-002400 CAT II
[22] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-002400 CAT II
[23] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-002400 CAT II
[24] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-002400 CAT II
[25] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-002400 CAT II
[26] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-002400 CAT II
[27] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-002400 CAT II
[28] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-002400 CAT II
[29] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-002400 CAT II
[30] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-002400 CAT II
[31] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-002400 CAT II
[32] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-002400 CAT II
[33] Standards Mapping - Web Application Security Consortium Version 2.00 Denial of Service (WASC-10)
[34] Standards Mapping - Web Application Security Consortium 24 + 2 Denial of Service
desc.semantic.java.j2ee_badpractices_jvm_termination
Abstract
non-serializable 개체를 HttpSession 속성으로 저장하면 응용 프로그램 안정성을 해칠 수 있습니다.
Explanation
J2EE 응용 프로그램은 여러 JVM을 이용하여 응용 프로그램 안정성과 성능을 개선합니다. 최종 사용자에게 여러 JVM을 하나의 응용 프로그램으로 보이게 하기 위해, J2EE 컨테이너는 여러 JVM에 HttpSession 개체를 복제하여 한 JVM을 사용할 수 없게 되면 다른 JVM이 개입하여 역할을 대신하기 때문에 응용 프로그램의 흐름이 중단되지 않습니다.

세션 복제가 제대로 동작하려면 응용 프로그램이 세션에 속성으로 저장한 값이 Serializable 인터페이스를 구현해야 합니다.

예제 1: 다음 클래스는 자신을 세션에 추가하지만 serializable 상태가 아니므로 세션을 더 이상 복제할 수 없습니다.


public class DataGlob {
String globName;
String globValue;

public void addToSession(HttpSession session) {
session.setAttribute("glob", this);
}
}
References
[1] The Java Servlet Specification Sun Microsystems
[2] The java.io.Serializable Interface Oracle
[3] MSC08-J. Do not store non-serializable objects as attributes in an HTTP session CERT
[4] Standards Mapping - CIS Azure Kubernetes Service Benchmark 1.0
[5] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 4.1
[6] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 2
[7] Standards Mapping - CIS Google Kubernetes Engine Benchmark normal
[8] Standards Mapping - Common Weakness Enumeration CWE ID 579
[9] Standards Mapping - OWASP Top 10 2004 A3 Broken Authentication and Session Management
[10] Standards Mapping - OWASP Top 10 2007 A7 Broken Authentication and Session Management
[11] Standards Mapping - OWASP Top 10 2010 A3 Broken Authentication and Session Management
[12] Standards Mapping - OWASP Top 10 2013 A2 Broken Authentication and Session Management
[13] Standards Mapping - OWASP Top 10 2017 A2 Broken Authentication
[14] Standards Mapping - OWASP Top 10 2021 A07 Identification and Authentication Failures
[15] Standards Mapping - OWASP Mobile 2014 M1 Weak Server Side Controls
[16] Standards Mapping - Payment Card Industry Data Security Standard Version 1.1 Requirement 6.5.3
[17] Standards Mapping - Payment Card Industry Data Security Standard Version 1.2 Requirement 6.5.7
[18] Standards Mapping - Payment Card Industry Data Security Standard Version 2.0 Requirement 6.5.8
[19] Standards Mapping - Payment Card Industry Data Security Standard Version 3.0 Requirement 6.5.10
[20] Standards Mapping - Payment Card Industry Data Security Standard Version 3.1 Requirement 6.5.10
[21] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2 Requirement 6.5.10
[22] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2.1 Requirement 6.5.10
[23] Standards Mapping - Payment Card Industry Data Security Standard Version 4.0 Requirement 6.2.4
[24] Standards Mapping - Payment Card Industry Software Security Framework 1.0 Control Objective 4.2 - Critical Asset Protection
[25] Standards Mapping - Payment Card Industry Software Security Framework 1.1 Control Objective 4.2 - Critical Asset Protection
[26] Standards Mapping - Payment Card Industry Software Security Framework 1.2 Control Objective 4.2 - Critical Asset Protection
desc.structural.java.j2ee_bad_practices_non_serializable_object_stored_in_session
Abstract
경우에 따라 웹 응용 프로그램의 스레드 관리가 금지되어 오류가 발생할 가능성이 항상 높습니다.
Explanation
J2EE 표준은 일부 경우에 웹 응용 프로그램의 스레드 관리를 금지하는데 스레드 관리는 항상 오류 발생 가능성이 높습니다. 스레드 관리는 어려운 작업이고 예상치 못한 방식으로 응용 프로그램 컨테이너의 동작을 방해할 가능성이 큽니다. 컨테이너를 방해하지 않는 경우에도, 스레드 관리는 보통 발견하기 어렵고 교착 상태, 경쟁 조건(race condition), 및 기타 동기화 오류 등으로 진단되는 버그를 일으킵니다.
References
[1] Java 2 Platform Enterprise Edition Specification, v1.4 Sun Microsystems
[2] Standards Mapping - CIS Azure Kubernetes Service Benchmark 1.0
[3] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 3.0
[4] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 5
[5] Standards Mapping - CIS Google Kubernetes Engine Benchmark normal
[6] Standards Mapping - Common Weakness Enumeration CWE ID 383
[7] Standards Mapping - OWASP API 2023 API8 Security Misconfiguration
desc.semantic.java.j2ee_badpractices_threads
Abstract
함수가 시간의 프록시로 block.timestamp 또는 block.number를 사용합니다.
Explanation
개발자는 흔히 block.timestamp 또는 block.number에 연결된 값을 사용해 시간 종속 이벤트를 트리거합니다. 그런데 이러한 값은 대개 사용하기에 안전하지 않은 시간 정보를 제공하는 경우가 많습니다.

블록체인은 분산형 기술이므로 노드는 시간을 특정 수준까지만 동기화할 수 있습니다. block.timestamp를 사용하는 코드는 신뢰하기가 어려울 수 있으며 최악의 경우에는 악의적인 채굴자가 블록의 타임스탬프를 채굴에 유리하게 변경할 수도 있습니다.

block.number 사용 시에는 블록 간 시간(약 14초) 예측은 가능하지만 블록 시간이 일정하게 유지되지 않으며 네트워크 활동에 따라 달라질 수도 있습니다. 그러므로 block.number는 시간 관련 계산에서 안전하게 사용할 수 없습니다.

예제 1: 다음 코드는 block.number를 사용하여 일정 기간이 지난 후 자금을 잠금 해제합니다.


function withdraw() public {
require(users[msg.sender].amount > 0, 'no amount locked');
require(block.number >= users[msg.sender].unlockBlock, 'lock period not over');
uint amount = users[msg.sender].amount;
users[msg.sender].amount = 0;
(bool success, ) = msg.sender.call.value(amount)("");
require(success, 'transfer failed');
}
References
[1] Enterprise Ethereum Alliance Don't misuse block data
[2] Standards Mapping - CIS Azure Kubernetes Service Benchmark 2.0
[3] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 2.0
[4] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 3
[5] Standards Mapping - CIS Google Kubernetes Engine Benchmark normal
[6] Standards Mapping - Smart Contract Weakness Classification SWC-116
desc.structural.solidity.swc116
Abstract
이러한 콜백이 설정되면 race condition이 발생할 수 있습니다.
Explanation
개발자는 Node.js를 사용하여 IO 차단 이벤트에 콜백을 할당할 수 있습니다. 콜백은 비동기로 실행되므로 기본 응용 프로그램이 IO에 의해 차단되지 않기 때문에 이렇게 하면 성능이 개선됩니다. 그러나 콜백 외부의 항목을 실행하려면 콜백 내의 코드가 먼저 실행되어야 하는 경우에는 race condition이 발생할 수 있습니다.

예제 1: 다음 코드에서는 authentication을 위해 데이터베이스를 기준으로 사용자를 확인합니다.

 
...
var authenticated = true;
...
database_connect.query('SELECT * FROM users WHERE name == ? AND password = ? LIMIT 1', userNameFromUser, passwordFromUser, function(err, results){
if (!err && results.length > 0){
authenticated = true;
}else{
authenticated = false;
}
});

if (authenticated){
//do something privileged stuff
authenticatedActions();
}else{
sendUnathenticatedMessage();
}


이 예제에서는 로그인용 사용자 자격 증명을 확인하기 위해 백엔드 데이터베이스를 호출하며, 자격 증명이 확인되면 변수를 true로 설정하고 확인되지 않으면 false로 설정합니다. 하지만 콜백은 IO에 의해 차단되므로 비동기로 실행되며 if (authenticated) 확인 후에 실행될 수 있습니다. 기본값은 true이기 때문에 사용자가 실제로 인증되었는지 여부와 관계없이 if 문이 실행됩니다.
References
[1] Kristopher Kowal Documentation for q
[2] Piotr Pelczar Asynchronous programming done right.
[3] Standards Mapping - CIS Azure Kubernetes Service Benchmark 1.0
[4] Standards Mapping - CIS Microsoft Azure Foundations Benchmark complete
[5] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 2.0
[6] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 4
[7] Standards Mapping - CIS Google Kubernetes Engine Benchmark integrity
[8] Standards Mapping - CIS Kubernetes Benchmark partial
[9] Standards Mapping - Common Weakness Enumeration CWE ID 362, CWE ID 367
[10] Standards Mapping - Common Weakness Enumeration Top 25 2022 [22] CWE ID 362
[11] Standards Mapping - Common Weakness Enumeration Top 25 2023 [21] CWE ID 362
[12] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-000366, CCI-003178
[13] Standards Mapping - General Data Protection Regulation (GDPR) Indirect Access to Sensitive Data
[14] Standards Mapping - NIST Special Publication 800-53 Revision 4 CM-6 Configuration Settings (P1)
[15] Standards Mapping - NIST Special Publication 800-53 Revision 5 CM-6 Configuration Settings
[16] Standards Mapping - OWASP Top 10 2021 A04 Insecure Design
[17] Standards Mapping - OWASP Application Security Verification Standard 4.0 1.11.2 Business Logic Architectural Requirements (L2 L3), 1.11.3 Business Logic Architectural Requirements (L3), 1.11.2 Business Logic Architectural Requirements (L2 L3), 1.11.3 Business Logic Architectural Requirements (L3), 11.1.6 Business Logic Security Requirements (L2 L3)
[18] Standards Mapping - Payment Card Industry Data Security Standard Version 3.0 Requirement 6.5.6
[19] Standards Mapping - Payment Card Industry Data Security Standard Version 3.1 Requirement 6.5.6
[20] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2 Requirement 6.5.6
[21] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2.1 Requirement 6.5.6
[22] Standards Mapping - Payment Card Industry Data Security Standard Version 4.0 Requirement 6.2.4
[23] Standards Mapping - Payment Card Industry Software Security Framework 1.0 Control Objective 4.2 - Critical Asset Protection
[24] Standards Mapping - Payment Card Industry Software Security Framework 1.1 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.3 - Terminal Software Attack Mitigation
[25] Standards Mapping - Payment Card Industry Software Security Framework 1.2 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.3 - Terminal Software Attack Mitigation
[26] Standards Mapping - SANS Top 25 2009 Insecure Interaction - CWE ID 362
[27] Standards Mapping - SANS Top 25 2010 Insecure Interaction - CWE ID 362
[28] Standards Mapping - Security Technical Implementation Guide Version 3.1 APP3630.1 CAT II
[29] Standards Mapping - Security Technical Implementation Guide Version 3.4 APP3630.1 CAT II
[30] Standards Mapping - Security Technical Implementation Guide Version 3.5 APP3630.1 CAT II
[31] Standards Mapping - Security Technical Implementation Guide Version 3.6 APP3630.1 CAT II
[32] Standards Mapping - Security Technical Implementation Guide Version 3.7 APP3630.1 CAT II
[33] Standards Mapping - Security Technical Implementation Guide Version 3.9 APP3630.1 CAT II
[34] Standards Mapping - Security Technical Implementation Guide Version 3.10 APP3630.1 CAT II
[35] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-001995 CAT II
[36] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-001995 CAT II
[37] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-001995 CAT II
[38] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-001995 CAT II
[39] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-001995 CAT II
[40] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-001995 CAT II
[41] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-001995 CAT II
[42] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-001995 CAT II
[43] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-001995 CAT II
[44] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-001995 CAT II
[45] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-001995 CAT II
[46] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-001995 CAT II
[47] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-001995 CAT II
[48] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-001995 CAT II
desc.structural.javascript.race_condition
Abstract
응용 프로그램이 공유 저장소에서 응용 프로그램을 설치하며, 이로 인해 설치되어야 할 패키지를 악성 응용 프로그램이 대체할 수 있습니다.
Explanation
응용 프로그램이 외부 저장소 읽기/쓰기 권한이 있는 모든 응용 프로그램이 쓸 수 있는 공유 저장소에서 응용 프로그램을 설치합니다. 경쟁 조건(Race Condition) 때문에 해당 폴더를 모니터링하는 악성 응용 프로그램이 다운로드된 APK 파일을 다른 APK 파일로 바꿀 수 있으며, 이 경우 설치 프로세스에서 올바른 업데이트 대신 바뀐 파일을 사용하게 됩니다.

예제 1: 다음 코드는 공유 저장소에서 응용 프로그램을 설치합니다.


Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory() + "/download/" + "app.apk")), "application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
References
[1] Standards Mapping - CIS Azure Kubernetes Service Benchmark 1.0
[2] Standards Mapping - CIS Microsoft Azure Foundations Benchmark complete
[3] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 2.0
[4] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 4
[5] Standards Mapping - CIS Google Kubernetes Engine Benchmark integrity
[6] Standards Mapping - CIS Kubernetes Benchmark partial
[7] Standards Mapping - Common Weakness Enumeration CWE ID 362, CWE ID 367
[8] Standards Mapping - Common Weakness Enumeration Top 25 2022 [22] CWE ID 362
[9] Standards Mapping - Common Weakness Enumeration Top 25 2023 [21] CWE ID 362
[10] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-000366, CCI-003178
[11] Standards Mapping - General Data Protection Regulation (GDPR) Indirect Access to Sensitive Data
[12] Standards Mapping - Motor Industry Software Reliability Association (MISRA) C Guidelines 2012 Rule 1.3
[13] Standards Mapping - NIST Special Publication 800-53 Revision 4 CM-6 Configuration Settings (P1)
[14] Standards Mapping - NIST Special Publication 800-53 Revision 5 CM-6 Configuration Settings
[15] Standards Mapping - OWASP Top 10 2021 A04 Insecure Design
[16] Standards Mapping - OWASP Application Security Verification Standard 4.0 1.11.2 Business Logic Architectural Requirements (L2 L3), 1.11.3 Business Logic Architectural Requirements (L3), 11.1.6 Business Logic Security Requirements (L2 L3)
[17] Standards Mapping - OWASP Mobile Application Security Verification Standard 2.0 MASVS-RESILIENCE-2
[18] Standards Mapping - Payment Card Industry Data Security Standard Version 3.0 Requirement 6.5.6
[19] Standards Mapping - Payment Card Industry Data Security Standard Version 3.1 Requirement 6.5.6
[20] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2 Requirement 6.5.6
[21] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2.1 Requirement 6.5.6
[22] Standards Mapping - Payment Card Industry Data Security Standard Version 4.0 Requirement 6.2.4
[23] Standards Mapping - Payment Card Industry Software Security Framework 1.0 Control Objective 4.2 - Critical Asset Protection
[24] Standards Mapping - Payment Card Industry Software Security Framework 1.1 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.3 - Terminal Software Attack Mitigation
[25] Standards Mapping - Payment Card Industry Software Security Framework 1.2 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.3 - Terminal Software Attack Mitigation
[26] Standards Mapping - SANS Top 25 2009 Insecure Interaction - CWE ID 362
[27] Standards Mapping - SANS Top 25 2010 Insecure Interaction - CWE ID 362
[28] Standards Mapping - Security Technical Implementation Guide Version 3.1 APP3630.1 CAT II
[29] Standards Mapping - Security Technical Implementation Guide Version 3.4 APP3630.1 CAT II
[30] Standards Mapping - Security Technical Implementation Guide Version 3.5 APP3630.1 CAT II
[31] Standards Mapping - Security Technical Implementation Guide Version 3.6 APP3630.1 CAT II
[32] Standards Mapping - Security Technical Implementation Guide Version 3.7 APP3630.1 CAT II
[33] Standards Mapping - Security Technical Implementation Guide Version 3.9 APP3630.1 CAT II
[34] Standards Mapping - Security Technical Implementation Guide Version 3.10 APP3630.1 CAT II
[35] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-001995 CAT II
[36] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-001995 CAT II
[37] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-001995 CAT II
[38] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-001995 CAT II
[39] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-001995 CAT II
[40] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-001995 CAT II
[41] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-001995 CAT II
[42] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-001995 CAT II
[43] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-001995 CAT II
[44] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-001995 CAT II
[45] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-001995 CAT II
[46] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-001995 CAT II
[47] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-001995 CAT II
[48] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-001995 CAT II
desc.dataflow.java.race_condition_app_download
Abstract
파일 속성을 검사하는 시점과 파일을 사용하는 시점 사이의 간격이 권한 상승 공격을 실행하기 위해 익스플로이트될 수 있습니다.
Explanation
검사 시점/사용 시점(TOCTOU) 경쟁 조건(race condition)이라고 하는 파일 접근은 다음 경우에 발생합니다.

1. 프로그램이 이름으로 파일을 참조하여 파일 속성을 검사합니다.

2. 프로그램이 나중에 동일한 파일 이름을 사용하여 파일 시스템 작업을 수행하며 이전에 검사한 속성이 변경되지 않았다고 가정합니다.
예제 1: 다음 코드는 프로그램이 설치한 setuid root에서 가져온 것입니다. 이 프로그램은 권한 없는 사용자를 대신하여 특정 파일 작업을 수행하고 액세스 검사를 사용하여 현재 사용자가 사용해서는 안 되는 작업을 수행하는 데 루트 권한을 사용하지 못하도록 합니다. 이 프로그램은 파일을 열고 필요한 작업을 수행하기 전에 access() 시스템 호출을 사용하여 프로그램을 실행하는 사람이 지정된 파일에 액세스할 수 있는 권한을 가지고 있는지 확인합니다.


if (!access(file,W_OK)) {
f = fopen(file,"w+");
operate(f);
...
}
else {
fprintf(stderr,"Unable to open file %s.\n",file);
}
access() 호출은 예상대로 동작하고 프로그램을 실행하는 사용자가 파일 쓰기 권한을 가지고 있으면 0을, 그렇지 않으면 -1을 반환합니다. 하지만 access()fopen() 모두 파일 핸들이 아닌 파일 이름에 대해 동작하기 때문에 file 변수가 fopen()에 전달될 때 access()에 전달되었을 때와 같은 디스크상의 파일을 참조한다고 보장할 수 없습니다. 공격자가 access() 호출 후 file을 다른 파일에 대한 심볼 링크로 교체하면 프로그램은 파일이 공격자가 수정할 수 없는 파일인 경우에도 해당 파일에 루트 권한을 사용하여 작업합니다. 공격자는 프로그램을 속여 수행할 권한이 없는 작업을 수행하게 함으로써 높은 권한을 얻는 것입니다.

이런 종류의 취약점은 root 권한이 있는 프로그램에만 국한되는 것은 아닙니다. 공격자가 수행할 수 없는 작업을 수행할 수 있는 응용 프로그램이라면 모두 공격의 대상이 될 수 있습니다.

이러한 공격에 취약한 시간은 속성이 테스트된 시점부터 파일이 사용될 시점까지의 기간입니다. 확인 직후에 사용하더라도 최신 운영 체제에서는 프로세스가 CPU를 더 이상 사용하지 않을 때까지 얼마만큼의 코드 양이 실행될 것인지를 알 수 없습니다. 공격자는 익스플로이트를 더 쉽게 이용하기 위해 기회의 시간을 늘릴 수 있는 다양한 기술을 보유하고 있습니다. 하지만 짧은 기간 안에도 성공할 때까지 익스플로이트 시도를 단순히 계속 반복할 수 있습니다.

예제 2: 다음 코드는 파일을 생성한 후 파일 소유자를 변경합니다.


fd = creat(FILE, 0644); /* Create file */
if (fd == -1)
return;
if (chown(FILE, UID, -1) < 0) { /* Change file owner */
...
}


코드는 chown() 호출 시 작동되는 파일이 creat() 호출 시 생성되는 파일과 같다고 가정하지만 반드시 그런 것은 아닙니다. chown()은 파일 핸들이 아닌 파일 이름에 대해 작동하므로 공격자가 자신이 소유하지 않은 파일의 링크로 파일을 대체할 수 있습니다. 그러면 공격자가 chown() 호출 시 연결된 파일의 소유권을 얻게 됩니다.
References
[1] J. Viega, G. McGraw Building Secure Software Addison-Wesley
[2] Standards Mapping - CIS Azure Kubernetes Service Benchmark 1.0
[3] Standards Mapping - CIS Microsoft Azure Foundations Benchmark complete
[4] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 2.0
[5] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 4
[6] Standards Mapping - CIS Google Kubernetes Engine Benchmark integrity
[7] Standards Mapping - CIS Kubernetes Benchmark partial
[8] Standards Mapping - Common Weakness Enumeration CWE ID 362, CWE ID 367
[9] Standards Mapping - Common Weakness Enumeration Top 25 2022 [22] CWE ID 362
[10] Standards Mapping - Common Weakness Enumeration Top 25 2023 [21] CWE ID 362
[11] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-000366, CCI-003178
[12] Standards Mapping - General Data Protection Regulation (GDPR) Access Violation
[13] Standards Mapping - Motor Industry Software Reliability Association (MISRA) C Guidelines 2012 Rule 1.3
[14] Standards Mapping - NIST Special Publication 800-53 Revision 4 CM-5 Access Restrictions for Change (P1), CM-6 Configuration Settings (P1)
[15] Standards Mapping - NIST Special Publication 800-53 Revision 5 CM-5 Access Restrictions for Change, CM-6 Configuration Settings
[16] Standards Mapping - OWASP Top 10 2021 A04 Insecure Design
[17] Standards Mapping - OWASP Application Security Verification Standard 4.0 1.11.2 Business Logic Architectural Requirements (L2 L3), 1.11.3 Business Logic Architectural Requirements (L3), 11.1.6 Business Logic Security Requirements (L2 L3)
[18] Standards Mapping - Payment Card Industry Data Security Standard Version 3.0 Requirement 6.5.6
[19] Standards Mapping - Payment Card Industry Data Security Standard Version 3.1 Requirement 6.5.6
[20] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2 Requirement 6.5.6
[21] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2.1 Requirement 6.5.6
[22] Standards Mapping - Payment Card Industry Data Security Standard Version 4.0 Requirement 6.2.4
[23] Standards Mapping - Payment Card Industry Software Security Framework 1.0 Control Objective 4.2 - Critical Asset Protection
[24] Standards Mapping - Payment Card Industry Software Security Framework 1.1 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.3 - Terminal Software Attack Mitigation
[25] Standards Mapping - Payment Card Industry Software Security Framework 1.2 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.3 - Terminal Software Attack Mitigation
[26] Standards Mapping - SANS Top 25 2009 Insecure Interaction - CWE ID 362
[27] Standards Mapping - SANS Top 25 2010 Insecure Interaction - CWE ID 362
[28] Standards Mapping - Security Technical Implementation Guide Version 3.1 APP3630.1 CAT II
[29] Standards Mapping - Security Technical Implementation Guide Version 3.4 APP3630.1 CAT II
[30] Standards Mapping - Security Technical Implementation Guide Version 3.5 APP3630.1 CAT II
[31] Standards Mapping - Security Technical Implementation Guide Version 3.6 APP3630.1 CAT II
[32] Standards Mapping - Security Technical Implementation Guide Version 3.7 APP3630.1 CAT II
[33] Standards Mapping - Security Technical Implementation Guide Version 3.9 APP3630.1 CAT II
[34] Standards Mapping - Security Technical Implementation Guide Version 3.10 APP3630.1 CAT II
[35] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-001995 CAT II
[36] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-001995 CAT II
[37] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-001995 CAT II
[38] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-001995 CAT II
[39] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-001995 CAT II
[40] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-001995 CAT II
[41] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-001995 CAT II
[42] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-001995 CAT II
[43] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-001995 CAT II
[44] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-001995 CAT II
[45] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-001995 CAT II
[46] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-001995 CAT II
[47] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-001995 CAT II
[48] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-001410 CAT II, APSC-DV-001995 CAT II
desc.controlflow.cpp.file_access_race_condition
Abstract
파일 속성이 확인되는 시점과 파일이 사용되는 시점 사이의 시간을 악용하여 권한 에스컬레이션 공격을 시작할 수 있습니다.
Explanation
TOCTOU(Time-Of-Check, Time-Of-Use)라고 알려진 파일 액세스 경합 상태는 다음과 같은 경우에 발생합니다.

1. 프로그램이 파일을 이름으로 참조하여 파일의 속성을 검사합니다.

2. 프로그램이 나중에 동일한 파일 이름을 사용하여 파일 시스템 작업을 수행하며 이전에 검사한 속성이 변경되지 않았다고 가정합니다.
예제: 다음 프로그램은 파일을 만들고 필요한 작업을 수행하기 전에 CBL_CHECK_FILE_EXIST 루틴을 호출하여 파일이 존재하는지 확인합니다.


CALL "CBL_CHECK_FILE_EXIST" USING
filename
file-details
RETURNING status-code
END-CALL

IF status-code NOT = 0
MOVE 3 to access-mode
MOVE 0 to deny-mode
MOVE 0 to device

CALL "CBL_CREATE_FILE" USING
filename
access-mode
deny-mode
device
file-handle
RETURNING status-code
END-CALL
END-IF
CBL_CHECK_FILE_EXIST 호출이 예상대로 작동하고 0이 아닌 값을 반환합니다. 이는 파일이 없음을 나타냅니다. 하지만 CBL_CHECK_FILE_EXISTCBL_CREATE_FILE은 모두 파일 핸들 대신 파일 이름을 사용하여 작업하기 때문에 filename 변수가 CBL_CHECK_FILE_EXIST에 전달되었을 때 참조하던 파일과 CBL_CREATE_FILE에 전달될 때 참조하는 파일이 여전히 동일한 것이라는 보장이 없습니다. 공격자가 CBL_CHECK_FILE_EXIST 호출 이후에 filename을 만들 경우, CBL_CREATE_FILE 호출은 실패하며 프로그램은 파일이 비어 있다고 믿게 됩니다. 실제로는 공격자가 제어하는 데이터가 파일 안에 들어 있습니다.

이러한 공격에 취약한 시간은 속성이 테스트된 시점부터 파일이 사용될 시점까지의 기간입니다. 확인 직후에 사용하더라도 최신 운영 체제에서는 프로세스가 CPU를 더 이상 사용하지 않을 때까지 얼마만큼의 코드 양이 실행될 것인지를 알 수 없습니다. 공격자는 익스플로이트를 더 쉽게 이용하기 위해 기회의 시간을 늘릴 수 있는 다양한 기술을 보유하고 있습니다. 하지만 짧은 기간 안에도 성공할 때까지 익스플로이트 시도를 단순히 계속 반복할 수 있습니다.

또한 이 유형의 취약점은 권한 없는 사용자를 대신하여 특정 파일 작업을 수행하고 액세스 검사를 사용하여 현재 사용자가 사용해서는 안 되는 작업을 수행하는 데 루트 권한을 사용하지 못하도록 하는 root 권한이 있는 프로그램에 적용될 수 있습니다. 허용되지 않는 작업을 수행하도록 프로그램을 속이면 공격자가 승격된 권한을 얻을 수 있습니다.
References
[1] J. Viega, G. McGraw Building Secure Software Addison-Wesley
[2] Standards Mapping - CIS Azure Kubernetes Service Benchmark 1.0
[3] Standards Mapping - CIS Microsoft Azure Foundations Benchmark complete
[4] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 2.0
[5] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 4
[6] Standards Mapping - CIS Google Kubernetes Engine Benchmark integrity
[7] Standards Mapping - CIS Kubernetes Benchmark partial
[8] Standards Mapping - Common Weakness Enumeration CWE ID 362, CWE ID 367
[9] Standards Mapping - Common Weakness Enumeration Top 25 2022 [22] CWE ID 362
[10] Standards Mapping - Common Weakness Enumeration Top 25 2023 [21] CWE ID 362
[11] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-000366, CCI-003178
[12] Standards Mapping - General Data Protection Regulation (GDPR) Access Violation
[13] Standards Mapping - Motor Industry Software Reliability Association (MISRA) C Guidelines 2012 Rule 1.3
[14] Standards Mapping - NIST Special Publication 800-53 Revision 4 CM-5 Access Restrictions for Change (P1), CM-6 Configuration Settings (P1)
[15] Standards Mapping - NIST Special Publication 800-53 Revision 5 CM-5 Access Restrictions for Change, CM-6 Configuration Settings
[16] Standards Mapping - OWASP Top 10 2021 A04 Insecure Design
[17] Standards Mapping - OWASP Application Security Verification Standard 4.0 1.11.2 Business Logic Architectural Requirements (L2 L3), 1.11.3 Business Logic Architectural Requirements (L3), 11.1.6 Business Logic Security Requirements (L2 L3)
[18] Standards Mapping - Payment Card Industry Data Security Standard Version 3.0 Requirement 6.5.6
[19] Standards Mapping - Payment Card Industry Data Security Standard Version 3.1 Requirement 6.5.6
[20] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2 Requirement 6.5.6
[21] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2.1 Requirement 6.5.6
[22] Standards Mapping - Payment Card Industry Data Security Standard Version 4.0 Requirement 6.2.4
[23] Standards Mapping - Payment Card Industry Software Security Framework 1.0 Control Objective 4.2 - Critical Asset Protection
[24] Standards Mapping - Payment Card Industry Software Security Framework 1.1 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.3 - Terminal Software Attack Mitigation
[25] Standards Mapping - Payment Card Industry Software Security Framework 1.2 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.3 - Terminal Software Attack Mitigation
[26] Standards Mapping - SANS Top 25 2009 Insecure Interaction - CWE ID 362
[27] Standards Mapping - SANS Top 25 2010 Insecure Interaction - CWE ID 362
[28] Standards Mapping - Security Technical Implementation Guide Version 3.1 APP3630.1 CAT II
[29] Standards Mapping - Security Technical Implementation Guide Version 3.4 APP3630.1 CAT II
[30] Standards Mapping - Security Technical Implementation Guide Version 3.5 APP3630.1 CAT II
[31] Standards Mapping - Security Technical Implementation Guide Version 3.6 APP3630.1 CAT II
[32] Standards Mapping - Security Technical Implementation Guide Version 3.7 APP3630.1 CAT II
[33] Standards Mapping - Security Technical Implementation Guide Version 3.9 APP3630.1 CAT II
[34] Standards Mapping - Security Technical Implementation Guide Version 3.10 APP3630.1 CAT II
[35] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-001995 CAT II
[36] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-001995 CAT II
[37] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-001995 CAT II
[38] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-001995 CAT II
[39] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-001995 CAT II
[40] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-001995 CAT II
[41] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-001995 CAT II
[42] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-001995 CAT II
[43] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-001995 CAT II
[44] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-001995 CAT II
[45] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-001995 CAT II
[46] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-001995 CAT II
[47] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-001995 CAT II
[48] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-001410 CAT II, APSC-DV-001995 CAT II
desc.controlflow.cobol.file_access_race_condition
Abstract
java.text.Formatparse()format() 메서드에는 설계 결함이 있어서 한 사용자가 다른 사용자의 데이터를 볼 수 있습니다.
Explanation
java.text.Formatparse()format() 메서드에는 race condition이 있어서 한 사용자가 다른 사용자의 데이터를 볼 수 있습니다.

예제 1: 다음 코드는 이 설계 결함을 밝혀내는 방법을 보여줍니다.


public class Common {

private static SimpleDateFormat dateFormat;
...

public String format(Date date) {
return dateFormat.format(date);
}
...

final OtherClass dateFormatAccess=new OtherClass();
...

public void function_running_in_thread1(){
System.out.println("Time in thread 1 should be 12/31/69 4:00 PM, found: "+ dateFormatAccess.format(new Date(0)));
}

public void function_running_in_thread2(){
System.out.println("Time in thread 2 should be around 12/29/09 6:26 AM, found: "+ dateFormatAccess.format(new Date(System.currentTimeMillis())));
}
}


이 코드는 단일 사용자 환경에서는 올바르게 동작하지만, 스레드 두 개가 동시에 이 코드를 실행하면 다음과 같은 출력이 생성될 수 있습니다.

Time in thread 1 should be 12/31/69 4:00 PM, found: 12/31/69 4:00 PM
Time in thread 2 should be around 12/29/09 6:26 AM, found: 12/31/69 4:00 PM

이 경우, format() 구현의 race condition으로 인해 첫 번째 스레드의 데이터가 두 번째 스레드의 출력에 표시됩니다.
References
[1] Bug 4228335 : SimpleDateFormat is not threadsafe Sun Microsystems
[2] The Java Servlet Specification Sun Microsystems
[3] Standards Mapping - CIS Azure Kubernetes Service Benchmark 2.0
[4] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 5.0
[5] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 5
[6] Standards Mapping - CIS Google Kubernetes Engine Benchmark confidentiality
[7] Standards Mapping - CIS Kubernetes Benchmark partial
[8] Standards Mapping - Common Weakness Enumeration CWE ID 362, CWE ID 488
[9] Standards Mapping - Common Weakness Enumeration Top 25 2022 [22] CWE ID 362
[10] Standards Mapping - Common Weakness Enumeration Top 25 2023 [21] CWE ID 362
[11] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-001090, CCI-003178
[12] Standards Mapping - General Data Protection Regulation (GDPR) Access Violation
[13] Standards Mapping - NIST Special Publication 800-53 Revision 4 CM-6 Configuration Settings (P1), SC-4 Information in Shared Resources (P1)
[14] Standards Mapping - NIST Special Publication 800-53 Revision 5 CM-6 Configuration Settings, SC-4 Information in Shared System Resources
[15] Standards Mapping - OWASP Top 10 2007 A6 Information Leakage and Improper Error Handling
[16] Standards Mapping - OWASP Top 10 2021 A04 Insecure Design
[17] Standards Mapping - OWASP Application Security Verification Standard 4.0 1.11.2 Business Logic Architectural Requirements (L2 L3)
[18] Standards Mapping - Payment Card Industry Data Security Standard Version 1.2 Requirement 6.5.6
[19] Standards Mapping - Payment Card Industry Data Security Standard Version 2.0 Requirement 6.5.5
[20] Standards Mapping - Payment Card Industry Data Security Standard Version 4.0 Requirement 6.2.4, Requirement 7.3.2
[21] Standards Mapping - Payment Card Industry Software Security Framework 1.1 Control Objective B.3.3 - Terminal Software Attack Mitigation
[22] Standards Mapping - Payment Card Industry Software Security Framework 1.2 Control Objective B.3.3 - Terminal Software Attack Mitigation
[23] Standards Mapping - SANS Top 25 2009 Insecure Interaction - CWE ID 362
[24] Standards Mapping - SANS Top 25 2010 Insecure Interaction - CWE ID 362
[25] Standards Mapping - Security Technical Implementation Guide Version 3.1 APP3630.1 CAT II
[26] Standards Mapping - Security Technical Implementation Guide Version 3.4 APP3630.1 CAT II
[27] Standards Mapping - Security Technical Implementation Guide Version 3.5 APP3630.1 CAT II
[28] Standards Mapping - Security Technical Implementation Guide Version 3.6 APP3630.1 CAT II
[29] Standards Mapping - Security Technical Implementation Guide Version 3.7 APP3630.1 CAT II
[30] Standards Mapping - Security Technical Implementation Guide Version 3.9 APP3630.1 CAT II
[31] Standards Mapping - Security Technical Implementation Guide Version 3.10 APP3630.1 CAT II
[32] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[33] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[34] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[35] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[36] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[37] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[38] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[39] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[40] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[41] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[42] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[43] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[44] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[45] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
desc.structural.java.race_condition_format_flaw
Abstract
개발자는 Windows.Storage.ApplicationData 클래스의 RoamingFolder 또는 RoamingSettings 속성을 사용하고 있습니다.
Explanation
RoamingFolderRoamingSettings 속성은 로밍 응용 프로그램 데이터 저장소에서 컨테이너를 가져옵니다. 이 컨테이너는 2개 이상의 장치에서 데이터를 공유하는 데 사용할 수 있습니다. 개발자는 로밍 앱 데이터 저장소에 저장된 개체를 쓰고 읽음으로써 손상될 위험을 높입니다. 여기에는 로밍 앱 데이터 저장소를 통해 해당 개체를 공유하는 데이터, 응용 프로그램 및 시스템의 기밀성, 무결성 및 가용성이 포함됩니다.

개발자는 이 기능을 사용하기 전에 먼저 필요한 기술적 제어를 구현해야 합니다.
References
[1] ApplicationData.RoamingFolder | roamingFolder property
[2] ApplicationData.RoamingSettings | roamingSettings property
[3] Standards Mapping - CIS Azure Kubernetes Service Benchmark 1.0
[4] Standards Mapping - CIS Microsoft Azure Foundations Benchmark complete
[5] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 5.0
[6] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 5
[7] Standards Mapping - CIS Google Kubernetes Engine Benchmark integrity
[8] Standards Mapping - CIS Kubernetes Benchmark partial
[9] Standards Mapping - Common Weakness Enumeration CWE ID 362, CWE ID 367
[10] Standards Mapping - Common Weakness Enumeration Top 25 2022 [22] CWE ID 362
[11] Standards Mapping - Common Weakness Enumeration Top 25 2023 [21] CWE ID 362
[12] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-000366, CCI-003178
[13] Standards Mapping - General Data Protection Regulation (GDPR) Access Violation
[14] Standards Mapping - NIST Special Publication 800-53 Revision 4 CM-6 Configuration Settings (P1)
[15] Standards Mapping - NIST Special Publication 800-53 Revision 5 CM-6 Configuration Settings
[16] Standards Mapping - OWASP Top 10 2021 A04 Insecure Design
[17] Standards Mapping - OWASP Application Security Verification Standard 4.0 1.11.2 Business Logic Architectural Requirements (L2 L3), 1.11.3 Business Logic Architectural Requirements (L3), 11.1.6 Business Logic Security Requirements (L2 L3)
[18] Standards Mapping - Payment Card Industry Data Security Standard Version 3.0 Requirement 6.5.6
[19] Standards Mapping - Payment Card Industry Data Security Standard Version 3.1 Requirement 6.5.6
[20] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2 Requirement 6.5.6
[21] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2.1 Requirement 6.5.6
[22] Standards Mapping - Payment Card Industry Data Security Standard Version 4.0 Requirement 6.2.4
[23] Standards Mapping - Payment Card Industry Software Security Framework 1.0 Control Objective 4.2 - Critical Asset Protection
[24] Standards Mapping - Payment Card Industry Software Security Framework 1.1 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.3 - Terminal Software Attack Mitigation
[25] Standards Mapping - Payment Card Industry Software Security Framework 1.2 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.3 - Terminal Software Attack Mitigation
[26] Standards Mapping - SANS Top 25 2009 Insecure Interaction - CWE ID 362
[27] Standards Mapping - SANS Top 25 2010 Insecure Interaction - CWE ID 362
[28] Standards Mapping - Security Technical Implementation Guide Version 3.1 APP3630.1 CAT II
[29] Standards Mapping - Security Technical Implementation Guide Version 3.4 APP3630.1 CAT II
[30] Standards Mapping - Security Technical Implementation Guide Version 3.5 APP3630.1 CAT II
[31] Standards Mapping - Security Technical Implementation Guide Version 3.6 APP3630.1 CAT II
[32] Standards Mapping - Security Technical Implementation Guide Version 3.7 APP3630.1 CAT II
[33] Standards Mapping - Security Technical Implementation Guide Version 3.9 APP3630.1 CAT II
[34] Standards Mapping - Security Technical Implementation Guide Version 3.10 APP3630.1 CAT II
[35] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-001995 CAT II
[36] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-001995 CAT II
[37] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-001995 CAT II
[38] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-001995 CAT II
[39] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-001995 CAT II
[40] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-001995 CAT II
[41] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-001995 CAT II
[42] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-001995 CAT II
[43] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-001995 CAT II
[44] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-001995 CAT II
[45] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-001995 CAT II
[46] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-001995 CAT II
[47] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-001995 CAT II
[48] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-001995 CAT II
desc.structural.dotnet.race_condition_roaming_data_access
Abstract
여러 시그널에 대해 동일한 시그널 처리기를 설치하면 다른 시그널이 짧게 연속으로 포착될 때 race condition이 발생할 수 있습니다.
Explanation
시그널 처리 race condition은 시그널 처리기로 설치된 함수가 재진입할 수 없을 때마다 나타날 수 있는데, 이러한 현상은 시그널 처리 race condition 시 일부 내부 상태가 유지되거나 이러한 기능을 하는 다른 함수를 호출함을 의미합니다. 이러한 race condition은 여러 시그널을 처리하도록 동일한 함수를 설치할 때에도 더 많이 나타납니다.

시그널 처리 race condition은 다음과 같은 경우에 더 많이 발생합니다.

1. 두 개 이상의 시그널에 대해 프로그램이 하나의 시그널 처리기를 설치합니다.

2. 처리기를 위해 두 개의 다른 시그널이 짧게 연속으로 설치되면 시그널 처리기에 race condition이 나타납니다.

예제: 다음 코드는 두 개의 다른 시그널에 대해 간단하며 비 재진입성(non-reentrant)의 동일한 시그널 처리기를 설치합니다. 공격자가 정확한 순간에 신호를 보내면, 신호 처리기에 double free 취약점이 발생하게 됩니다. 동일한 값에 대해 free()를 두 번 호출하면 buffer overflow가 발생할 수 있습니다. 프로그램이 같은 인수로 free()를 두 번 호출하면 프로그램의 메모리 관리 데이터 구조가 손상됩니다. 이 손상으로 인해 프로그램이 손상되거나 경우에 따라 이후에 있을 두 번의 malloc() 호출이 같은 포인터를 반환하기도 합니다. malloc()이 같은 값을 두 번 반환하고 나중에 프로그램이 이 중복 할당된 메모리에 작성되는 데이터에 대한 제어권을 공격자에게 넘겨주면 프로그램은 buffer overflow 공격에 취약해집니다.


void sh(int dummy) {
...
free(global2);
free(global1);
...
}

int main(int argc,char* argv[]) {
...
signal(SIGHUP,sh);
signal(SIGTERM,sh);
...
}
References
[1] Standards Mapping - CIS Azure Kubernetes Service Benchmark 1.0
[2] Standards Mapping - CIS Microsoft Azure Foundations Benchmark partial
[3] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 2.0
[4] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 4
[5] Standards Mapping - CIS Google Kubernetes Engine Benchmark normal
[6] Standards Mapping - Common Weakness Enumeration CWE ID 362, CWE ID 364
[7] Standards Mapping - Common Weakness Enumeration Top 25 2022 [22] CWE ID 362
[8] Standards Mapping - Common Weakness Enumeration Top 25 2023 [21] CWE ID 362
[9] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-000366, CCI-003178
[10] Standards Mapping - General Data Protection Regulation (GDPR) Indirect Access to Sensitive Data
[11] Standards Mapping - Motor Industry Software Reliability Association (MISRA) C Guidelines 2012 Rule 21.5
[12] Standards Mapping - Motor Industry Software Reliability Association (MISRA) C++ Guidelines 2008 Rule 18-7-1
[13] Standards Mapping - NIST Special Publication 800-53 Revision 4 CM-6 Configuration Settings (P1)
[14] Standards Mapping - NIST Special Publication 800-53 Revision 5 CM-6 Configuration Settings
[15] Standards Mapping - OWASP Top 10 2021 A04 Insecure Design
[16] Standards Mapping - OWASP Application Security Verification Standard 4.0 1.11.2 Business Logic Architectural Requirements (L2 L3)
[17] Standards Mapping - Payment Card Industry Data Security Standard Version 3.0 Requirement 6.5.6
[18] Standards Mapping - Payment Card Industry Data Security Standard Version 3.1 Requirement 6.5.6
[19] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2 Requirement 6.5.6
[20] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2.1 Requirement 6.5.6
[21] Standards Mapping - Payment Card Industry Data Security Standard Version 4.0 Requirement 6.2.4
[22] Standards Mapping - Payment Card Industry Software Security Framework 1.0 Control Objective 4.2 - Critical Asset Protection
[23] Standards Mapping - Payment Card Industry Software Security Framework 1.1 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.3 - Terminal Software Attack Mitigation
[24] Standards Mapping - Payment Card Industry Software Security Framework 1.2 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.3 - Terminal Software Attack Mitigation
[25] Standards Mapping - SANS Top 25 2009 Insecure Interaction - CWE ID 362
[26] Standards Mapping - SANS Top 25 2010 Insecure Interaction - CWE ID 362
[27] Standards Mapping - Security Technical Implementation Guide Version 3.1 APP3630.1 CAT II
[28] Standards Mapping - Security Technical Implementation Guide Version 3.4 APP3630.1 CAT II
[29] Standards Mapping - Security Technical Implementation Guide Version 3.5 APP3630.1 CAT II
[30] Standards Mapping - Security Technical Implementation Guide Version 3.6 APP3630.1 CAT II
[31] Standards Mapping - Security Technical Implementation Guide Version 3.7 APP3630.1 CAT II
[32] Standards Mapping - Security Technical Implementation Guide Version 3.9 APP3630.1 CAT II
[33] Standards Mapping - Security Technical Implementation Guide Version 3.10 APP3630.1 CAT II
[34] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-001995 CAT II
[35] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-001995 CAT II
[36] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-001995 CAT II
[37] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-001995 CAT II
[38] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-001995 CAT II
[39] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-001995 CAT II
[40] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-001995 CAT II
[41] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-001995 CAT II
[42] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-001995 CAT II
[43] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-001995 CAT II
[44] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-001995 CAT II
[45] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-001995 CAT II
[46] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-001995 CAT II
[47] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-001995 CAT II
desc.structural.cpp.race_condition_signal_handling
Abstract
Servlet 멤버 필드는 사용자가 다른 사용자의 데이터를 보는 것을 허용합니다.
Explanation
많은 Servlet 개발자들은 Servlet이 단일 항목이라는 사실을 모릅니다. Servlet의 인스턴스는 하나뿐이며, 이 단일 인스턴스를 여러 번 사용하여 다른 스레드에 의해서 동시에 처리되는 여러 요청을 처리합니다.

이런 무지로 인해 일반적으로 발생하는 결과는 개발자가 사용자로 하여금 실수로 다른 사용자의 데이터를 볼 수 있도록 Servlet 멤버 필드를 사용하는 것입니다. 다시 말해, 사용자 데이터를 Servlet 멤버 필드에 저장하여 데이터 접근 경쟁 조건(race condition)을 야기합니다.

예제 1: 다음 Servlet은 요청 매개 변수의 값을 멤버 필드에 저장한 다음, 나중에 매개 변수 값을 응답 출력 스트림으로 보냅니다.


public class GuestBook extends HttpServlet {

String name;

protected void doPost (HttpServletRequest req, HttpServletResponse res) {
name = req.getParameter("name");
...
out.println(name + ", thanks for visiting!");
}
}


이 코드는 단일 사용자 환경에서는 올바로 동작하지만, 두 명의 사용자가 거의 동시에 Servlet에 접근하면 다음과 같이 두 요청 처리기 스레드가 얽힐 수 있습니다.

스레드 1: name에 "Dick" 할당
스레드 2: name에 "Jane" 할당
스레드 1: print "Jane, thanks for visiting!"
스레드 2: print "Jane, thanks for visiting!"

따라서 첫 번째 사용자에게 두 번째 사용자의 이름이 표시됩니다.
References
[1] The Java Servlet Specification Sun Microsystems
[2] Standards Mapping - CIS Azure Kubernetes Service Benchmark 2.0
[3] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 3.0
[4] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 5
[5] Standards Mapping - CIS Google Kubernetes Engine Benchmark confidentiality
[6] Standards Mapping - CIS Kubernetes Benchmark partial
[7] Standards Mapping - Common Weakness Enumeration CWE ID 362, CWE ID 488
[8] Standards Mapping - Common Weakness Enumeration Top 25 2022 [22] CWE ID 362
[9] Standards Mapping - Common Weakness Enumeration Top 25 2023 [21] CWE ID 362
[10] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-001090, CCI-003178
[11] Standards Mapping - General Data Protection Regulation (GDPR) Access Violation
[12] Standards Mapping - NIST Special Publication 800-53 Revision 4 CM-6 Configuration Settings (P1), SC-4 Information in Shared Resources (P1)
[13] Standards Mapping - NIST Special Publication 800-53 Revision 5 CM-6 Configuration Settings, SC-4 Information in Shared System Resources
[14] Standards Mapping - OWASP Top 10 2007 A6 Information Leakage and Improper Error Handling
[15] Standards Mapping - OWASP Top 10 2021 A04 Insecure Design
[16] Standards Mapping - OWASP Application Security Verification Standard 4.0 1.11.2 Business Logic Architectural Requirements (L2 L3)
[17] Standards Mapping - Payment Card Industry Data Security Standard Version 1.2 Requirement 6.5.6
[18] Standards Mapping - Payment Card Industry Data Security Standard Version 2.0 Requirement 6.5.5
[19] Standards Mapping - Payment Card Industry Data Security Standard Version 3.0 Requirement 6.5.6
[20] Standards Mapping - Payment Card Industry Data Security Standard Version 3.1 Requirement 6.5.6
[21] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2 Requirement 6.5.6
[22] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2.1 Requirement 6.5.6
[23] Standards Mapping - Payment Card Industry Data Security Standard Version 4.0 Requirement 6.2.4
[24] Standards Mapping - Payment Card Industry Software Security Framework 1.0 Control Objective 4.2 - Critical Asset Protection
[25] Standards Mapping - Payment Card Industry Software Security Framework 1.1 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.3 - Terminal Software Attack Mitigation
[26] Standards Mapping - Payment Card Industry Software Security Framework 1.2 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.3 - Terminal Software Attack Mitigation
[27] Standards Mapping - SANS Top 25 2009 Insecure Interaction - CWE ID 362
[28] Standards Mapping - SANS Top 25 2010 Insecure Interaction - CWE ID 362
[29] Standards Mapping - Security Technical Implementation Guide Version 3.1 APP3630.1 CAT II
[30] Standards Mapping - Security Technical Implementation Guide Version 3.4 APP3630.1 CAT II
[31] Standards Mapping - Security Technical Implementation Guide Version 3.5 APP3630.1 CAT II
[32] Standards Mapping - Security Technical Implementation Guide Version 3.6 APP3630.1 CAT II
[33] Standards Mapping - Security Technical Implementation Guide Version 3.7 APP3630.1 CAT II
[34] Standards Mapping - Security Technical Implementation Guide Version 3.9 APP3630.1 CAT II
[35] Standards Mapping - Security Technical Implementation Guide Version 3.10 APP3630.1 CAT II
[36] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[37] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[38] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[39] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[40] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[41] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[42] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[43] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[44] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[45] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[46] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[47] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[48] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[49] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[50] Standards Mapping - Web Application Security Consortium Version 2.00 Information Leakage (WASC-13)
[51] Standards Mapping - Web Application Security Consortium 24 + 2 Information Leakage
desc.structural.java.singleton_member_field_race_condition
Abstract
정적 필드에 저장된 데이터베이스 연결이 스레드 간에 공유됩니다.
Explanation
데이터베이스 연결과 같은 트랜잭션 리소스 개체는 동시에 트랜잭션 하나에만 연결될 수 있습니다. 따라서 스레드 간에 연결을 공유하지 말고 정적 필드에 저장하지 않아야 합니다. 자세한 내용은 J2EE Specification의 섹션 4.2.3을 참조하십시오.

예제 1:

public class ConnectionManager {

private static Connection conn = initDbConn();
...
}
References
[1] Java 2 Platform Enterprise Edition Specification, v1.4 Sun Microsystems
[2] Standards Mapping - CIS Azure Kubernetes Service Benchmark 1.0
[3] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 3.1
[4] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 1
[5] Standards Mapping - CIS Google Kubernetes Engine Benchmark confidentiality
[6] Standards Mapping - CIS Kubernetes Benchmark partial
[7] Standards Mapping - Common Weakness Enumeration CWE ID 362, CWE ID 567
[8] Standards Mapping - Common Weakness Enumeration Top 25 2022 [22] CWE ID 362
[9] Standards Mapping - Common Weakness Enumeration Top 25 2023 [21] CWE ID 362
[10] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-001090, CCI-003178
[11] Standards Mapping - General Data Protection Regulation (GDPR) Access Violation
[12] Standards Mapping - NIST Special Publication 800-53 Revision 4 CM-6 Configuration Settings (P1), SC-4 Information in Shared Resources (P1)
[13] Standards Mapping - NIST Special Publication 800-53 Revision 5 CM-6 Configuration Settings, SC-4 Information in Shared System Resources
[14] Standards Mapping - OWASP Top 10 2021 A04 Insecure Design
[15] Standards Mapping - OWASP Application Security Verification Standard 4.0 1.11.2 Business Logic Architectural Requirements (L2 L3)
[16] Standards Mapping - Payment Card Industry Data Security Standard Version 3.0 Requirement 6.5.6
[17] Standards Mapping - Payment Card Industry Data Security Standard Version 3.1 Requirement 6.5.6
[18] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2 Requirement 6.5.6
[19] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2.1 Requirement 6.5.6
[20] Standards Mapping - Payment Card Industry Data Security Standard Version 4.0 Requirement 6.2.4
[21] Standards Mapping - Payment Card Industry Software Security Framework 1.0 Control Objective 4.2 - Critical Asset Protection
[22] Standards Mapping - Payment Card Industry Software Security Framework 1.1 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.3 - Terminal Software Attack Mitigation
[23] Standards Mapping - Payment Card Industry Software Security Framework 1.2 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.3 - Terminal Software Attack Mitigation
[24] Standards Mapping - SANS Top 25 2009 Insecure Interaction - CWE ID 362
[25] Standards Mapping - SANS Top 25 2010 Insecure Interaction - CWE ID 362
[26] Standards Mapping - Security Technical Implementation Guide Version 3.1 APP3630.1 CAT II
[27] Standards Mapping - Security Technical Implementation Guide Version 3.4 APP3630.1 CAT II
[28] Standards Mapping - Security Technical Implementation Guide Version 3.5 APP3630.1 CAT II
[29] Standards Mapping - Security Technical Implementation Guide Version 3.6 APP3630.1 CAT II
[30] Standards Mapping - Security Technical Implementation Guide Version 3.7 APP3630.1 CAT II
[31] Standards Mapping - Security Technical Implementation Guide Version 3.9 APP3630.1 CAT II
[32] Standards Mapping - Security Technical Implementation Guide Version 3.10 APP3630.1 CAT II
[33] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[34] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[35] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[36] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[37] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[38] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[39] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[40] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[41] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[42] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[43] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[44] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[45] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
[46] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-001995 CAT II, APSC-DV-002380 CAT II
desc.structural.java.race.dbconn
Abstract
기존의 세션 ID를 무효화하지 않고 사용자를 인증하면 공격자에게 인증된 세션을 도용할 수 있는 기회를 제공합니다.
Explanation
다음의 경우 session fixation 취약점이 발생합니다.

1. 웹 응용 프로그램이 먼저 기존 세션을 무효화하지 않고 사용자를 인증하여 이미 사용자에게 연결되어 있는 세션을 계속 사용하도록 합니다.
2. 공격자가 사용자에게 알려진 세션 ID를 강제로 적용할 수 있기 때문에 사용자가 인증되면 공격자가 인증된 세션에 대한 접근 권한을 갖게 됩니다.

Session fixation 취약점의 일반적인 익스플로이트에서 공격자는 웹 응용 프로그램에 대한 새 세션을 만들어 관련 세션 ID를 기록합니다. 그런 다음 공격자는 기록한 세션 ID를 사용하여 피해자가 서버에 대해 인증을 받도록 하고 공격자는 활성 세션을 통해 피해자의 계정에 대한 접근 권한을 얻습니다.

Spring Security와 같은 일부 프레임워크는 새 세션을 만들 때 기존 세션을 자동으로 무효화합니다. 이 동작을 비활성화하면 응용 프로그램이 이 공격에 취약해질 수 있습니다.

예제 1: 다음 예는 session fixation 보호가 비활성화된 Spring Security로 보호된 응용 프로그램의 조각을 보여줍니다.


<http auto-config="true">
...
<session-management session-fixation-protection="none"/>
</http>


응용 프로그램이 취약하다 하더라도 여기에 기술한 공격이 성공하려면 여러 요인이 공격자에게 유리하게 작용해야 합니다. 즉, 공용 터미널에 대한 접근을 들키지 않는 것, 손상된 세션을 활성 상태로 유지하는 능력 및 공용 터미널에서 취약한 응용 프로그램에 로그인하려는 피해자가 바로 그런 요소입니다. 대부분의 경우 충분한 시간을 투자한다고 했을 때 첫 번째 두 관문은 통과할 수 있습니다. 공용 터미널을 사용하여 취약한 응용 프로그램에 로그인하려는 피해자를 찾는 일도 해당 사이트가 아주 인기 있기만 하면 불가능한 일이 아닙니다. 잘 알려지지 않은 사이트일수록 공용 터미널을 사용하여 로그인하려는 피해자가 있을 확률이 낮고 따라서 앞서 기술한 공격이 성공할 가능성도 낮습니다.

공격자가 session fixation 취약점을 익스플로이트할 때 직면하는 가장 큰 과제는 공격자에게 알려진 세션 ID를 사용하여 피해자가 취약한 응용 프로그램에 대해 인증을 받도록 유도하는 것입니다. Example 1에서는 공격자가 잘 알려지지 않은 웹 사이트 관련 공격에 적합하게 조정할 수 없는 직접적인 방법을 사용하여 이를 수행합니다. 하지만 그렇다고 안심해선 안 됩니다. 공격자는 이 공격의 한계를 극복할 수 있는 여러 가지 수단을 갖고 있습니다. 공격자가 사용하는 가장 흔한 방법은 대상 사이트에서 cross-site scripting 또는 HTTP response splitting 취약점을 이용하는 것입니다[1]. 피해자를 속여 JavaScript 또는 기타 코드를 피해자의 브라우저에 다시 돌려보내는 취약한 응용 프로그램에 악성 요청을 전송하도록 하여 공격자는 피해자가 공격자가 제어하는 세션 ID를 다시 사용하도록 하는 쿠키를 만들 수 있습니다.

쿠키가 주어진 URL과 연결된 최상위 도메인에 연결되어 있다는 것을 주목할 필요가 있습니다. 여러 응용 프로그램이 bank.example.comrecipes.example.com과 같이 같은 최상위 도메인에 있는 경우, 한 응용 프로그램의 취약점 때문에 공격자가 도메인 example.com [2]에 있는 응용 프로그램과의 모든 상호 작용에 사용할 고정 세션 ID로 쿠키를 설정할 수 있습니다.

다른 공격으로는 공격자가 올바른 사이트의 요청을 리디렉션하여 사용자가 악성 사이트를 방문하도록 만드는 DNS 감염 및 관련 네트워크 기반 공격 등이 있습니다. 네트워크 기반 공격은 일반적으로 피해자의 네트워크상에 실제로 존재하거나 네트워크상의 피해 시스템을 제어하는 것과 관련이 있습니다. 이는 원격 익스플로이트가 어렵지만 그 중요성을 간과해서는 안 됩니다. Apache Tomcat의 기본 구현과 같이 세션 관리 메커니즘의 보안이 약할수록 일반적으로 쿠키에서 예상되는 세션 ID를 URL에도 지정할 수 있습니다. 이를 통해 공격자가 악성 URL을 전자 메일로 전송하기만 하면 피해자가 고정 세션 ID를 사용하도록 할 수 있습니다.
References
[1] Standards Mapping - CIS Azure Kubernetes Service Benchmark 2.0
[2] Standards Mapping - CIS Microsoft Azure Foundations Benchmark complete
[3] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 2.0
[4] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 3
[5] Standards Mapping - CIS Google Kubernetes Engine Benchmark integrity
[6] Standards Mapping - CIS Kubernetes Benchmark partial
[7] Standards Mapping - Common Weakness Enumeration CWE ID 384
[8] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-001664, CCI-001941, CCI-001942
[9] Standards Mapping - FIPS200 IA
[10] Standards Mapping - General Data Protection Regulation (GDPR) Access Violation
[11] Standards Mapping - NIST Special Publication 800-53 Revision 4 AC-10 Concurrent Session Control (P3), IA-2 Identification and Authentication (Organizational Users) (P1), SC-23 Session Authenticity (P1)
[12] Standards Mapping - NIST Special Publication 800-53 Revision 5 AC-10 Concurrent Session Control, IA-2 Identification and Authentication (Organizational Users), SC-23 Session Authenticity
[13] Standards Mapping - OWASP Top 10 2004 A3 Broken Authentication and Session Management
[14] Standards Mapping - OWASP Top 10 2007 A7 Broken Authentication and Session Management
[15] Standards Mapping - OWASP Top 10 2010 A3 Broken Authentication and Session Management
[16] Standards Mapping - OWASP Top 10 2013 A2 Broken Authentication and Session Management
[17] Standards Mapping - OWASP Top 10 2017 A2 Broken Authentication
[18] Standards Mapping - OWASP Top 10 2021 A07 Identification and Authentication Failures
[19] Standards Mapping - OWASP API 2023 API2 Broken Authentication
[20] Standards Mapping - OWASP Application Security Verification Standard 4.0 3.2.1 Session Binding Requirements (L1 L2 L3), 3.2.3 Session Binding Requirements (L1 L2 L3), 3.3.1 Session Logout and Timeout Requirements (L1 L2 L3)
[21] Standards Mapping - OWASP Mobile 2014 M9 Improper Session Handling
[22] Standards Mapping - OWASP Mobile 2024 M3 Insecure Authentication/Authorization
[23] Standards Mapping - Payment Card Industry Data Security Standard Version 1.1 Requirement 6.5.3
[24] Standards Mapping - Payment Card Industry Data Security Standard Version 1.2 Requirement 6.5.7
[25] Standards Mapping - Payment Card Industry Data Security Standard Version 2.0 Requirement 6.5.8
[26] Standards Mapping - Payment Card Industry Data Security Standard Version 3.0 Requirement 6.5.10
[27] Standards Mapping - Payment Card Industry Data Security Standard Version 3.1 Requirement 6.5.10
[28] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2 Requirement 6.5.10
[29] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2.1 Requirement 6.5.10
[30] Standards Mapping - Payment Card Industry Data Security Standard Version 4.0 Requirement 6.2.4
[31] Standards Mapping - Payment Card Industry Software Security Framework 1.0 Control Objective 4.2 - Critical Asset Protection
[32] Standards Mapping - Payment Card Industry Software Security Framework 1.1 Control Objective 4.2 - Critical Asset Protection
[33] Standards Mapping - Payment Card Industry Software Security Framework 1.2 Control Objective 4.2 - Critical Asset Protection
[34] Standards Mapping - Security Technical Implementation Guide Version 3.1 APP3405 CAT I
[35] Standards Mapping - Security Technical Implementation Guide Version 3.4 APP3405 CAT I
[36] Standards Mapping - Security Technical Implementation Guide Version 3.5 APP3405 CAT I
[37] Standards Mapping - Security Technical Implementation Guide Version 3.6 APP3405 CAT I
[38] Standards Mapping - Security Technical Implementation Guide Version 3.7 APP3405 CAT I
[39] Standards Mapping - Security Technical Implementation Guide Version 3.9 APP3405 CAT I
[40] Standards Mapping - Security Technical Implementation Guide Version 3.10 APP3405 CAT I
[41] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II, APSC-DV-002250 CAT II, APSC-DV-002260 CAT II, APSC-DV-002270 CAT II, APSC-DV-002280 CAT II
[42] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II, APSC-DV-002250 CAT II, APSC-DV-002260 CAT II, APSC-DV-002270 CAT II, APSC-DV-002280 CAT II
[43] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II, APSC-DV-002250 CAT II, APSC-DV-002260 CAT II, APSC-DV-002270 CAT II, APSC-DV-002280 CAT II
[44] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II, APSC-DV-002250 CAT II, APSC-DV-002260 CAT II, APSC-DV-002270 CAT II, APSC-DV-002280 CAT II
[45] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II, APSC-DV-002250 CAT II, APSC-DV-002260 CAT II, APSC-DV-002270 CAT II, APSC-DV-002280 CAT II
[46] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II, APSC-DV-002250 CAT II, APSC-DV-002260 CAT II, APSC-DV-002270 CAT II, APSC-DV-002280 CAT II
[47] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II, APSC-DV-002250 CAT II, APSC-DV-002260 CAT II, APSC-DV-002270 CAT II, APSC-DV-002280 CAT II
[48] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II, APSC-DV-002250 CAT II, APSC-DV-002260 CAT II, APSC-DV-002270 CAT II, APSC-DV-002280 CAT II
[49] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II, APSC-DV-002250 CAT II, APSC-DV-002260 CAT II, APSC-DV-002270 CAT II, APSC-DV-002280 CAT II
[50] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II, APSC-DV-002250 CAT II, APSC-DV-002260 CAT II, APSC-DV-002270 CAT II, APSC-DV-002280 CAT II
[51] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II, APSC-DV-002250 CAT II, APSC-DV-002260 CAT II, APSC-DV-002270 CAT II, APSC-DV-002280 CAT II
[52] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II, APSC-DV-002250 CAT II, APSC-DV-002260 CAT II, APSC-DV-002270 CAT II, APSC-DV-002280 CAT II
[53] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II, APSC-DV-002250 CAT II, APSC-DV-002260 CAT II, APSC-DV-002270 CAT II, APSC-DV-002280 CAT II
[54] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-000010 CAT II, APSC-DV-001620 CAT II, APSC-DV-001630 CAT II, APSC-DV-002250 CAT II, APSC-DV-002260 CAT II, APSC-DV-002270 CAT II, APSC-DV-002280 CAT II
[55] Standards Mapping - Web Application Security Consortium Version 2.00 Session Fixation (WASC-37)
[56] Standards Mapping - Web Application Security Consortium 24 + 2 Session Fixation
desc.config.java.session_fixation
Abstract
기존의 세션 ID를 무효화하지 않고 사용자를 인증하면 공격자가 인증된 세션을 도용할 수 있는 기회를 얻습니다.
Explanation
다음의 경우 session fixation 취약점이 발생합니다.

1. 웹 응용 프로그램이 먼저 기존 세션을 무효화하지 않고 사용자를 인증하여 이미 사용자에게 연결되어 있는 세션을 계속 사용하도록 합니다.

2. 공격자가 사용자에게 알려진 세션 ID를 강제로 적용할 수 있기 때문에 사용자가 인증되면 공격자가 인증된 세션에 대한 접근 권한을 갖게 됩니다.

Session fixation 취약점의 일반적인 익스플로이트에서 공격자는 웹 응용 프로그램에 대한 새 세션을 만들어 관련 세션 ID를 기록합니다. 그런 다음 공격자는 기록한 세션 ID를 사용하여 피해자가 서버에 대해 인증을 받도록 하고 공격자는 활성 세션을 통해 피해자의 계정에 대한 접근 권한을 얻습니다.

예제 1: 다음 코드는 세션 쿠키에 대해 use_strict_mode 속성을 비활성화합니다.

ini_set("session.use_strict_mode", "0");
References
[1] D. Whalen The Unofficial Cookie FAQ
[2] The PHP Group PHP Use Strict Mode Documentation
[3] Standards Mapping - CIS Azure Kubernetes Service Benchmark 2.0
[4] Standards Mapping - CIS Microsoft Azure Foundations Benchmark complete
[5] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 2.0
[6] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 3
[7] Standards Mapping - CIS Google Kubernetes Engine Benchmark integrity
[8] Standards Mapping - CIS Kubernetes Benchmark partial
[9] Standards Mapping - Common Weakness Enumeration CWE ID 384
[10] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-001664, CCI-001941, CCI-001942
[11] Standards Mapping - FIPS200 IA
[12] Standards Mapping - General Data Protection Regulation (GDPR) Access Violation
[13] Standards Mapping - NIST Special Publication 800-53 Revision 4 AC-10 Concurrent Session Control (P3), IA-2 Identification and Authentication (Organizational Users) (P1), SC-23 Session Authenticity (P1)
[14] Standards Mapping - NIST Special Publication 800-53 Revision 5 AC-10 Concurrent Session Control, IA-2 Identification and Authentication (Organizational Users), SC-23 Session Authenticity
[15] Standards Mapping - OWASP Top 10 2004 A3 Broken Authentication and Session Management
[16] Standards Mapping - OWASP Top 10 2007 A7 Broken Authentication and Session Management
[17] Standards Mapping - OWASP Top 10 2010 A3 Broken Authentication and Session Management
[18] Standards Mapping - OWASP Top 10 2013 A2 Broken Authentication and Session Management
[19] Standards Mapping - OWASP Top 10 2017 A2 Broken Authentication
[20] Standards Mapping - OWASP Top 10 2021 A07 Identification and Authentication Failures
[21] Standards Mapping - OWASP API 2023 API2 Broken Authentication
[22] Standards Mapping - OWASP Application Security Verification Standard 4.0 3.2.1 Session Binding Requirements (L1 L2 L3), 3.2.3 Session Binding Requirements (L1 L2 L3), 3.3.1 Session Logout and Timeout Requirements (L1 L2 L3)
[23] Standards Mapping - OWASP Mobile 2014 M9 Improper Session Handling
[24] Standards Mapping - OWASP Mobile 2024 M3 Insecure Authentication/Authorization
[25] Standards Mapping - Payment Card Industry Data Security Standard Version 1.1 Requirement 6.5.3
[26] Standards Mapping - Payment Card Industry Data Security Standard Version 1.2 Requirement 6.5.7
[27] Standards Mapping - Payment Card Industry Data Security Standard Version 2.0 Requirement 6.5.8
[28] Standards Mapping - Payment Card Industry Data Security Standard Version 3.0 Requirement 6.5.10
[29] Standards Mapping - Payment Card Industry Data Security Standard Version 3.1 Requirement 6.5.10
[30] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2 Requirement 6.5.10
[31] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2.1 Requirement 6.5.10
[32] Standards Mapping - Payment Card Industry Data Security Standard Version 4.0 Requirement 6.2.4
[33] Standards Mapping - Payment Card Industry Software Security Framework 1.0 Control Objective 4.2 - Critical Asset Protection
[34] Standards Mapping - Payment Card Industry Software Security Framework 1.1 Control Objective 4.2 - Critical Asset Protection
[35] Standards Mapping - Payment Card Industry Software Security Framework 1.2 Control Objective 4.2 - Critical Asset Protection
[36] Standards Mapping - Security Technical Implementation Guide Version 3.1 APP3405 CAT I
[37] Standards Mapping - Security Technical Implementation Guide Version 3.4 APP3405 CAT I
[38] Standards Mapping - Security Technical Implementation Guide Version 3.5 APP3405 CAT I
[39] Standards Mapping - Security Technical Implementation Guide Version 3.6 APP3405 CAT I
[40] Standards Mapping - Security Technical Implementation Guide Version 3.7 APP3405 CAT I
[41] Standards Mapping - Security Technical Implementation Guide Version 3.9 APP3405 CAT I
[42] Standards Mapping - Security Technical Implementation Guide Version 3.10 APP3405 CAT I
[43] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II, APSC-DV-002250 CAT II, APSC-DV-002260 CAT II, APSC-DV-002270 CAT II, APSC-DV-002280 CAT II
[44] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II, APSC-DV-002250 CAT II, APSC-DV-002260 CAT II, APSC-DV-002270 CAT II, APSC-DV-002280 CAT II
[45] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II, APSC-DV-002250 CAT II, APSC-DV-002260 CAT II, APSC-DV-002270 CAT II, APSC-DV-002280 CAT II
[46] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II, APSC-DV-002250 CAT II, APSC-DV-002260 CAT II, APSC-DV-002270 CAT II, APSC-DV-002280 CAT II
[47] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II, APSC-DV-002250 CAT II, APSC-DV-002260 CAT II, APSC-DV-002270 CAT II, APSC-DV-002280 CAT II
[48] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II, APSC-DV-002250 CAT II, APSC-DV-002260 CAT II, APSC-DV-002270 CAT II, APSC-DV-002280 CAT II
[49] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II, APSC-DV-002250 CAT II, APSC-DV-002260 CAT II, APSC-DV-002270 CAT II, APSC-DV-002280 CAT II
[50] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II, APSC-DV-002250 CAT II, APSC-DV-002260 CAT II, APSC-DV-002270 CAT II, APSC-DV-002280 CAT II
[51] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II, APSC-DV-002250 CAT II, APSC-DV-002260 CAT II, APSC-DV-002270 CAT II, APSC-DV-002280 CAT II
[52] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II, APSC-DV-002250 CAT II, APSC-DV-002260 CAT II, APSC-DV-002270 CAT II, APSC-DV-002280 CAT II
[53] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II, APSC-DV-002250 CAT II, APSC-DV-002260 CAT II, APSC-DV-002270 CAT II, APSC-DV-002280 CAT II
[54] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II, APSC-DV-002250 CAT II, APSC-DV-002260 CAT II, APSC-DV-002270 CAT II, APSC-DV-002280 CAT II
[55] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-001620 CAT II, APSC-DV-001630 CAT II, APSC-DV-002250 CAT II, APSC-DV-002260 CAT II, APSC-DV-002270 CAT II, APSC-DV-002280 CAT II
[56] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-000010 CAT II, APSC-DV-001620 CAT II, APSC-DV-001630 CAT II, APSC-DV-002250 CAT II, APSC-DV-002260 CAT II, APSC-DV-002270 CAT II, APSC-DV-002280 CAT II
[57] Standards Mapping - Web Application Security Consortium Version 2.00 Session Fixation (WASC-37)
[58] Standards Mapping - Web Application Security Consortium 24 + 2 Session Fixation
desc.structural.php.session_fixation