Connect with us

Security

Malicious SQLite Databases Used to Compromise Applications

back up data

Databases, which are designed to make it easy to store and access data, uses a set structure for data storage, and the Structured Query Language (SQL) allows a user to query the database and extract information from it.

And SQL is a very powerful language. In fact, it is Turing complete, meaning that any computer program could potentially be implemented in SQL. However, the power of the SQL language and its access to potentially sensitive information make it a common target of attack.

SQL injection attacks are one way of targeting databases via SQL. SQL queries commonly intermingle commands with input provided by the user. SQL injection attacks take advantage of this by providing input that is deliberately formatted to make data be interpreted as SQL commands. A recent talk at theDEF CON cybersecurity conference demonstrates another way in which SQL databases can be abused.

By using a malicious SQLite database, a hacker can take a variety of different actions, including compromising the legitimate applications that rely on these databases.

Introduction to SQLite

Several implementations of databases compliant with the SQL language exist. However, SQLite is an extremely popular one due to its “liteness”. Unlike most SQL databases, SQLite databases are completely self-contained within a single file on disk. SQLite is implemented as a C library and does its job very well. As a result, it is built into many different applications, including all mobile phones and many different types of computers. The heavy reliance of applications on the data stored within SQLite databases make them a promising target for hackers.

Exploiting Apps Through SQLite

While SQL injection attacks exist, some applications may assume that data in a database is valid. However, this assumption makes them vulnerable to attack.

In his DEF CON talk, Omer Gull provided a couple of case studies in how a malicious SQL database could be used to compromise applications. One example dealt with the fact that SQLite is embedded in all mobile phones and is commonly used by iOS applications.

Apple is well-known for its strict security model when it comes to applications. In order to run on an iOS device, an application has to be digitally signed. However, the same is not true of all files on iOS. SQLite databases, which are used by a variety of different applications, do not require digital signatures.

Gull took advantage of this by modifying the Contacts database on iOS to contain malicious code. When the Contacts process tries to query the SQL database, it runs the code injected by the attacker.

This ability to run malicious code on the device has multiple different applications for a hacker. Beyond the ability to steal sensitive data from the device (the code is present in a database), the code can be used to add persistence to malware or even to elevate its privileges. If the user identified and deleted malware running on the device, the malicious SQL code could reinstall it.

Privilege escalation can occur since multiple processes use the Contacts database and they have varying levels of privileges. For example, an attacker may manage to modify the database through access to the Contacts application. However, Facetime and WhatsApp also use this database. When they query the database and execute the malicious code, it may give the attacker access to the device’s camera and
microphone.

Protecting Applications from Malicious Databases

SQLite databases are a common feature in many platforms and applications – iOS and Android both use them as well as a host of different desktop applications. As demonstrated by Gull, iOS Contacts, WhatsApp, FaceTime, Springboard, and Telegram all depend on a single database and could be targeted by this attack.

The use of a malicious SQL database to compromise legitimate applications is a significant security concern. The proof of concept created by Omer Gull clearly demonstrated that an attacker could bypass the security protections put in place by Apple to protect iOS products. While Apple has fixed the issues identified by Gull, the same is not necessarily true of a variety of different software products.

Applications that rely upon SQLite databases need to have the ability to monitor these databases and ensure that they have not been corrupted by hackers. Accomplishing this is an important component of a data security solution. By monitoring access to the database and scanning for any anomalous inputs, the solution can alert the organization if an attempt to corrupt an SQLite database (through SQL injection or other means) has been made.

Organizations may also want to consider the use of runtime application self-protection (RASP) for the protection of applications that rely on external sources of data (like SQLite databases). RASP is designed to provide individualized protection of an application, monitoring its inputs, outputs, and behavior in order to identify any anomalies that could be indicators of an attack. The malicious input stored in SQLite databases and used in this attack would definitely be anomalous and could be prevented using a RASP solution.

Databases have become a core component of many applications, and the power of the SQL language and the trust placed in these databases is often overlooked from a security perspective. The new techniques described by Gull are only a taste of what is possible when misusing SQL, and organizations need to take the appropriate steps to secure their software and systems against these new types of attacks.

BusinessBlogs is the popular online Hub for quality business articles. We publish unique articles and share them with our social followers. Read more on our 'About' page https://businessblogshub.com/about/

Continue Reading

Trending