Mutex Copied via Value Receiver
Description
A `sync.Mutex` is copied in a function given that the receiver is a value. As a result, the struct may not be locked as intended, potentially leading to concurrency issues.
Examples
Insecure Code
go
func (m myStruct) myFunction() { m.Lock(); }Secure Code
go
func (m *myStruct) myFunction() { m.Lock(); }Remediation
Change the receiver to a pointer to ensure the mutex is not copied.
Rule Details
| Field | Value |
|---|---|
| ID | CODE-0257 |
| Category | Concurrency |
| Severity | MEDIUM |
| CWE | CWE-688 |
| Confidence | HIGH |
| Impact | LOW |
| Likelihood | HIGH |
| Exploitability | MODERATE |
| Tags | concurrency, mutex |
| OWASP | N/A |