Open lcimeni opened 3 years ago
Update: The risk severity (CVSS score) of this finding has been modified from 7.3 to 9.99 by Lorenz Cimeni.
Powered by NowSecure Platform
Update: The risk severity (CVSS score) of this finding has been modified from 9.99 to 9.9999 by Lorenz Cimeni.
Powered by NowSecure Platform
Update: This finding has been marked as ‘Pass’ by Lorenz Cimeni, so no additional action required.
Powered by NowSecure Platform
Update: This finding has been permanently hidden by Lorenz Cimeni, so no additional action required.
Powered by NowSecure Platform
Finding Description
The application is vulnerable to Path Traversal attack, also known as Directory Traversal or Dot Dot Slash attacks. Traversal attacks within Android allow attackers to specify a file path outside of the application's intended context and access that file.
For example, instead of specifying the filename "filename.txt", the attacker might specify
../someOtherDir/secretFile.txt
and gain access to that file.This can allow an unauthorized actor to read and write files inside internal storage from outside the application directory to which they have access.
Steps to Reproduce
Verify the permissions of the app's content providers. If a content provider has
android:exported="true"
, verify its permissionandroid:protectionLevel
. If the protectionLevel has not been set or no permission has been set, then this provider may be vulnerable. The content provider that has insufficient permissions can then be used to attempt a path traversal attack by appending../
to the URI used for writing processes. The automated NowSecure test for this vulnerability attempts to perform a path transversal attack in the context of an application and in read/write files inside internal storage.Business Impact
This vulnerability can be used to compromise and expose sensitive user data on the device as well as gain enhanced access within applications.
Remediation Resources
Recommended Fix
When using content providers, it is necessary to validate the accepted inputs. These inputs can include those performed by users and by third party applications who have permission to access the app's content providers. Limiting inputs from trusted sources, along with preventing entries that contain file paths is necessary to prevent path traversal. In addition, setting permissions in the AndroidManifest can also limit access to providers. Details and code snippets can be found at https://developer.android.com/guide/topics/providers/content-provider-creating.
With regards to limiting permissions, setting
android:exported=”false”
in the AndroidManifests prevents other apps from accessing the provider. In cases where other apps need access to a provider, access should only be supplied to trusted apps using aandroid:protectionLevel=“signature”
. For more information regarding content provider permissions, details can be found here: https://developer.android.com/training/articles/security-tips#ContentProviders.If you cannot use the security features above, use well-structured data formats and verify that the data conforms to the expected format. While blacklisting of characters or character-replacements are sometimes an effective strategy, these techniques are often error-prone in practice and should be avoided when possible. For additional information, please see the following resource: https://support.google.com/faqs/answer/7496913?hl=en.
Code Samples
Good Code Example (.java)
Good Code Example (.kotlin)
Additional Guidance
Risk and Regulatory Information
Severity: high CVSS: 7.3
Application
See more detail in the NowSecure Report