CVE-2015-10076: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') (CWE-89)
value: A vulnerability was found in dimtion Shaarlier up to 1.2.2. It has been declared as critical. Affected by this vulnerability is the function createTag of the file app/src/main/java/com/dimtion/shaarlier/TagsSource.java of the component Tag Handler. The manipulation leads to sql injection. Upgrading to version 1.2.3 is able to address this issue. The identifier of the patch is 3d1d9b239d9b3cd87e8bed45a0f02da583ad371e. It is recommended to upgrade the affected component. The identifier VDB-220453 was assigned to this vulnerability.
CWE description: The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. Without sufficient removal or quoting of SQL syntax in user-controllable inputs, the generated SQL query can cause those inputs to be interpreted as SQL instead of ordinary user data.
CVSS v3 base score: 9.8
Published: 2023-02-09T23:15Z
Repository: https://github.com/dimtion/Shaarlier
Language: Java
Files changed: app/src/main/java/com/dimtion/shaarlier/TagsSource.java
Commit date: 2015-06-06 10:50:53 +0200
Commit message: Solve bug with tags (possible sql injection)

Diff: diff --git a/app/src/main/java/com/dimtion/shaarlier/TagsSource.java b/app/src/main/java/com/dimtion/shaarlier/TagsSource.java
index 3e6cc01..464961c 100644
--- a/app/src/main/java/com/dimtion/shaarlier/TagsSource.java
+++ b/app/src/main/java/com/dimtion/shaarlier/TagsSource.java
@@ -59,14 +59,16 @@ class TagsSource {
         ContentValues values = new ContentValues();
         values.put(MySQLiteHelper.TAGS_COLUMN_ID_ACCOUNT, masterAccount.getId());
         values.put(MySQLiteHelper.TAGS_COLUMN_TAG, tag.getValue());
 
         // If existing, do nothing :
+        String[] getTagArgs = {String.valueOf(tag.getMasterAccountId()), tag.getValue()};
+
         Cursor cursor = db.query(MySQLiteHelper.TABLE_TAGS, allColumns,
-                MySQLiteHelper.TAGS_COLUMN_ID_ACCOUNT + " = " + tag.getMasterAccountId() + " AND " +
-                        MySQLiteHelper.TAGS_COLUMN_TAG + " = '" + tag.getValue() + "'",
-                null, null, null, null);
+                MySQLiteHelper.TAGS_COLUMN_ID_ACCOUNT + " = ? AND " +
+                        MySQLiteHelper.TAGS_COLUMN_TAG + " = ?",
+                getTagArgs, null, null, null);
         try {
             cursor.moveToFirst();
             if (cursor.isAfterLast()) {
                 long insertId = db.insert(MySQLiteHelper.TABLE_TAGS, null, values);
                 tag.setId(insertId);

Vulnerable code:                 MySQLiteHelper.TAGS_COLUMN_ID_ACCOUNT + " = " + tag.getMasterAccountId() + " AND " +
                        MySQLiteHelper.TAGS_COLUMN_TAG + " = '" + tag.getValue() + "'",
                null, null, null, null);
Fixed code:         String[] getTagArgs = {String.valueOf(tag.getMasterAccountId()), tag.getValue()};

                MySQLiteHelper.TAGS_COLUMN_ID_ACCOUNT + " = ? AND " +
                        MySQLiteHelper.TAGS_COLUMN_TAG + " = ?",
                getTagArgs, null, null, null);