CVE-2017-20181 (published 2023-03-07T00:15Z)

A vulnerability classified as critical was found in hgzojer Vocable Trainer up to 1.3.0 on Android. This vulnerability affects unknown code of the file src/at/hgz/vocabletrainer/VocableTrainerProvider.java. The manipulation leads to path traversal. Attacking locally is a requirement. Upgrading to version 1.3.1 is able to address this issue. The name of the patch is accf6838078f8eb105cfc7865aba5c705fb68426. It is recommended to upgrade the affected component. The identifier of this vulnerability is VDB-222328.

CVSS v3 base score: 5.5, MEDIUM (CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N)

Weakness information:
cwe_id: CWE-22
cwe_name: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
description: The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.
extended_description: 
            Many file operations are intended to take place within a restricted directory. By using special elements such as ".." and "/" separators, attackers can escape outside of the restricted location to access files or directories that are elsewhere on the system. One of the most common special elements is the "../" sequence, which in most modern operating systems is interpreted as the parent directory of the current location. This is referred to as relative path traversal. Path traversal also covers the use of absolute pathnames such as "/usr/local/bin" to access unexpected files. This is referred to as absolute path traversal.
         
         

Fix information:
repo_url: https://github.com/hgzojer/vocabletrainer
commit_details: repo_url: https://github.com/hgzojer/vocabletrainer
author: Hans Georg Zojer
author_date: 2017-10-01 10:46:03+02:00
msg: Bugfix Path Traversal Vulnerability - see https://support.google.com/faqs/answer/7496913
repository: repo_url: https://github.com/hgzojer/vocabletrainer
repo_name: hgzojer/vocabletrainer
description: Vocable trainer for Android 14+ mobile phones with text field input und multiple choice test.
repo_language: Java
owner: hgzojer
file_changes: filename: AndroidManifest.xml
change_type: ModificationType.MODIFY
diff: @@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="at.hgz.vocabletrainer"
-    android:versionCode="9"
-    android:versionName="1.3.0" >
+    android:versionCode="10"
+    android:versionName="1.3.1" >
 
     <uses-sdk
         android:minSdkVersion="14"

programming_language: Ruby
filename: VocableTrainerProvider.java
change_type: ModificationType.MODIFY
diff: @@ -2,6 +2,7 @@ package at.hgz.vocabletrainer;
 
 import java.io.File;
 import java.io.FileNotFoundException;
+import java.io.IOException;
 
 import android.content.ContentProvider;
 import android.content.ContentValues;
@@ -13,11 +14,19 @@ import android.util.Log;
 public class VocableTrainerProvider extends ContentProvider {
 	
 	@Override
-	public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {       
-	     File cacheDir = getContext().getCacheDir();
-	     File privateFile = new File(cacheDir, uri.getLastPathSegment());
+	public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
+		try {
+			String cacheDir = getContext().getCacheDir().toString();
+			File privateFile = new File(cacheDir, uri.getLastPathSegment());
 
-	     return ParcelFileDescriptor.open(privateFile, ParcelFileDescriptor.MODE_READ_ONLY);
+			if (!privateFile.getCanonicalPath().startsWith(cacheDir)) {
+				throw new IllegalArgumentException();
+			}
+
+			return ParcelFileDescriptor.open(privateFile, ParcelFileDescriptor.MODE_READ_ONLY);
+		} catch (IOException e) {
+			throw new RuntimeException(e.getMessage(), e);
+		}
 	}
 	
 	@Override

programming_language: Java