CWE-362 使用共享资源的并发执行不恰当同步问题(竞争条件) 类弱点 422 条 CVE 漏洞汇总,含 AI 中文分析。
CWE-362 属于并发执行漏洞,指代码序列在需要独占访问共享资源时,因缺乏同步机制导致存在时间窗口,使其他并发序列能修改该资源。攻击者通常利用此竞态条件,通过精心构造并发请求篡改数据或绕过安全检查,从而引发逻辑错误或权限提升。开发者应避免此类问题,确保对共享资源的访问具备原子性,通过加锁、事务或原子操作等同步机制消除竞争窗口,保障数据一致性。
$transfer_amount = GetTransferAmount(); $balance = GetBalanceFromDatabase(); if ($transfer_amount < 0) { FatalError("Bad Transfer Amount"); } $newbalance = $balance - $transfer_amount; if (($balance - $transfer_amount) < 0) { FatalError("Insufficient Funds"); } SendNewBalanceToDatabase($newbalance); NotifyUser("Transfer of $transfer_amount succeeded."); NotifyUser("New balance: $newbalance");In the following pseudocode, the attacker makes two simultaneous calls of the program, CALLER-1 and CALLER-2. Both callers are for the same user account. CALLER-1 (the attacker) is associated with PROGRAM-1 (the instance that handles CALLER-1). CALLER-2 is associated with PROGRAM-2. CALLER-1 makes a transfer request of 80.00. PROGRAM-1 calls GetBalanceFromDatabase and sets $balance to 100.00 PROGRAM-1 calculates $newbalance as 20.00, then calls SendNewBalanceToDatabase(). Due to high server load, the PROGRAM-1 call to SendNewBalanceToDatabase() encounters a delay. CALLER-2 makes a transfer reqvoid f(pthread_mutex_t *mutex) { pthread_mutex_lock(mutex); /* access shared resource */ pthread_mutex_unlock(mutex); }int f(pthread_mutex_t *mutex) { int result; result = pthread_mutex_lock(mutex); if (0 != result) return result; /* access shared resource */ return pthread_mutex_unlock(mutex); }CWE-362(使用共享资源的并发执行不恰当同步问题(竞争条件)) 是常见的弱点类别,本平台收录该类弱点关联的 422 条 CVE 漏洞。