Conversation
Effi-S
marked this pull request as ready for review
August 10, 2026 07:57
Effi-S
force-pushed
the
fix-2079
branch
2 times, most recently
from
August 10, 2026 14:08
6b34786 to
eac3e53
Compare
AkramBitar
reviewed
Aug 10, 2026
AkramBitar
left a comment
Contributor
There was a problem hiding this comment.
The read lock is released before the slice is iterated in three places (signer.go, verifier.go, eidrh.go). A concurrent writer calling append may allocate a new backing array at that moment; the reader holds a copy of the old slice header and misses the new entry. This is safe (no crash) but creates a stale-read window.
Consider either holding the lock through the iteration, or copying the slice under the lock before releasing:
v.mutex.RLock()
dess := make([]TypedSignerDeserializer, len(v.deserializers[si.Type]))
copy(dess, v.deserializers[si.Type])
v.mutex.RUnlock()
AkramBitar
requested changes
Aug 10, 2026
Contributor
Author
deserializers map[identity.Type]driver2.AuditInfoDeserializer |
Effi-S
force-pushed
the
fix-2079
branch
3 times, most recently
from
August 12, 2026 11:54
12ed0b1 to
de0f99f
Compare
Signed-off-by: Effi-S <effi.szt@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2079
Summary
The signer deserializer multiplex keeps its per-type deserializer lists in a plain Go map that is
written under one mutex and read without any lock, so a concurrent registration and lookup can race
and trigger Go's "concurrent map read and map write" fatal error.
Where
token/services/identity/deserializer/signer.go:23declaresdeserializers map[IdentityType][]TypedSignerDeserializer. Writes happen viaAddTypedSignerDeserializer(signer.go:30-38), called frommembership/lm.go:818while holdinglocalIdentitiesMutex. Reads happen unlocked atsigner.go:45, fromProvider.getSignerAndCache(provider.go:325). These are two different mutexes, so the lock heldduring registration provides no protection for the concurrent read path. Registration can happen at
runtime via
refreshAndGet(lm.go:889), so a liveGetSignercall can genuinely race a newregistration.
verifier.go:26has the same shape, andeidrh.go:26'sAddDeserializerhas nomutex at all.
Impact
A registration happening concurrently with a lookup on the same multiplex can trigger Go's runtime
map-race detector, which terminates the process — this is a stability concern under concurrent
identity-registration workloads, independent of any race detector build (the runtime check is always
active for maps, not just under
-race).Suggested fix
Guard map access consistently — either take the same mutex used for writes on the read path (a small
read-lock around the lookup), or switch to a concurrency-safe map type if lock contention on the read
path is a concern given how frequently
getSignerAndCacheis called. Apply the same fix toverifier.goand add a mutex toeidrh.go'sAddDeserializer, since all three share the samepattern.
Severity
HIGH — a data-race that can crash the process, though it requires registration and lookup to overlap
in time to manifest.