News for hackers. Stuff that matters.
Re:Hardening Cellular Basebands in Android by phh on Tuesday December 12, 2023 @05:59PM (#38619978)
I'd rather say the issue is NOT that basebands need hardening (ok they do need it), but that we should stop putting things there.

The article mentions parsing XML, doing DNS, IMS, TCP and IP stacks. As far as I know, all of those are down for one single purpose which is VoLTE (And VoWifi, and other related features which all go under the umbrella of "IMS"). On top of that, they also need to do IPSec (should be pretty safe) and SIP (gosh wait too much string handling). The remote Pixel security flaw few months ago was in that VoLTE stack.

This stack should NOT be in an embedded closed source un-auditable system. It should be in a "dumb" sandboxed opensource app in a sandboxed language.

This is exactly what I'm doing: https://github.com/phhusson/ims This is a FLOSS VoLTE + VoWifi[1] implementation for Android written in kotlin with no native code [2].

I'm not recommending it for anyone (I managed to make my first outgoing call with it yesterday), it has real issues (you do want baseband cooperation on various parts, like QoS or roaming to 3G, which I'm choosing to ignore), but I think software IMS is the way of the future.

In addition to security, this allows for a lot of de-obsoleting:

- It helps *a lot* for custom Android ROMs, and compatibility with annoying carriers

- I can integrate top-notch audio codecs (EVS) without breaking a sweat, and deployed for everyone in a jiffy (heck I don't even to reboot user's smartphone's to apply the change, I can just deploy it over Play Store)

- I can integrate modern voice improvements

- I can enable VoWifi on 3G smartphones (Granted, I'm not sure that's extremely useful)

- I can enable features that didn't exist when that smartphone model got released like Cross-Sim VoWifi (you have your french main SIM, you're in the US with a local eSIM, you can do VoWifi of the french SIM over the local eSIM to have cheap 4G voice calls)

I see some movement in AOSP source code that make me think Google will release an opensource IMS within two years, so I'm hopeful my work will be able to go to the trash.

[1] I'm kinda cheating for the wifi part, because it's provided by AOSP, I barely lifted the little finger to enable it. [2] Okay, I added rnnoise for the sake of having a denoising, but it's fixed-size-data-in fixed-size-data-out, so I feel safe there.

PS: I know that my knowledge of 3GPP is pretty thin, so if knowledgeable people want to tell me which parts will still need to remain in modem, I'm curious.

PS2: I'm putting this just in case: For GNU/Linux smartphones (or desktops with SIM card reader), you should be able to use that C+py stack to have userspace vowifi: https://github.com/phhusson/doubango

Re:Hardening Cellular Basebands in Android by numpad0 on Tuesday December 12, 2023 @08:03PM (#38621257)
I'm just guessing here; but the reason why it's not implemented in userspace, not written in Rust, not using IOMMU, BP is allowed full DMA, the system is split into AP and BP in the first place, etc etc, is probably because of lags those stuffs introduce - difficulty of meeting and maintaining required realtime constraints.

ALL of those desktop-derived event driven technologies, with deep call stacks and abusive use of interrupts, tend to run NOT like a marathon runner, but like an attention deficit man, and the latter is how you get choppy audio.

IIUC, Nokia in '00s already used an architecture that baseband OS and application OS(Symbian) would run on the same CPU, with RTOS below the application OS forcing regular switch to baseband or something, because baseband code is synchronized to physical IRL time, managing physical phenomena, and the user, can wait.

If anyone's going to move phone signaling and audio processing to AP, they'll have to first show the embedded guys that their fancy stuff is better than the existing realtime stuff, and is not an elaborate prank. Which, I think, isn't easy. I mean, one of news for Raspberry Pi 5 was addition of a programmable I/O processor for realtime/low-level tasks, not removal of.

Re:Hardening Cellular Basebands in Android by LoganDark on Wednesday December 13, 2023 @01:49AM (#38623557)
> the latter is how you get choppy audio

Tell me, if Discord can stream high-quality audio in real-time, what makes a phone call that much harder to handle, especially given how awful the sample rate is? Shouldn't an 8-bit micro from the 80s be able to handle that? Aren't there even already pieces of homebrew software for those micros that can handle audio of that quality?

Re:Hardening Cellular Basebands in Android by atoav on Wednesday December 13, 2023 @02:55AM (#38624000)
For me it feels just wrong? Why would we high-level-sandbox a basic functionality when we obviously know how to write safe software in other spaces in the low level? Think anything space, aviation or automotive.

If your remedy to writing bad software is "just put it into a sandbox", then who says that sandbox isn't bad software as well? So now you got bad software in a sandbox that may or may not be safe and is less performant than the low level variant. Maybe the software is bad in a kind that allows abuse despite the sandbox, congrats now your baseband lies to you.

The solution I like is to use strictly typed languages, formaly verified compliers, a ton of tests and fuzzing and above all: avoiding unnecessary complexity. Embedded programming sucks, but we have Ada, we have Rust and we have a chance to do things that are both safe and performant.

Re:Hardening Cellular Basebands in Android by eptcyka on Wednesday December 13, 2023 @05:47AM (#38625459)
Nobody is attacking interfaces of plane SBCs the way mobile basebands are being attacked out in the wild. They defensive architecting and programming for aerospace most often is entirely different from the defensive programming of things that have to contend with malicious input.
Re:Hardening Cellular Basebands in Android by bdd8f1df777b on Wednesday December 13, 2023 @06:25AM (#38625767)
> when we obviously know how to write safe software in other spaces in the low level? Think anything space, aviation or automotive.

I seriously doubt that those software is near any levels of safe. They are just not attacked as often.

> If your remedy to writing bad software is "just put it into a sandbox", then who says that sandbox isn't bad software as well?

Chromium has high quality coding, but they still sandbox their own code whenever they can. Security vulnerability results from the limit of humanity, so it cannot be eliminated by just willpower.

And to answer your question directly,

* Writing a sandbox is easier to get right than many other software. * Even if the sandbox itself is badly written and therefore has vulnerability, it must be combined with the vulnerability of the software it protects in order to achieve any attack. So sandboxing something always increase the difficulty of attackers and is a worthy investment from the viewpoint of security.

> The solution I like is to use strictly typed languages, formaly verified compliers, a ton of tests and fuzzing and above all: avoiding unnecessary complexity.

The relationship between these and sandboxing is not exclusive. One can and should do both of them.

Re:Hardening Cellular Basebands in Android by dvdkon on Wednesday December 13, 2023 @09:46AM (#38628073)
It's just as much software engineering as it is "politics". Baseband vendors could put in as much effort as aviation manufacturers, but they won't. The status quo of overcomplicated, insecure, buggy software is hard to change. So the only tenable approach is one that relies as little on baseband vendors cooperating.
Re:Hardening Cellular Basebands in Android by LoganDark on Wednesday December 13, 2023 @10:57AM (#38629243)
> Why would we high-level-sandbox a basic functionality when we obviously know how to write safe software in other spaces in the low level?

Why would we sandbox code against vulnerabilities rather than simply writing code without vulnerabilities? Because writing code without vulnerabilities is not possible to achieve 100% of the time.

I love Rust as much as the next guy, but you need to know how to use it, too. We're back to "just do it perfectly" again: write perfect code, using perfect languages with perfect compilers. In order to know how to do that, hire perfect employees. In order to hire perfect employees, you need a perfect interview process, etc. I'm sure this would be easy in a perfect world.

But do you have any idea how unrealistic this prospect is? About why you can't just place your trust in being able to write perfect code that has no bugs, and about why defense in depth is so important?

If you have no sandbox, you have to write code that contains zero vulnerabilities. If you cannot perfectly guarantee the complete absence of bugs, you cannot perfectly guarantee that your code contains zero vulnerabilities.

Re:Hardening Cellular Basebands in Android by GoatOfAplomb on Wednesday December 13, 2023 @02:21AM (#38623731)
> is probably because of lags those stuffs introduce

There is likely some truth to this, but I think the bigger reason for these things is that Qualcomm can't be arsed.

Re:Hardening Cellular Basebands in Android by phh on Wednesday December 13, 2023 @07:18AM (#38626278)
There are two lags to take into account. Lags at connection, and lags during the call.

Connection is what is very complicated to do safely, but once its setup, except for some signaling, it is much simpler [1].

The architecture used by some people (I wouldn't know exactly who does what, it's all muddy) is that the connection/signaling is done in application processor, but the Encoding/Decoding + RTP is done in baseband processor. You do get a bit of additional of lag at connection (but anyway you have an UI to show), but you can keep your real time audio guarantees.

[1] That's for volte. For vowifi, that's more complicated, but anyway talking about lags over wifi...

Re:Hardening Cellular Basebands in Android by the8472 on Wednesday December 13, 2023 @08:55AM (#38627368)
> I'm just guessing here; but the reason why it's not implemented in userspace, not written in Rust, not using IOMMU, BP is allowed full DMA, the system is split into AP and BP in the first place, etc etc, is probably because of lags those stuffs introduce - difficulty of meeting and maintaining required realtime constraints.

That doesn't seem likely. All those technologies (except userspace maybe) work fine for realtime constrains down to microseconds. If your constraints are in the nanoseconds (wireless signal processing stuff?) you probably have to use some local SRAM anyway and thus not need to touch the system memory.

Re:Hardening Cellular Basebands in Android by dwbehappy on Tuesday December 12, 2023 @06:44PM (#38620479)
Not to take away from your excellent work, but what the hell is the point of VoWifi ?

Why not just handle this with a well tuned user space app that runs on udp/whatever over any network connectivity you have already, whether it's wifi/cellular/pigeon carrier.

It seems like its an entirely US-centric thing, motivated by a] cost savings from not using data on the cell network (not a problem for most of the world who have unlimited data plans cheap enough for everyone to afford) and b] some kind of vendor feature contest/lock-in type incentives.

What is the selling point of it, I don't get it. WhatsApp/Facetime/Signal or similar voice calls are not perfect, they obviously do introduce some extra latency and inefficiencies compared to using that lower level data pipe, but it just strikes me as a very strange avenue for people to be going down with very marginal benefit (efficiency) but a ton of extra work.

EDIT: Btw if its not clear, I fully agree with you that it, whatever it is, should be in userspace as much as possible, and as an open standard, I'm just trying to figure out why this stuff has been introduced in this way at all.

Re:Hardening Cellular Basebands in Android by alufers on Tuesday December 12, 2023 @07:29PM (#38620970)
I used to live in an old apartment block with thick concrete walls, and away from a cellular base station. VoWifi was really helpful if I wanted to make calls from my home. I guess I could use WhatsApp/Facetime/Signal, but the insurance agent won't call me on WhatsApp from her landline phone :)

And it is not handled by an app on your phone, because of legacy reasons. I believe that, before LTE was introduced, 2G and 3G had a distinction between IP and voice traffic, so the baseband handled the voice transmission. Then they thought that LTE should be IP only and voice should be sent as VOIP over it, but it still had to be handled by the baseband for backwards compatibility with 2G and 3G. And then they came up with the idea that the VOIP traffic could also be piped over Wi-Fi (through the main processor of the phone), and so VoWi-Fi was created.

Re:Hardening Cellular Basebands in Android by numpad0 on Tuesday December 12, 2023 @08:42PM (#38621587)
I think it was lots of parallel development - some mid-to-late 3G phones had carrier hand-rolled Wi-Fi calling, some had femtocell support instead, LTE was to be just faster packet-only Internet mode for 3G, became its own thing too late which necessitated CSFB, and then Wi-Fi calling became reimplemented as part of standard, etc.
Re:Hardening Cellular Basebands in Android by thaumasiotes on Wednesday December 13, 2023 @05:24AM (#38625269)
> I guess I could use WhatsApp/Facetime/Signal, but the insurance agent won't call me on WhatsApp from her landline phone

Huh. I would expect that it's more common for the insurance agent to have WhatsApp (or equivalent) as the only option than it is for them to refuse to use it in favor of the telephone network.

Re:Hardening Cellular Basebands in Android by wtallis on Tuesday December 12, 2023 @07:27PM (#38620943)
WhatsApp, FaceTime, etc. all require both endpoints of a call to use that app. VoWiFi lets you receive calls to your regular phone number from any normal phone. The fact that the last mile of the call is being carried over WiFi becomes an invisible implementation detail.
Re:Hardening Cellular Basebands in Android by upofadown on Wednesday December 13, 2023 @07:44AM (#38626535)
The phones could just use the SIP protocol for voice. You don't need an accompanying chat app. The huge disadvantage of that is that the customer could then use any VOIP supplier for their phone calls. ... or none at all for SIP to SIP calls. That would create a competitive market in voice. A competitive market is the last thing any cell phone provider wants. They need to maintain their monopoly on the last mile connection.

This might be an interesting idea for a government interested in improving this particular market. Forbid the provision of anything but reasonable latency data by a last mile provider. Establish standards.

I note that jmp.chat, a provider of SMS and voice over internet connections, is toying with the idea of providing, pay as you go, data only plans as a complement to their primary service.

Re:Hardening Cellular Basebands in Android by phh on Thursday December 14, 2023 @04:59AM (#38639648)
VoLTE is literally SIP + IPSec + auth with SIM card (+ some pretty usual SIP optional extensions marked as required)
Re:Hardening Cellular Basebands in Android by BobbyTables2 on Tuesday December 12, 2023 @08:10PM (#38621310)
I think your concerns are misplaced.

Things like TCP/IP and DNS are child’s play compared to the complexity of cellular baseband firmware — even for just a single 2G/3G/4G standard.

The SIM card layer is also another nightmare in itself.

Re:Hardening Cellular Basebands in Android by eightysixfour on Tuesday December 12, 2023 @07:29PM (#38620969)
VoWifi is neither US centric nor purely about efficiency - it allows you to make calls with your phone to another phone via a third party network when you don’t have cellular connectivity.

For example if you have poor cell coverage at your home or office, you can still make and receive calls via a wifi connection using your phone number instead of forcing everyone to sign up for some third party service.

Re:Hardening Cellular Basebands in Android by lstodd on Tuesday December 12, 2023 @08:03PM (#38621254)
Well, this sort of reinforces the point - there are about zero places in Europe where you have Wifi but do not have cheap almost-unlimited 4G/LTE. In fact it's wifi that's dying out here, the only thing that keeps it alive is that in a cafe setting it's still somewhat faster, and it eats a bit less battery.
Re:Hardening Cellular Basebands in Android by eightysixfour on Tuesday December 12, 2023 @08:24PM (#38621449)
I’m not sure we are talking about the same thing - just because you have cheap unlimited 4G doesn’t mean you get that 4G signal in a basement. VoWifi lets you still call someone with your phone number when the signal is bad but you have wifi access…
Re:Hardening Cellular Basebands in Android by lstodd on Tuesday December 12, 2023 @08:53PM (#38621682)
I was never into insisting to only talk on the phone from the basement of my medieval castle. The view from the battlements is much better.

We're not all jamesbondesque supervillains here.

Like I said above, for like $8/mo you have in fact unlimited 4G at decent speeds here. Or for idk maybe $15 you can get a gpon, unlimited traffic, 30+Mbit to the house, depending on local laziness of course. And that is for a rural place in Balkans, not something in more civilized places.

Re:Hardening Cellular Basebands in Android by kelnos on Tuesday December 12, 2023 @09:42PM (#38621986)
I do love how, seemingly to counteract the US-centric nature of many discussions, some Europeans act as though Europe is this one homogeneous block where everything works the same everywhere.

I guarantee you there are quite a few people in various countries in Europe where they don't have great cellular coverage, whether because of their location, or because of the building materials used in whatever house or office building they spend a lot of time in.

Regardless, I don't really get the hate toward VoWifi. Like... it's an added option. In some cases it might be redundant (or worse than the normal VoLTE option), but... it's an added option, that you don't have to use, that can be a great fallback in some cases.

Re:Hardening Cellular Basebands in Android by macNchz on Tuesday December 12, 2023 @09:36PM (#38621948)
I just got back from a week in Paris where I frequently had limited cell service indoors on a major provider. Even with antennas all over there’s just a lot of masonry for signals to get through.

I’ve been really happy on many occasions to have Wifi calling, both where I live in NYC (where service sometimes behaves similarly to Paris) and the rural places I visit frequently (where having the cellular modem off while at home saves tons of battery vs constantly having no service).

Re:Hardening Cellular Basebands in Android by eightysixfour on Tuesday December 12, 2023 @09:19PM (#38621854)
Yes, and VoWifi lets your cell phone make a call over that fiber when your wireless coverage isn’t great. Not really sure where castles and battlements come to play here - there are plenty of completely normal places people visit with connectivity issues.

Maybe it is your experience in the rural balkans, where cellular congestion and significant building density aren’t factors, and your assumption it must be better in “civilized” places that is confusing the issue…

Re:Hardening Cellular Basebands in Android by sib on Tuesday December 12, 2023 @08:33PM (#38621513)
Europe is approximately 7% of the land surface area of the world. We don't all live in small, densely populated places :)
Re:Hardening Cellular Basebands in Android by lstodd on Tuesday December 12, 2023 @08:45PM (#38621611)
And US is 6.1% Your point?
Re:Hardening Cellular Basebands in Android by callalex on Wednesday December 13, 2023 @01:30AM (#38623452)
Would you describe the entirety of the US as “densely populated”?
Re:Hardening Cellular Basebands in Android by sib on Wednesday December 13, 2023 @02:33PM (#38633002)
My point is exactly what I said. There are lots of parts of the world where mobile service is not good (or available at all) because it's not economically sensible to build out coverage where populations are very low.

You wrote "there are about zero places in Europe where you have Wifi but do not have cheap almost-unlimited 4G/LTE" on a site with a global audience.

Re:Hardening Cellular Basebands in Android by iggldiggl on Thursday December 14, 2023 @12:18PM (#38643975)
And even where the connectivity is there, the "cheap almost-unlimited" bit might not necessarily be true – that, too, significantly varies from country to country.
Re:Hardening Cellular Basebands in Android by cyberax on Tuesday December 12, 2023 @08:35PM (#38621537)
That's not quite true. There are older buildings with brick walls that have bad cellular reception.

Conversely, some high rises have a too _good_ reception and the radio spectrum can get congested.

Re:Hardening Cellular Basebands in Android by lstodd on Tuesday December 12, 2023 @08:43PM (#38621589)
Where it does matter they put a femtocell which is about as complicated as a wifi AP.
Re:Hardening Cellular Basebands in Android by wrboyce on Wednesday December 13, 2023 @04:12AM (#38624638)
I live in the UK and pretty much rely on VoWifi to make/receive calls when at home. I can also think of a few places within an hours drive where my reception drops to “No Service”.

You are completely wrong in your assertions.

Re:Hardening Cellular Basebands in Android by klausa on Wednesday December 13, 2023 @12:01AM (#38622888)
I can make "regular" phone calls when on a different continent and on WiFi without paying any roaming fees.
Re:Hardening Cellular Basebands in Android by yxhuvud on Wednesday December 13, 2023 @04:40AM (#38624863)
> Not to take away from your excellent work, but what the hell is the point of VoWifi ?

The point is that your phone should continue to work even if you are deep inside a building without coverage. Or that you should have connectivity if you for some other reason have good wifi coverage but bad cellular.

Now, the protocol choices I won't defend, it is layers upon layers of complexity that I don't know enough to understand what is motivated or what is bad.

Re:Hardening Cellular Basebands in Android by jchw on Tuesday December 12, 2023 @09:43PM (#38621997)
Hey, that looks really cool. I've been wanting to mess around with this stuff on PinePhone, which is in a unique position here since there are third-party images for the baseband which are mostly open source[1].

I've been especially interested in trying to reverse engineer what's going on with Google Fi on Android, but it is definitely a bit over my head, given that until recently I didn't even really know what an AT command was :) I'm guessing since it's Google the carrier stuff is mostly for fallback and all of the actually interesting stuff is done using protobufs over a data connection. (Fi is also interesting because you can make phone calls on the web over WebRTC. I wonder if that's some kind of gateway to SIP, or what.)

[1]: https://github.com/the-modem-distro/pinephone_modem_sdk

(Note: I didn't dig deep enough, so it wouldn't surprise me if the blobs in this are actually where the interesting stuff happens, but it's still probably a great base for experimentation nonetheless.)

Re:Hardening Cellular Basebands in Android by posguy on Tuesday December 12, 2023 @11:45PM (#38622774)
The PinePhone uses a really old, slow modem (the Quectel EG25). Why not get a modern Snapdragon x62 like the RM520, drop it in a carrier board, root the modem and do all the shenanigans you want?

Useful links: https://github.com/natecarlson/quectel-rgmii-configuration-n...

https://github.com/carp4/qadbkey-unlock

Re:Hardening Cellular Basebands in Android by LoganDark on Wednesday December 13, 2023 @01:52AM (#38623569)
Because you can't use a Snapdragon in that way, that's not how Qualcomm's business works. There's a reason that very few (or no) "open" phones actually use Snapdragons and it's because it's impossible to obtain the firmware for these without layers of very restrictive contracts and NDAs. They're almost like NXP in that way.
Re:Hardening Cellular Basebands in Android by pomian on Tuesday December 12, 2023 @10:24PM (#38622260)
That looks great! I have a pixel 4xl that will not allow enabling VoWifi. (Maybe old sim card, maybe Graphene.) As you mentioned, great for other builds. PinePhone, etc. Going to try...
Re:Hardening Cellular Basebands in Android by LaF0rge on Friday December 15, 2023 @11:25AM (#38655675)
I've played with doubango for some time trying to get it to work against the flavor of IMS used in VoLTE / VoWiFi, and it is not all that close to it, even with various hacks applied from https://gitea.osmocom.org/ims-volte-vowifi/doubango/commits/... in which I tried to add a Linux kernel IPsec plugin as well as various other bits and pieces.