signalapp / Signal-Android

A private messenger for Android.
https://signal.org
GNU Affero General Public License v3.0
25.59k stars 6.14k forks source link

Signal adds the wrong country code on received SMS with dual-sim phone #8838

Closed AlexandreBonneau closed 2 years ago

AlexandreBonneau commented 5 years ago

Bug description

When using a dual-sim phone, classic SMS non-signal messages are received and the wrong country code is applied to those, effectively splitting the conversation with contacts that do not use signal in two threads, one where you receive their message (with the wrong country number), and one where you send the message to the correct number.

Steps to reproduce

Actual result: Signal sort that sms under the +3387112233 number. And if you try to answer in that thread, Signal tries to send your response to that unknown number. Expected result: Signal should detect that the number is coming from the French Polynesia network, and hence should sort it under the +68987112233 number thread.

Device info

Device: OnePlus 3 (ONEPLUS A3003) Android version: 8.0.0 Signal version: 4.40.4

Link to debug log

http://paste.debian.net/1084337/

alan-signal commented 5 years ago

Now, being in the French Polynesia country, receive a classic SMS from a Polynesian number (ie. +689 87 11 22 33)

Which number was that message sent to?

AlexandreBonneau commented 5 years ago

The message was sent to the Polynesian number +689 87 65 43 21 This is 100% reproducible.

AlexandreBonneau commented 4 years ago

Any news on this? This is a pretty critical bug, since it has 2 consequences : 1) When you answer, you send your message to a wrong number (which is pretty bad for privacy, and cost-wise since you're contacting another country), and 2) You cannot follow a conversation with some numbers since you'll receive their message on the wrong number, but have to change of conversation thread to reply.

All in all it makes Signal useless in dual-sim configuration if one or two sims do not share the country code used to create the Signal account.

AlexandreBonneau commented 4 years ago

For info, this critical bug is still happening in version 4.55.8.

AlexandreBonneau commented 3 years ago

@greyson-signal regarding your comment on issue #9439, is there a way to check if the provider does not send a valid e.164 address? I would like to check since all my contacts have a country code set, and that would narrow the cause of the problem.

mueslo commented 3 years ago

Same issue on Signal 5.10.2 w/Xiaomi Mi 9T

novazur972 commented 3 years ago

I have the opposite problem. I am in Martinique (+596) and when I receive a message from someone in mainland France (+33), as our French telephone system replaces the international code with a 0, signal affects the local code (+596) replacing the sender's 0, so the number is wrong, and I cannot reply to it. See bug #11278

palday commented 3 years ago

This is also a problem with receiving verification texts from local numbers -- for example with delivery notification updates, I can't reply to say YES.

AlexandreBonneau commented 3 years ago

As of today, 5.20.4 still exhibit this critical bug. I've tried to find a way to check if the phone company sends "a valid e.164 address", however I couldn't find how exactly. Would you know how to check that?

greyson-signal commented 3 years ago

From what you're telling me, the Polynesian telcom is somehow sending SMS's with 'from' fields that don't have the country code. I don't think there's much we can do in this situation. If there's no country code, the only thing we can do is assume that it has the same country as your registered phone number.

As far as checking what the explicit 'from' field value is, I'm not sure. We don't and can't log it for obvious reasons. Maybe try another SMS app and see what happens?

palday commented 3 years ago

@greyson-signal It simply doesn't prepend the country code and relies on the network handling numbers without explicit country codes.

AlexandreBonneau commented 3 years ago

I'm not sure if signal does access the contact list, but perhaps it could try to match the phone number in the SMS with the user contact list, and use the country code found in that list (given the user has correctly entered all the country code for every numbers in its contact list)?

etienneroudeix commented 2 years ago

Hi there, I am experiencing the very same issue when receiving Mexican (+52) sms while my signal account is linked to a french (+33) phone number. Note that I also have a Mexican phone number and when I send a sms with it through Signal, i get the response with the bad indicator too, in another signal conversation.

martinst commented 2 years ago

I just moved to Australia and I am experiencing this critical bug as well. It prevents me from using Signal as the generic messaging app on my device. Please get this fixed, the bug was first reported over 2 years ago!

AlexandreBonneau commented 2 years ago

I managed to push my colleagues to use Signal, but this critical caveat turns their experience into a NO-GO unfortunately. (lots of Polynesian use dual-sim since we are both Polynesian and French)

Since Signal displays the contact photo, I'm guessing it has access to the contact list. Could it not check the existing numbers in the user contact list and match against that? (see my previous comment)

stale[bot] commented 2 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

AlexandreBonneau commented 2 years ago

This is still, unfortunately, very relevant.

mueslo commented 2 years ago

Lol, please undo

AlexandreBonneau commented 2 years ago

That stale bot is bonkers. Please re-open that (still) critical issue @alan-signal . Also, please remove the "wontfix" tag.

pievalentin commented 2 years ago

Yes I can confirm it's annoying. I have to make sure my contact have country codes otherwise signal would infer the wrong extension.

AlexandreBonneau commented 2 years ago

Do note that having the correct country codes in your address book does not fix the problem. 100% of my contacts have a country code set, but this still happens (but randomly now ; some work, others don't..).

My questions remains :

Since Signal displays the contact photo, I'm guessing it has access to the contact list. Could it not check the existing numbers in the user contact list and match against that?

cody-signal commented 2 years ago

I know this started as dual sim, but doesn't exactly sound like it's exclusive to dual sim. Do you know if that's the case and you need a device with dual sim to encounter it?

AlexandreBonneau commented 2 years ago

I know this started as dual sim, but doesn't exactly sound like it's exclusive to dual sim. Do you know if that's the case and you need a device with dual sim to encounter it?

That would be interesting to know. On my end at least I've seen that happen only with dual-sim setups.

@novazur972 in your comment:

I have the opposite problem. I am in Martinique (+596) and when I receive a message from someone in mainland France (+33), as our French telephone system replaces the international code with a 0, signal affects the local code (+596) replacing the sender's 0, so the number is wrong, and I cannot reply to it. See bug #11278

Do you use a dual-sim setup too?

tvelocity commented 2 years ago

Handling of country codes is still broken for SMS messages in Signal 5.35.3

Relevant issue: #7321

The default behavior by Signal in this is case is based on completely incorrect assumptions. Signal sees a phone number without a country code, and decides to prepend the country code from the user's registered account number. This assumption is completely invalid, as the user might be using a dual SIM phone, or a dual number SIM, or might have temporarily swapped his SIM due to traveling, etc. These can barely be considered edge cases - they are fairly common usage scenarios.

If a number's country code is unknown, then it is unknown, there is nothing that can be done about that. Trying to replace it with an arbitrary country code is not helpful and just leads to confusion and a clunky user experience.

For me, the expected behavior would be to leave the phone number alone, if the country code can't be reliably deduced. The user may add the correct country code if he decides to dial back, respond, attach the number to a contact, etc... A phone number without a country code is much preferable to a phone number with an incorrect country code. This is consistent with how other dialers and SMS applications handle phone numbers on Android.

AlexandreBonneau commented 2 years ago

I agree that adding a country code blindly is very bad, however since Signal has already access to the phone contact list, it stands to reason to use the information there to match the number without country code, with the same number already declared correctly with a country code in the contact list.

It's should work 99% of the time. The edge case here would be to have 2 different persons with the same 'number' but different country codes declared. In this case, you would not be able to deterministically know which one is the correct one. For this very specific case, then no match should be done.

pievalentin commented 2 years ago

This assumption is completely invalid, as the user might be using a dual SIM phone, or a dual number SIM, or might have temporarily swapped his SIM due to traveling, etc. These can barely be considered edge cases - they are fairly common usage scenarios.

I can confirm this is my scenario. While traveling, I tried to send a message to people I met to later realize that it was the wrong country code 😢

For me, the expected behavior would be to leave the phone number alone

Indeed that's the best behavior!

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

AlexandreBonneau commented 2 years ago

This issue is very much still alive (although indeed that issue is stale).

mueslo commented 2 years ago

This seems like such an easy thing to fix :/

girai46 commented 2 years ago

any hope to see this addressed?

jonathancross commented 2 years ago

I have had many issues with this on a single SIM phone. When traveling I swap SIM cards to match the new country. Incoming SMS in Portugal seem to often not have a country code specified, leading Signal to assume the country code of my Signal account (+41). Even if I add the Portuguese number to my contacts with the correct country code (+351) -- Signal will not match up these two numbers, but instead assume they are two different contacts. So incoming SMS in one conversation and outgoing messages in another. Can get even more complex with encrypted messages.

heviiguy commented 2 years ago

Ummm... why is this problem being ignored? It seems that many users (including me!) are being negatively affected by it.

codethief commented 2 years ago

@greyson-signal

If there's no country code, the only thing we can do is assume that it has the same country as your registered phone number.

No, the other option would be to not touch the phone number and let the user choose which SIM card to send it with. I wrote about this extensively 6(!) years ago, see https://github.com/signalapp/Signal-Android/issues/5078#issuecomment-223891837

@cody-signal

I know this started as dual sim, but doesn't exactly sound like it's exclusive to dual sim. Do you know if that's the case and you need a device with dual sim to encounter it?

Correct, it's probably not related to the dual SIM functionality but to the fact that Signal takes the country code of the number one registered with and adds it by default to all numbers of incoming text messages that don't come with a country code. Again, see the aforementioned #5078 .

-> Could you please reopen #5078 ?

greyson-signal commented 2 years ago

Hi there, given our future plans to remove SMS support, I'm gonna close this. Thanks!

heviiguy commented 2 years ago

"...future plans..."?? How far out into the future can we expect that this problem might finally be resolved? Meanwhile, it's still very much alive and causing problems for many Users.

jonathancross commented 1 year ago

"...future plans..."?? How far out into the future can we expect that this problem might finally be resolved? Meanwhile, it's still very much alive and causing problems for many Users.

It will never be "resolved". When SMS support is removed... like any day now, then this issue won't matter anymore.

novazur972 commented 1 year ago

The main advantage of signal is the fact of not having to distinguish between SMS and messaging. The day that signal no longer has the SMS functionality, it loses interest for very many users, and perhaps even for a large majority. Think carefully.

girai46 commented 1 year ago

The main advantage of signal is the fact of not having to distinguish between SMS and messaging. The day that signal no longer has the SMS functionality, it loses interest for very many users, and perhaps even for a large majority. Think carefully.

indeed. One of the reasons I started using signal over session was the fact signal could handle sms, so one less app to worry about.