<dd id="sga4y"><optgroup id="sga4y"></optgroup></dd>
<nav id="sga4y"><code id="sga4y"></code></nav>
  • <optgroup id="sga4y"></optgroup>

    Race Condition: Signal Handling

    ABSTRACT

    為多重信號安裝相同的信號處理函數的話,當在短時間內連續收到不同的信號時,會導致 race condition。

    EXPLANATION

    當安裝作為信號處理函數的函數屬于非可重入函數時,信號處理就會發生 race condition。非可重入函數會保留一些內部狀態,或調用其他同樣如此的函數。當安裝同一函數去處理多重信號時,很有可能發生這種 race condition。

    信號處理 race condition 很有可能在以下情況中出現:

    1. 程序為多重信號僅安裝一個信號處理函數。

    2. 在短時間內,信號處理函數收到兩種不同的信號,導致該信號處理函數中出現 race condition。

    示例:以下代碼為兩個不同的信號僅安裝了一個簡單的、非折返信號處理函數。如果攻擊者使信號在適當的時間內一起發送,信號處理函數就會遭受 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 - Security Technical Implementation Guide Version 3 - (STIG 3) APP3630.1 CAT II

    [2] Standards Mapping - Security Technical Implementation Guide Version 3.4 - (STIG 3.4) APP3630.1 CAT II

    [3] Standards Mapping - Common Weakness Enumeration - (CWE) CWE ID 362, CWE ID 364

    [4] Standards Mapping - SANS Top 25 2009 - (SANS 2009) Insecure Interaction - CWE ID 362

    [5] Standards Mapping - SANS Top 25 2010 - (SANS 2010) Insecure Interaction - CWE ID 362


    Copyright 2013 Fortify Software - All rights reserved.
    (Generated from version 2013.1.1.0008 of the Fortify Secure Coding Rulepacks)
    desc.structural.cpp.race_condition_signal_handling

    97av