程序無法釋放其持有的鎖,這可能會導致死鎖。
程序可能無法成功釋放某一項系統資源。
資源泄露至少有兩種常見的原因:
- 錯誤狀況及其他異常情況。
- 未明確程序的哪一部份負責釋放資源。
大部分 Unreleased Resource 問題只會導致一般的軟件可靠性問題,但如果攻擊者能夠故意觸發資源泄漏,該攻擊者就有可能通過耗盡資源池的方式發起 denial of service 攻擊。
示例:如果發生錯誤,以下函數會破壞它分配的條件變量。如果進程長時間存在,它會耗盡文件句柄。
int helper(char* fName)
{
int status;
...
pthread_cond_init (&count_threshold_cv, NULL);
pthread_mutex_init(&count_mutex, NULL);
status = perform_operation();
if (status) {
printf("%s", "cannot perform operation");
return OPERATION_FAIL;
}
pthread_mutex_destroy(&count_mutex);
pthread_cond_destroy(&count_threshold_cv);
return OPERATION_SUCCESS;
}
[1] Standards Mapping - OWASP Top 10 2004 - (OWASP 2004) A9 Application Denial of Service
[2] Standards Mapping - Security Technical Implementation Guide Version 3 - (STIG 3) APP6080 CAT II
[3] Standards Mapping - Security Technical Implementation Guide Version 3.4 - (STIG 3.4) APP6080 CAT II
[4] Standards Mapping - Common Weakness Enumeration - (CWE) CWE ID 411
[5] Standards Mapping - Payment Card Industry Data Security Standard Version 1.1 - (PCI 1.1) Requirement 6.5.9