Reverse Engineering Flutter Apps: What You Need To Know?

Reverse engineering is one of the most notorious methods using which hackers exploit an application or software. If you're in the mobile app development industry and use Flutter for app development, you'd know the threat reverse engineering poses to apps.

While 100% protection from reverse engineering isn't possible, you can give the hackers a tough time trying to exploit your app. And this blog is there to help. Below, we'll discuss what reverse engineering is, is reverse engineering Flutter apps possible, and how you can protect Flutter apps from this threat. 

What is Flutter?

While most websites define Flutter as a framework for crafting cross-platform applications, it's much more than that. Flutter is a complete toolkit or SDK with everything (rendering engine, tools, UI library) a dev needs to create interactive cross-platform web, mobile, or desktop applications.

To craft cross-platform apps via Flutter, developers need to use Dart: a highly functional type of safe language created by Google. 

What is Reverse Engineering?

Reverse Engineering is the process of deconstructing software or a mobile app to access the source code and other crucial resources (API keys, URLs, etc.) of the application. Reverse engineering Flutter apps means deconstructing apps developed using the Flutter framework.

Organizations use reverse engineering techniques to learn more about their competitors and the features they're using and take inspiration or simply copy those features. This use case may sound okay. So, here's another one:

Hackers use reverse engineering to access source code, modify and create popular application replicas. The motive here is to bypass security, access premium features for free, and upload the app for mass adoption, which can be further used to capture and steal user data.

The above actions impact both the business and the users. For instance, businesses might lose invaluable business logic, and customers might lose money. Also, if your app is exploitable, the customers won't trust your business, reducing retention and, thus, revenue.

Is Reverse Engineering Flutter Apps Possible?

While the difficulty of deconstructing an application may vary from language to language and several other factors, almost all apps can be reverse-engineered. And apps built using Flutter are no exception.

Flutter apps can be statically or dynamically reverse-engineered using various open-source tools that simplify the job. For instance, MobSF is known for static and Frida for dynamic reverse engineering. 

However, reverse engineering Flutter apps may be more challenging than it may seem. Here's why:

The Dart Snapshot Format Changes a lot with Every Update

Dart is a new and evolving programming language. Because of this, the snapshot (containing data and compiled machine code) format keeps changing each time an update is launched, making it hard to reverse-engineer the app. So, if developers write a parser for data extraction, with every Dart update, it'll become outdated. And the entire process will have to be repeated.

Dart Frameworks are Linked in the Application Library Statically

Dart frameworks are linked into the Dart snapshots statically, which makes the reverse engineering process hard; here's how:

  • A bigger size of the snapshot makes the reverse engineering process more extensive. 
  • App code becomes hard to distinguish from framework code.
  • Internal function calls make it hard for developers to determine what a function does.

 

The Dart Code Depends on the Dart Virtual Machine for Execution

Because of this dependency, reverse engineering tools are unable to locate the function of Dart objects, making reverse engineering quite a task. Also, Dart Virtual Machine uses a custom ABI and layout, which makes the Dart code appear complex and difficult to decipher.

While reverse engineering Flutter apps is tough, it's not impossible. It means Flutter apps are at as much risk of being reverse-engineered as other apps. However, developers can take additional steps to make this process even harder and demotivate hackers from reverse engineering Flutter apps. Let's learn about that below.

Good Read: Why is Flutter the Ideal Framework for Optimum App Security?

How Can You Protect Your App’s Code Against Reverse Engineering?

Here's how:

1) Obfuscation

Reverse engineering involves using tools to access an application's source code. Hackers perform Flutter code analysis to understand how the code works and to manipulate it for their benefit. However, you can conceal your Flutter code using code obfuscation.

Obfuscation helps obfuscate or hide the class and function names. This way, even if the hackers access the source code, it won't make any sense, which will help enhance Flutter app security.

2) Secure the API Keys

Securing your API is essential for reverse engineering protection for Flutter. If your APIs are not secure, hackers can access the data in transit and use it for illicit purposes. To secure your APIs, you can implement restriction controls and restrict access to the APIs. Another thing you can do to protect your APIs is encrypt and decrypt API keys on runtime.

3) Flutter Jailbreak Detection

Developers must integrate the Flutter_jailbreak_detection package while developing the mobile app to secure the app from threats posed by rooted or jailbroken devices. Such packages help detect if the app is running on a compromised device, enabling you to take appropriate measures to mitigate potential threats.

4) Protect Network Connections

Information or data on the move is always at risk of being intercepted. However, you can stop this from happening using Transport Layer Protection (TSL.) Also, you can whitelist your domain, restricting any insecure traffic. Furthermore, you can implement certificate pinning, preventing hackers from accessing data using illegitimate certificates.

5) Ask for Necessary Permissions Only and Secure User Data

Ensure you're not adding any plugins or 3rd party components that ask for permissions from the user that aren't necessary. Otherwise, native APIs and hardware can be accessed.

While it's not ideal, certain apps store personally identifiable information (PII), auth tokens and similar information. This information can be manipulated if left unprotected. However, you can use Flutter's Flutter_secure_storage package, which uses Keystore to store information.

In addition, you can opt for Hive, a dart-specific package for preventing any tempering efforts and safely storing the data locally.

6) Protect Background Snapshots

There's a task switcher feature that captures and displays the last app state. This snapshot can potentially expose sensitive information. However, by using the secure_application package, developers can prevent this from being viewed and thus protect sensitive data.  

7) Securing the CI Infrastructure

The CI infrastructure is where the code is uploaded and integrated regularly. This infrastructure should be constantly monitored to identify any potential vulnerabilities. Also, the virtual machine must be updated to ensure the apps are running in a safe environment.

Wrapping Up

Flutter is one of the best, most secure, and most reliable cross-platform app development frameworks. But that doesn't make it immune to cybercriminals and attacks. So, developers must follow the steps before developing Flutter apps to protect against reverse engineering.

In addition to following the above steps, you can refer to Top Mobile App Security Best Practices to make your apps even more resilient to attacks.

FAQs

What is Reverse Engineering?

Reverse engineering is the process of decompiling or deconstructing a mobile app to understand its inner workings. While it can be used to learn how an app works and what features it uses, hackers leverage reverse engineering to fulfill their mal intentions.

How to Reverse Engineer Software?

While the actual reverse engineering process varies with the type of software you're using and other factors, here are the typical steps involved in reverse engineering:

1. Defining the objective
2. Acquiring the software, i.e., the binary of the application
3. Setting up the environment (gathering the required tools such as decompilers)
4. Static Analysis (analyzing the app's code when it's static)
5. Dynamic Analysis (running the app in VM and analyzing it)
6. Identifying the components (data structures, libraries, etc.)
7. Understanding the functionality or logic
8. Documenting the findings

Is Flutter Apps Secure?

Flutter is more robust regarding security features than other cross-platform app development frameworks. From data loss prevention to code injection and user authentication, Flutter has some of the best security features in place.

While Flutter is innately secure, it's still possible to reverse engineer Flutter apps. However, you can follow the abovementioned steps and make your app more resilient against such efforts.

 

Published on Jun 5, 2023
Abhinav Vasisth
Written by Abhinav Vasisth
Abhinav Vasisth is a certified ethical hacker and the security research lead at Appknox, a mobile security suite that helps enterprises automate mobile security. Abhinav has been a critical member of Appknox for 5 years, reinventing the standards of mobile app security against evolving threats. He is highly regarded in the industry for his expertise, speaks at various security conferences like PHDays, and has collaborated with numerous enterprises to safeguard their digital assets.
When he's not outsmarting hackers, he listens to metal music or is lost in books.

Questions?

Chat With Us

Using Other Product?

Switch to Appknox

2 Weeks Free Trial!

Get Started Now