Executive brief
A flaw in the concurrent-ruby library, a tool used by Ruby developers to manage multi-threaded tasks, can cause data protection mechanisms to fail. Specifically, if a program performs a very high number of repeated read operations, the system may incorrectly grant a "write lock" that is supposed to be exclusive. This means two different parts of a program could modify and read the same data simultaneously, potentially leading to data corruption or unpredictable application behavior.
Technical details
A wrap-around error (CWE-128) exists in the Concurrent::ReentrantReadWriteLock implementation where local read and write hold counts are stored in a single integer. The low 15 bits track the read hold count, while bit 15 represents the WRITE_LOCK_HELD flag. When a thread acquires a read lock 32,768 times, the counter overflows into bit 15. Subsequent calls to try_write_lock observe this bit, incorrectly conclude the thread already holds the write lock, and return true without setting the global RUNNING_WRITER bit. This allows other threads to continue acquiring read locks while the primary thread believes it has exclusive write access, leading to race conditions. The issue is fixed in version 1.3.7.
Affected products
- ruby-concurrency concurrent-ruby < 1.3.7
Timeline
- 2026-06-16: advisory: GitHub Security Advisory published
- 2026-06-24: disclosed: NVD publication date
- 2026-06-24: patched: Fix released in version 1.3.7