Skip to content

Commit

Permalink
crypto/ssss: only accept secret shares from verified devices (#352)
Browse files Browse the repository at this point in the history
Co-authored-by: Tulir Asokan <tulir@maunium.net>
  • Loading branch information
bradtgmurray and tulir authored Feb 13, 2025
1 parent 0417844 commit 14008ca
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions crypto/sharing.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,19 @@ func (mach *OlmMachine) receiveSecret(ctx context.Context, evt *DecryptedOlmEven
return
}

// https://spec.matrix.org/v1.10/client-server-api/#msecretsend
// "The recipient must ensure... that the device is a verified device owned by the recipient"
if senderDevice, err := mach.GetOrFetchDevice(ctx, evt.Sender, evt.SenderDevice); err != nil {
log.Err(err).Msg("Failed to get or fetch sender device, rejecting secret")
return
} else if senderDevice == nil {
log.Warn().Msg("Unknown sender device, rejecting secret")
return
} else if !mach.IsDeviceTrusted(ctx, senderDevice) {
log.Warn().Msg("Sender device is not verified, rejecting secret")
return
}

mach.secretLock.Lock()
secretChan := mach.secretListeners[content.RequestID]
mach.secretLock.Unlock()
Expand Down

0 comments on commit 14008ca

Please sign in to comment.