iOS/Android Developer Security Basics
5 (4)

Click to rate this post!
[Total: 4 Average: 5]
Unsplash.com

I couldn’t find a single place that covers the mobile developer security (must know) basics, this will be again like a chat between two developers (Lulu ๐Ÿ‘ฉ๐Ÿผโ€๐Ÿ’ป) and (Sam ๐Ÿฆ–)

๐Ÿ‘ฉ๐Ÿผโ€๐Ÿ’ป: What are the risks of not having good security precautions? I can see we spend big money on security.
๐Ÿฆ–: There are over 500 reported incidents of data-breach each year, It’s estimated that each incident costs 3.5M~5.0M USD on average.
If you look at statistics, you can see that remote jobs increased these costs by 15%, since attackers would have more opportunities of attacking a target that is spread on different locations.

๐Ÿ‘ฉ๐Ÿผโ€๐Ÿ’ป: When people talk about security, the server is being presented as the main defense line, why would a mobile developer be concerned with security if the server/website is secure?
๐Ÿฆ–: Even if a website is securely developed and maintained, mobile apps still need to implement security best practices, while the server plays an important role, the client-side code in a mobile app can potentially expose users to risks if not developed securely, if the client is poorly written, you should expect a lot of attacks on the server.

Mobile apps have direct access to users’ sensitive data like location, contacts, files etc. on their devices, if an app is compromised, it could leak private user information, unlike browsers, mobile apps run locally on devices without the same protections of a browser sandbox, so vulnerabilities in app code could allow malicious actors to directly attack the device.

Many mobile attacks happen by exploiting vulnerabilities in how apps download and execute code. Developers need to ensure app updates and payloads come from verified, untampered sources.

As users spend more time in apps than browsers, mobile presents a larger attack surface. Security needs to be a priority throughout the development and deployment process on both frontend and backend.

๐Ÿ‘ฉ๐Ÿผโ€๐Ÿ’ป: But you are an iOS developer, and I develop for Android, would your tips and hints be applicable to Android too? oh, I almost forgot that both are based on Linux.
๐Ÿฆ–: wait, they are not both based on Linux, iOS is aย Unix-like Operating Systemย which isย based on Darwin(BSD)ย operating system, while Android is Linux-based Operating Systemย and is an open source mobile operating system, there are a lot of precautions that are applicable on both OSs.

๐Ÿ‘ฉ๐Ÿผโ€๐Ÿ’ป: I was asking myself in the past, why not rely on HTTPS and that’s it?
๐Ÿฆ–: HTTPS protects your data in transit between your client application to the server, but only if you can validate the TLS certificate has not been compromised.

๐Ÿ‘ฉ๐Ÿผโ€๐Ÿ’ป: What are the mobile weak points? what can be hacked?
๐Ÿฆ–: Network , Disk, USB Port, etc…

๐Ÿ‘ฉ๐Ÿผโ€๐Ÿ’ป: That looks like a lot of terminology, can you explain the basics?
๐Ÿฆ–: You will be good to go if you know these as a start.


TermBasic Explanation.
Authentication establish a userโ€™s identity
Authorizationgrant a user an access to a resource, look up the difference between Authorization and Authentication
Cryptographythe study of concepts like Encryption, decryption.
Encryptionmeans of securing digital data using one or more mathematical techniques, along with a password or “key” used to decrypt the information
Decryptionthe conversion of encrypted data to its original form.
Hashinga hash function is any function that can be used to map data of arbitrary size to fixed-size values, used mainly for fingerprinting.
Forensicsa branch of digital forensic science pertaining to evidence found in computers and digital storage media.
Sniffingprocess of monitoring and capturing all data packets passing through given network
HTTPSHypertext Transfer Protocol Secure, a web protocol
SSLSecure Sockets Layer
TLSTransport Layer Security (TLS)
IP SpoofingIP spoofing is the creation of Internet Protocol (IP) packets which have a modified source address in order to either hide the identity of the sender
Reverse Engineeringis a process in which software, machines, aircraft, architectural structures and other products are deconstructed to extract design information from them.
MITMMan in the middle, itโ€™s a type of a cyber attack where they secretly relay and possibly alter the data between two parties.
XSSCross Site Scripting (XSS)
SQL Injection:Read About it here.
OWASPOpen Web Application Security Project (OWASP)
MASVSMobile Application Security Verification Standard, itโ€™s a sister project of OWASP Mobile Security testing guide.
Binarya non-text encoded file
Mach-O binaryUnder NeXTSTEP, OPENSTEP, macOS, and iOS, multiple Mach-O files can be combined in a multi-architecture binary
Basic Terminology


๐Ÿ‘ฉ๐Ÿผโ€๐Ÿ’ป: Why would people with a jailbroken device be a threat on the app itself, a jailbreak only make the user hackable, right?
๐Ÿฆ–: No, The best practice, is to prevent people with Jailbroken devices from running your app, see my x04_checker repo, iOS Developers can use it to prevent jailbroken devices from running their applications.

Jailbreaking is the process of exploiting the flaws of a locked-down electronic device to install software other than what the manufacturer has made available for that device. It allows the owner to gain full access to the root of the operating system and access all the features, you must know that 100% jailbreak detection is not possible, we need to make (bypassing jailbreak detection) time-consuming, because an attacker can steal the developer info, and thus steal the app info.

Say a banking app has insufficient security on a jailbroken phone that is compromised, it could result in costly consequences for the banking app operator. For instance, if a user’s money is stolen due to their mobile banking app being hacked as a result of the jailbroken phone, the bank may need to reimburse the user even though it was not necessarily the bank’s fault.

This is because banks often guarantee protection of users’ money from theft, so a breach of security on the mobile app that enables theft could trigger the bank’s reimbursement responsibilities regardless of the root cause being the jailbroken phone.

Similarly, social media or other apps with user accounts could face defamation lawsuits if inadequate security on a compromised mobile app allows hackers to use a user’s account without their consent due to the jailbroken phone.

In such scenarios, the app operator may have to bear costs due to reputational or legal risks, despite the primary vulnerability being the jailbroken phone.

๐Ÿ‘ฉ๐Ÿผโ€๐Ÿ’ป: They say debugging and print statements can be a security vulnerability, is this true?
๐Ÿฆ–: Print normally only works on development builds, print will still send the data to the usb interface.

As you mentioned print, It’s a heavy command though, even if your debugging device is not connected in debug mode with Xcode, leaving print statement of heavy objects might make your app slower during development, but anyway, this is not our topic.

Keep in mind, NSLog will be left even in Distribution builds, any normal user can see the logs using the macOS console app, I used them when debugging opening the app using a notification when it’s terminated, this is not easy to do in Xcode directly, anyway, just use NSLog carefully, and treat the error log files with care, don’t log sensitive data, or leave trace of code symbols.

With regards to logging on mobile apps, a common security concern is the potential leakage of personally identifiable information (PII) about users. Sensitive data like users’ names, financial account details, physical locations and other personal information could inadvertently be written to log files if not properly scrubbed or encrypted.

This exposes the risk of PII being accessed and misused by unauthorized parties who gain access to the device’s logs. Such access could occur either after the fact if the device is stolen, or even in real-time if a hacker manages to achieve remote access. Proper handling of logging is important to prevent such PII leaks that can negatively impact users’ privacy and security.

๐Ÿ‘ฉ๐Ÿผโ€๐Ÿ’ป: What about certificate pinning?
๐Ÿฆ–: Certificate pinning simply prevents people from having the victim installing an incorrect certificate and making altered requests.

When implementing TLS pinning, bundling the certificate within the mobile app may not be the most suitable approach on its own. While including a default certificate is reasonable, the app should also incorporate the ability to dynamically update the pinned certificate if the server’s certificate expires or needs revocation. Any bundled certificate would also need to be encrypted in a way that prevents attackers from simply replacing the file on the device.

This is to ensure the certificate can be refreshed securely over time, while an attacker cannot tamper with the pinned certificate to circumvent TLS validation. A more robust TLS pinning implementation would account for eventual certificate changes on the server through a secure update mechanism within the app.

๐Ÿ‘ฉ๐Ÿผโ€๐Ÿ’ป: What about sensitive static strings?
๐Ÿฆ–: Never have your sensitive strings inside plist or any asset file, this is the most basic tip you should never miss.
๐Ÿ‘ฉ๐Ÿผโ€๐Ÿ’ป: Wait Sam, I downloaded a facebook apk online, and ran a simple command to scan the binary for strings that look similar to google api keys, that begin with AIz, and I can see this, any explanation why this is not hidden in the binary?

ย strings targetFile | grep "targetString"

using the strings command on macos

๐Ÿฆ–: There are multiple ways google makes sure that a request is authentic, from comparing hashes, to domain binding to bundle ids etc… again, you need to have your sensitive data hidden, this is not an excuse.

๐Ÿ‘ฉ๐Ÿผโ€๐Ÿ’ป: Why is it said to be risky to use 3rd party libraries when developing sensitive apps like banks?
๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป: In normal cases, libraries are fine, just make sure that they are being audited, NPM libraries had a lot of these, for sensitive apps, it’s better to avoid them altogether.

๐Ÿ‘ฉ๐Ÿผโ€๐Ÿ’ป: If I follow all of these tips, I will be completely secure?
๐Ÿฆ–: The sad news is, No, there are a lot of other attacks, like URL-scheme attacks, when you define a url scheme, your app responds to that scheme, so for instance, you create a scheme myapp://. all links starting with your scheme will directly launch your app. A universal link doesn’t include your scheme in the url but they will still launch your application, apple allows other apps to the register the same url.
๐Ÿ‘ฉ๐Ÿผโ€๐Ÿ’ป: the alternative is universal links?
๐Ÿฆ–: correct!

๐Ÿ‘ฉ๐Ÿผโ€๐Ÿ’ป: That was a huge amount of info for a starter, any final thoughts?
๐Ÿฆ–: 100% Security for any Application is not possible but we can try to make the attacking/cracking of iOS App as much harder as possible.

Security is not always about “make accessing the data impossible”. sometimes it is about cost and likelihood of retrieval versus importance of the data.

More tips on top of my head:

  • Avoid Objective-C if possible, itโ€™s very easy to reverse engineer.
  • Don’t write sensitive data into logs.
  • Disable Keyboard caching (3rd party keyboard)
  • Password/Pin should not be exposed during user interaction – Don’t include sensitive data in backup.
  • User Credentials should be stored in (keystore, keychainโ€ฆ).
  • App Transport Security – Certificate Pinning.
  • Integrity Check.
  • Prevent Running on rooted devices.
  • Detect JailBreak, (Jail Monkey library).
  • Use WebView carefully.
  • Securing Data on disk.
  • Securing Data across a network connection.
  • Secure application logic.
  • prevent Reverse Engineering (even if there is no sensitive data, if your app is novel, you don’t want people to see the code)
  • Don’t share sensitive data with 3rd party
  • Avoid keywords like (โ€œjailโ€,โ€securityโ€,โ€cydiaโ€,โ€aptโ€) in variable & function names
  • Hide the JB check deep in the app, not in appdelegateโ€ฆ
  • Some Jailbreaks are permanent, and are done by exploiting security flaws in hardware.

Easily Tiling Images in interface builder, without code !
5 (1)

Click to rate this post!
[Total: 1 Average: 5]
images, with and without tiling

Tiling images in interface builder directly without code is easy…

1- add an image into assets catalogue.
2- select the asset, go to “editor” menu, then choose “Show Slicing”.
3- the asset image will show up as darker, with a button labeled “Start Slicing”, and you will be able to select the slicing type.


4- select how you want the image tiled, in normal cases you will have the setup like this, zeroed Left, Right, Top and Bottom, and the Width & Height as the image dimensions.


5- for tilability, the image content mode should be fill, not fit.

Keep experimenting, and go wild with your Imagination, sample of playing with small tilable images I have..