Testing and Securing Android Studio Applications - podcast episode cover

Testing and Securing Android Studio Applications

Mar 08, 202521 min
--:--
--:--
Download Metacast podcast app
Listen to this episode in Metacast mobile app
Don't just listen to podcasts. Learn from them with transcripts, summaries, and chapters for every episode. Skim, search, and bookmark insights. Learn more

Episode description

This Book is the preface and table of contents from a book titled Testing and Securing Android Studio Applications. The book guides Android developers on debugging and securing their apps using Android Studio. It covers fundamental software security concepts, Android-specific security features, debugging tools (DDMS), vulnerability mitigation techniques, data privacy preservation, securing communications (HTTPS), authentication methods, and various testing methodologies. The authors provide practical examples and explanations, and the text also lists the book's reviewers and contributors. Additionally, it includes mentions of several external testing and security tools.

You can listen and download our episodes for free on more than 10 different platforms:
https://linktr.ee/cyber_security_summary

Get the Book now from Amazon:
https://www.amazon.com/Testing-Securing-Android-Studio-Applications/dp/1783988800?&linkCode=ll1&tag=cvthunderx-20&linkId=e11e0147a6507bc2f8f84326bdc4ae0c&language=en_US&ref_=as_li_ss_tl

Discover our free courses in tech and cybersecurity, Start learning today:
https://linktr.ee/cybercode_academy

Transcript

Speaker 1

Hey everyone, and welcome back to the Deep Dive. Today, we're diving headfirst into the world of Android app security. Oo exciting it is, right, We've got these excerpts from Testing and Securing Androids Studio Applications, so nice, and we're going to break it down figure out how to make sure that your Android apps are as secure as fort Knox. A mighty task, it is, but I think we can do it. You ready to get into it?

Speaker 2

Yeah, let's do it all right.

Speaker 1

So the book actually kicks off by talking about some core security concepts kind of like security one oh one. Yeah, that apply to all software, not just Android. Yeah, so things like access control, encryption, authentication.

Speaker 2

Yeah, the basics, the basics.

Speaker 1

It's interesting they emphasize this before even getting into like Android specifics.

Speaker 2

Yeah, it's really important to understand these kind of foundational pieces of security before you can even start to think about building a secure app. Yeah, because you know, we all have passwords, but what does it really mean for a password to be secure? What does it actually mean to authenticate yourself? How can you prove that you are who you say you are?

Speaker 1

Right?

Speaker 2

So those are the building blocks totally, and.

Speaker 1

The book actually quotes this guy, Boris Buyser, who's a software testing expert, and he says bugs lurk in corners and congregate at boundaries.

Speaker 2

Ooh, that's good.

Speaker 1

I feel like that's setting the stage for a whole lot of testing. It is.

Speaker 2

It means we to test everything, yeah, because those bugs are going to be hiden.

Speaker 1

Yeah. All right, so we've talked about some of the foundational concepts. Now let's actually talk about androids specifically.

Speaker 2

Okay.

Speaker 1

So Android seems to have like a multi layered approach to security.

Speaker 2

Yeah, it does.

Speaker 1

The book describes it as like an Onion architecture, oh, the Onion, yeah, which I thought was interesting.

Speaker 2

Yeah. It's a good way to think about it, because each layer adds an extra level of protection.

Speaker 1

Okay.

Speaker 2

So at the very core, you have the Linux kernel, which provides some of the most fundamental security features. Okay, and then on top of that you have things like app sandboxing, permissions, application signing.

Speaker 1

Okay, So let's break those down a little bit. What is sandboxing?

Speaker 2

Okay? So sandboxing basically means that each app lives in its own little isolated environment okay, and this prevents apps from interfering with each other or accessing data that they shouldn't have access to.

Speaker 1

Oh, so it's all about isolation.

Speaker 2

Exactly, It's all about isolation.

Speaker 1

Got it? Okay? What about permissions? Permissions those pop up every time I install an app, Yes.

Speaker 2

Every time on my phone. So permissions are how Android controls what an app can and can't do.

Speaker 1

Okay.

Speaker 2

So if an app wants to access your camera, it has to ask you for permission.

Speaker 1

First, okay. So it's like a check and balance.

Speaker 2

Exactly, It's a checks and balance the system.

Speaker 1

Gotcha, okay? And then what about application signing?

Speaker 2

Oh, application signing is how Android knows that an app is legitimate and that it hasn't been campered with. So every app that's published to the play Store has to be digitally signed, okay. And that's how your phone knows okay, I can trust this app.

Speaker 1

So it's basically like a guarantee that it can from, like a trusted source, a trust.

Speaker 2

It source, no one's messed with it.

Speaker 1

Right, Okay? Cool. So it seems like Android has a lot of built in security features. It does, but the book also talks about how smartphones are constantly connected and that kind of creates more opportunities for attacks.

Speaker 2

Right. Our phones are basically mini computers in our pockets. They're connected to the internet almost all the time. Yeah, so that just gives attackers more ways to try to get in.

Speaker 1

Okay. So let's say you are a developer, Okay, you're building an Android app. What are some of the common vulnerabilities that you need to watch out for.

Speaker 2

Well, the book talks about three really big ones. Okay, input validation, sequel injection, and intense spoofing. Okay, let's start with input validation. So imagine you have an app that has a form okay, and it's asking the user for their email address. Yeah, you need to make sure that the user is actually entering a valid email address. Oh okay, and not like trying to sneak in some malicious code or something.

Speaker 1

Is it like a pain to actually validate every single input it can be that a user could provide.

Speaker 2

But it's really important, okay, because without proper input validation, you're essentially leaving the front door to your app wide open. An attacker could exploit that to inject some harmful code or manipulate data to cast all sorts of problems.

Speaker 1

Okay, So input validation, that's something that developers really need to pay attention to absolutely. Okay. What about SQL injection?

Speaker 2

So? SQL injection is a classic attack that exploits vulnerabilities in how an app interacts with a database. So let's say you have an app that allows users to search for products in a database. An attacker could craft a malicious search query. Oh that, instead of returning search results, ends up deleting data from your database. Oh no, yeah, so it's a serious threat. Okay, the developers need to be aware.

Speaker 1

Of Okay, but are there ways to prevent it?

Speaker 2

Yes, thankfully there are using things like parameterized queries, which essentially separate the user input from the actual SEQL query itself.

Speaker 1

Okay, so it's like creating a barrier.

Speaker 2

Exactly, creating a barrier between the user's input and the sensitive part.

Speaker 1

Okay, gotcha, So input validation's sequel injection. Now what about intense spoofing.

Speaker 2

Woh, intense poofing sounds scary, it does?

Speaker 1

What is it?

Speaker 2

So? Intense spoofing is all about exploiting the way that Android apps can communicate with each other. Okay, So Android apps can send messages called intents to request actions or share information. An attacker can basically create a fake intent to trick an app into doing something it shouldn't.

Speaker 1

So it's like sending like a fake invitation to a party.

Speaker 2

Yes, exactly like that.

Speaker 1

Okay. So how can developers protect their apps against this?

Speaker 2

A couple of key things. One is to always use explicit intents whenever possible, okay, which means being very specific about which component should receive that intent. And the other one is to validate the data that's being received, make sure it's what you expect and that it hasn't been tampered with.

Speaker 1

Makes sense, all right? So I think we've covered a lot of ground here. We've talked about some foundational security concepts, how Android approaches security, and some of the most common vulnerabilities, the scary stuff. Yeah, but good to know, good to know. So I feel like we've built a pretty solid foundation here.

Speaker 2

We have. The walls are up, the doors are locked.

Speaker 1

All right, perfect, Now we need to think about protecting the data inside the house.

Speaker 2

Yes, that's next.

Speaker 1

So let's take a quick break and we'll be back to dive into the world of data privacy.

Speaker 2

Sounds good. So we've talked about building this secure house, right, thank you. Sure the walls are strong and the doors are.

Speaker 1

Locked, right, keeping those intruders out.

Speaker 2

Now, let's step inside and talk about protecting the valuables, those precious possessions. Data.

Speaker 1

Data privacy. It's such a hot topic these days, and for good reason. Users are trusting these apps with more and more of their personal information. Oh yeah, absolutely, So we really got to make sure we're treating it with care.

Speaker 2

Yeah, it's like being a bank. You need to make sure that you're keeping your customer's money safe.

Speaker 1

Right. So the book talks about all the different storage options available and Android. There's shared preferences, internal storage, external storage databases, so many ops. It's like a whole storage unit, it is, and you.

Speaker 2

Have to check the right storage unit for the right thing exactly.

Speaker 1

So let's start with shared preferences. I use this all the time for like user settings or app settings. Yeah, simple stuff. Are there any security risks with those?

Speaker 2

Well, Shared preferences are really convenient for those small bits of data. Yeah, but they're not the best choice for sensitive information because by default, the data that's stored and shared preferences is unencrypted, ah, which means it's basically visible to anyone who has access to the device.

Speaker 1

So, like, if I'm storing a user's password or apike shared preferences are out of the question.

Speaker 2

Definitely, you need a more secure storage option for that.

Speaker 1

Okay, So what about internal storage? Is that a step up?

Speaker 2

Internal storage is definitely more secure okay, because the data is stored in your app's private data directory Okay, and boxed and generally inaccessible to other apps. Gotcha, unless they have root access to the device.

Speaker 1

But what happens if an attacker gets root access?

Speaker 2

Well, if an attacker has root access, then it's basically game over. Oh no, they can access pretty much anything on the device.

Speaker 1

So even with internal storage, it's not a guarantee.

Speaker 2

Right, That's why we need encryption.

Speaker 1

Okay, So encryption is important no matter where we're storing it. Yes, what about external storage like an SD card?

Speaker 2

So external storage is typically used for data that's not specific to your app okay, so things like media files that you want users to be able to share. Yeah, but it's also the least secure option.

Speaker 1

Yeah, it seems like it because.

Speaker 2

Anyone can access it. So never store sensitive data on external storage makes sense?

Speaker 1

Now, what about databases?

Speaker 2

Databases are great for storing larger amounts of structured data, okay, and they offer a really good level of security, especially when you combine them with encryption.

Speaker 1

Always got to encrypt. So you keep mentioning encryption, Can you explain what it is and why it's so important?

Speaker 2

Yeah. So encryption is basically scrambling data into an unreadable format so that anyone who doesn't have the key to unscramble it just seems gibberish.

Speaker 1

So even if someone gets the data, it's useless without that key.

Speaker 2

Exactly.

Speaker 1

Okay, cool. Now you mentioned before there's like two types of encryption, symmetric and asymmetric. Yeah, can you break those down?

Speaker 2

Yeah. So symmetric encryption is like having one key that locks and unlocks the treasure chests. Okay, so anyone who has that key can access the data, gotcha. Asymmetric encryption is like having two keys, a public key and a private key.

Speaker 1

Okay.

Speaker 2

You use the public key to encrypt the data and the private key to DECRYPTI.

Speaker 1

Gotcha.

Speaker 2

So you can give anyone the public key, but only the person with the private key can actually see the data.

Speaker 1

It's like a super secret decoder ring exactly. But even with encryption, we still have to make sure those keys are safe.

Speaker 2

Right, absolutely. Key management is just as important as encryption itself.

Speaker 1

Okay, so what are some best practices for that.

Speaker 2

Ideally you want to avoid storing encryption keys directly on the device, Okay, If possible, you should send them to a secure server. So keep them somewhere else, Yeah, separate from the data.

Speaker 1

It makes sense. Well, what if, like sending the keys to a server isn't possible.

Speaker 2

Well, another option is to generate the key based on a password that the user has to enter each time they start the app. Okay, So the key is never actually stored anywhere permanently. Tatscha, but it's recreated each time.

Speaker 1

Interesting.

Speaker 2

Yeah, it's more secure, but it could be a little bit more inconvenient for the user.

Speaker 1

Right. It's always a balancing act, always a balancing act. Okay. So we've talked about protecting data at rest, Right now we got to think about protecting data when.

Speaker 2

It's moving around, data in transit.

Speaker 1

Yeah, exactly. And I think this is where HGTPS comes in.

Speaker 2

Yes, HGTTPS is our.

Speaker 1

Friend, right. I always see that little pad luck in the address bar. Yes, I feel like it makes me safe.

Speaker 2

It does. It means that the communication between your browser and the website is encrypted okay, So anyone who's trying to easdrop can't see what's being sent.

Speaker 1

So it's like sending a postcard versus sending a sealed letter, right exactly. So if I'm building an app that handles sensitive data, HTTPS is a must.

Speaker 2

It is absolutely essential.

Speaker 1

So I'm kind of curious, how does HTTPS actually work? What's going on behind the scenes.

Speaker 2

Well, HTTPS is actually a combination of the standard HTTP protocol okay and something called SSL or TLS.

Speaker 1

Okay, SSL, we talked about that before, right, like when we were talking about certificates.

Speaker 2

Yes, you write, SSL stands for Secure Sockets Layer okay, and TLS is Transport Layer Security okay, which is basically a newer, more secure version of SSL.

Speaker 1

Gotcha.

Speaker 2

But they both do essentially the same thing, which is to encrypt the communication between your app and a server.

Speaker 1

So they're like the bodyguards for our data.

Speaker 2

Yes, protecting it from those prying eyes.

Speaker 1

I like that. So when an app establishes an HTTPTS connection, what actually happens.

Speaker 2

There's a handshake process okay, where the app and the server agree on which encryption algorithms to use and they exchange keys.

Speaker 1

Okay, So it's like a secret meeting.

Speaker 2

Yeah, the secret means.

Speaker 1

To make sure they're on the same page, and once that connection is established, then all the data.

Speaker 2

Is encrypto exactly. It's like a secret tunnel.

Speaker 1

Okay. Cool. So we talked about certificates before, and I remember you mentioned a tool called key Tool. Yes, what is that and how does that play into this?

Speaker 2

So digital certificates are like electronic passports that verify the identity of a website or a server, and key tool is a tool that you can use to create your own self signed certificates.

Speaker 1

So like, if I'm a developer just getting started, I can create my own certificates to play with.

Speaker 2

Yes, exactly, and the book actually shows you how to do that. Awesome bo through the command line and through Android studio.

Speaker 1

Okay, handy, But even with HTTPS and certificates, things can still go wrong, right unfortunately?

Speaker 2

Yes, okay. Sometimes you might encounter a certificate that's self signed, or it was issued by a certificate authority that's not recognized by Android.

Speaker 1

So it's like having a passport from a country that Android doesn't trust.

Speaker 2

Exactly. Yeah, in those cases, you need to explicitly tell your app to trust that certificate. Oh okay, otherwise you'll get an error.

Speaker 1

So we have to be careful about which certificate.

Speaker 2

Sweet, it's very careful. Always double check and make sure you're handling them correctly.

Speaker 1

Awesome advice. Okay, so we've covered a lot today, data at rest, data in transit, lots of security.

Speaker 2

Measures, players upon layers.

Speaker 1

But we can't forget about one of the most important aspects of any secure system, which is authentication. Making sure we know who's at the door before we let them in.

Speaker 2

Yes, we've built the house, we've protected the valuables. Now we need to hire a good bouncer.

Speaker 1

Right, we'll be right back to talk all about authentication. Welcome back to the deep dive. We've talked about building a secure foundation, protecting data at rest and in transit, lots of layers. Now it's time to make sure we've got a.

Speaker 2

Strong front door authentication.

Speaker 1

Yes, so let's talk about some of the most common authentication methods out there.

Speaker 2

Right.

Speaker 1

The book starts with the classic, the tried and true username.

Speaker 2

And password, the old standby.

Speaker 1

But I feel like everyone knows this is not the most secure method.

Speaker 2

Yeah, it's definitely got its weaknesses. Passwords can be stolen, they could be guessed they could be cracked.

Speaker 1

People are not great at picking good passwords. So what are some alternatives that we can use.

Speaker 2

Well, one that's becoming increasingly popular is multi factor authentication or MFA.

Speaker 1

Oh yeah, MFA, I've heard of that.

Speaker 2

It adds an extra layer of security, okay, by requiring users to provide more than just their password.

Speaker 1

Okay, So it's like having two locks on the door exactly.

Speaker 2

Okay, So even if someone gets passed the first lock, they still need another key to get in.

Speaker 1

Gotcha. So MFA usually combines something the user knows, like a password, with something they have like a physical token or a code sent to their phone, right, or even something they are like a fingerprint or a face scan.

Speaker 2

Biometrics biometrics, Yeah, those again popular.

Speaker 1

Yeah, they're super convenient.

Speaker 2

They are convenient.

Speaker 1

But are there any downsides to using them?

Speaker 2

Yeah? There are some things to consider. For one thing, biometric data can be harder to change if it's compromised, that's true, And there are also privacy concerns about how that data is being collected.

Speaker 1

And stored, right, So always important to think about the trade offs. So the book actually walks through how to build a basic login system in Android. Okay, what are some key things developers should be thinking about when they're building something like that.

Speaker 2

Well, first and foremost, security has to be your top priority.

Speaker 1

Okay.

Speaker 2

Always use HTTPS to protect those credentials as they're being sent over the network, right, Never ever store passwords in plain text. Oh yeah, Always hash them using a strong hashing algorithm hashing.

Speaker 1

I remember we talked about that before. That's like a one way function, right exactly.

Speaker 2

You can't unscramble a hashed password, okay, So even if your database is compromise, the attacker can't actually see the passwords.

Speaker 1

Cool. Okay, And of course we already talked about MFA. That's always a good idea.

Speaker 2

Yeah, layers of security.

Speaker 1

Now, the book mentions something called account manager. What is that?

Speaker 2

So? Account manager is a class in Android okay that gives you access to the user accounts that are stored on the device. Okay, so things like Google accounts or accounts for other online services.

Speaker 1

It's like a central hub, gotcha, And you can use it to request authentication tokens you can, which is really cool.

Speaker 2

It is because it means the user doesn't have to enter their credentials over and over again. It just makes it smoother, much smoother.

Speaker 1

Okay. Cool, All right, so we've talked about authentication. Yeah, now let's move on to what I think is one of the most important parts of building secure software.

Speaker 2

Oh, I know what's coming.

Speaker 1

Testing.

Speaker 2

We have to test.

Speaker 1

We have to it's so important, it is. So the book talks about different types of testing unit testing. Yeah, let's start with UI testing. Why is that so important for security?

Speaker 2

Well? UI testing focuses on how a user interacts with the app's interface. Remember we were talking about those input validation vulnerabilities. UI testing can help.

Speaker 1

Us catch those, okay, So we can simulate a real user trying to break the app exactly and see if our input validation is actually working.

Speaker 2

Yes, And Android provides this great framework called UI Automator okay for creating automated UI tests.

Speaker 1

Cool, so we don't have to do it manually.

Speaker 2

Well, you can do it manually, but it's much easier to automate it. And there's also this cool tool called UI Automator Viewer okay, which lets you inspect the hierarchy of your.

Speaker 1

App's UI so we can see what's going on.

Speaker 2

Yeah, you can see all the different elements and how they're laid out.

Speaker 1

Okay, very cool. Now what about unit testing? How is that different?

Speaker 2

So unit testing is about testing individual components of your code in isolation. Okay, So you're not testing the whole app at once. Okay, you're testing each little piece.

Speaker 1

Gotcha? And Android uses j unit for.

Speaker 2

This, yes, Jane. It is the standard framework for unit testing in Java.

Speaker 1

Okay. But does Android have any like special tools or classes to help with that.

Speaker 2

It does. It has a bunch of classes and methods specifically for testing Android components. Cool, like activities and services.

Speaker 1

Oh, very cool. And you mentioned instrumentation before. What's that all about?

Speaker 2

So instrumentation is this really powerful mechanism that lets your test code interact with the app's life cycle. Okay, So you can start and stop activities, send simulated user inputs.

Speaker 1

So you have a lot of control. You have a lot of control, okay, awesome, And then j unit provides those assertions yes, to make sure that the app is doing.

Speaker 2

What we expect exactly.

Speaker 1

Now, the book also talks about mock objects. What are those?

Speaker 2

So mock objects are simulated versions of real objects Okay that your code might depend on. Okay, So, for example, if your code interacts with a database. You can create a mock database RCHA so that your tests don't actually have to connect to a real database. Makes sense, which makes your tests run much faster and more reliably.

Speaker 1

Right, because we don't want our tests to be dependent on like the network or something exactly.

Speaker 2

And there are some great libraries for creating mock objects.

Speaker 1

Cool like Machito.

Speaker 2

Machio's a popular one.

Speaker 1

Yeah, I've heard of that one. So we've got all these great tools and techniques for testing we do, but how do we actually run the tests?

Speaker 2

Well, Android Studio has a built in test runner Okay, that makes it super easy to run your tests and see the results.

Speaker 1

And it works with jone it.

Speaker 2

Yes, it integrates seamlessly with June It awesome.

Speaker 1

All right, So it seems like androids Studio has everything we need.

Speaker 2

It does, And there are also a bunch of external tools that you can use if you want.

Speaker 1

Oh yeah, the book mentions like spoon and robo Electric.

Speaker 2

Yeah, those are great for running your tests across multiple devices or on your computer without needing an emulator.

Speaker 1

Very cool. And then there's Monkey.

Speaker 2

Oh. Monkey Monkey is so much fun.

Speaker 1

It throws chaos at the app.

Speaker 2

It does It basically just simulates random user interactions seas if it breaks and seas if it breaks.

Speaker 1

That's awesome. Wow, this has been quite a deep dive has into the world of Android app security. We've talked about so much, so much, building a secure foundation, protecting data, secure communication, authentication, and of course testing everything. I feel like I've learned so much.

Speaker 2

Me too, And the biggest takeaway for me is that security is a journey, not a destination.

Speaker 1

That's a good way to put it.

Speaker 2

It's something you have to be thinking about constantly.

Speaker 1

Yeah, and always staying up to date with the latest threats. Awesome. Well, if anyone wants to learn more about the stuff we've talked about today, yeah, the book we've been using, Testing and Securing Android Studio Applications is a great resource.

Speaker 2

It is, and there's also a ton of information online and a really active Android developer community.

Speaker 1

So many resources. Awesome. Well, thanks for joining me on this deep dive.

Speaker 2

This was fun.

Speaker 1

I had a great time. Until next time, Happy coding everyone,

Transcript source: Provided by creator in RSS feed: download file
For the best experience, listen in Metacast app for iOS or Android