Use both envelope.type and ciphertextMessageType in the validator.

This commit is contained in:
Greyson Parrelli
2026-01-28 12:43:59 -05:00
parent 0a572153f0
commit d9dba89781
7 changed files with 179 additions and 33 deletions

View File

@@ -4,6 +4,7 @@ import okio.ByteString
import okio.ByteString.Companion.toByteString
import org.signal.core.models.ServiceId
import org.signal.core.util.logging.Log
import org.signal.libsignal.protocol.message.CiphertextMessage
import org.thoughtcrime.securesms.database.SignalDatabase.Companion.groups
import org.thoughtcrime.securesms.dependencies.AppDependencies
import org.thoughtcrime.securesms.groups.GroupChangeBusyException
@@ -47,7 +48,8 @@ class PushProcessMessageJob private constructor(
sourceDeviceId = metadata.sourceDeviceId,
sealedSender = metadata.sealedSender,
groupId = if (metadata.groupId != null) metadata.groupId!!.toByteString() else null,
destinationServiceId = ByteString.of(*metadata.destinationServiceId.toByteArray())
destinationServiceId = ByteString.of(*metadata.destinationServiceId.toByteArray()),
ciphertextMessageType = metadata.ciphertextMessageType
),
serverDeliveredTimestamp = serverDeliveredTimestamp
).encode()
@@ -84,7 +86,8 @@ class PushProcessMessageJob private constructor(
sourceDeviceId = completeMessage.metadata.sourceDeviceId,
sealedSender = completeMessage.metadata.sealedSender,
groupId = completeMessage.metadata.groupId?.toByteArray(),
destinationServiceId = ServiceId.parseOrThrow(completeMessage.metadata.destinationServiceId.toByteArray())
destinationServiceId = ServiceId.parseOrThrow(completeMessage.metadata.destinationServiceId.toByteArray()),
ciphertextMessageType = completeMessage.metadata.ciphertextMessageType ?: CiphertextMessage.WHISPER_TYPE
),
serverDeliveredTimestamp = completeMessage.serverDeliveredTimestamp
)

View File

@@ -177,7 +177,7 @@ object MessageDecryptor {
Log.d(TAG, "${logPrefix(envelope, cipherResult)} Successfully decrypted the envelope in ${(endTimeNanos - startTimeNanos).nanoseconds.toDouble(DurationUnit.MILLISECONDS).roundedString(2)} ms (GUID ${UuidUtil.getStringUUID(envelope.serverGuid, envelope.serverGuidBinary)}). Delivery latency: ${serverDeliveredTimestamp - envelope.serverTimestamp!!} ms, Urgent: ${envelope.urgent}")
val validationResult: EnvelopeContentValidator.Result = EnvelopeContentValidator.validate(envelope, cipherResult.content, SignalStore.account.aci!!)
val validationResult: EnvelopeContentValidator.Result = EnvelopeContentValidator.validate(envelope, cipherResult.content, SignalStore.account.aci!!, cipherResult.metadata.ciphertextMessageType)
if (validationResult is EnvelopeContentValidator.Result.Invalid) {
Log.w(TAG, "${logPrefix(envelope, cipherResult)} Invalid content! ${validationResult.reason}", validationResult.throwable)