-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Android ContentProvider Incomplete Permissions #10637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android ContentProvider Incomplete Permissions #10637
Conversation
Initial work on checking provider elements in Android manifests for complete permissions.
Initial commit for work on a query finding instances where the `mode` parameter of an override of the `openFile` method of the `android.content.ContentProvider` class
…al commit" This reverts commit e37f62b. The MisconfiguedContentProviderUse.ql file provided a sample query which will be useful in future checks for CVE-2021-41166, but is not needed for the current manifest-focused check
java/ql/src/Security/CWE/CWE-276/ContentProviderIncompletePermissions.ql
Fixed
Show fixed
Hide fixed
Follow the style suggestion from the github-code-scanning bot and remove provider element from alert link
...-tests/security/CWE-276/android/incomplete_provider_permissions/TestFull/AndroidManifest.xml
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CodeQL code itself looks good 👍, just some minor comments. This will need a docs review.
java/ql/lib/change-notes/2022-09-29-contentprovider-incomplete-permissions.md
Show resolved
Hide resolved
.../CWE-276/android/incomplete_provider_permissions/ContentProviderIncompletePermissionsTest.ql
Outdated
Show resolved
Hide resolved
java/ql/src/Security/CWE/CWE-276/ContentProviderIncompletePermissions.ql
Outdated
Show resolved
Hide resolved
java/ql/src/Security/CWE/CWE-276/ContentProviderIncompletePermissions.ql
Outdated
Show resolved
Hide resolved
java/ql/src/Security/CWE/CWE-276/ContentProviderIncompletePermissions.ql
Outdated
Show resolved
Hide resolved
java/ql/src/Security/CWE/CWE-276/ContentProviderIncompletePermissions.qhelp
Outdated
Show resolved
Hide resolved
QHelp previews: java/ql/src/Security/CWE/CWE-926/ContentProviderIncompletePermissions.qhelpMissing read or write permission in a content providerThe Android manifest file specifies the content providers for the application using RecommendationTo prevent permission bypass, you should create ExampleIn the following two (bad) examples, the provider is configured with only read or write permissions. This allows a malicious application to bypass the permission check by requesting access to the unrestricted operation. <manifest ... >
<application ...>
<!-- BAD: only 'android:readPermission' is set -->
<provider
android:name=".MyContentProvider"
android:authorities="table"
android:enabled="true"
android:exported="true"
android:readPermission="android.permission.MANAGE_DOCUMENTS">
</provider>
</application>
</manifest>
<manifest ... >
<application ...>
<!-- BAD: only 'android:writePermission' is set -->
<provider
android:name=".MyContentProvider"
android:authorities="table"
android:enabled="true"
android:exported="true"
android:writePermission="android.permission.MANAGE_DOCUMENTS">
</provider>
</application>
</manifest>
In the following (good) examples, the provider is configured with full permissions, protecting it from a permissions bypass. <manifest ... >
<application ...>
<!-- Good: both 'android:readPermission' and 'android:writePermission' are set -->
<provider
android:name=".MyContentProvider"
android:authorities="table"
android:enabled="true"
android:exported="true"
android:writePermission="android.permission.MANAGE_DOCUMENTS"
android:readPermission="android.permission.MANAGE_DOCUMENTS">
</provider>
</application>
</manifest>
<manifest ... >
<application ...>
<!-- Good: 'android:permission' is set -->
<provider
android:name=".MyContentProvider"
android:authorities="table"
android:enabled="true"
android:exported="true"
android:permission="android.permission.MANAGE_DOCUMENTS">
</provider>
</application>
</manifest>
References
|
Co-authored-by: Tony Torralba <atorralba@users.noreply.github.com>
Co-authored-by: Jami <57204504+jcogs33@users.noreply.github.com>
Co-authored-by: Tony Torralba <atorralba@users.noreply.github.com>
Merge the read-only, write-only, read-write, and full test cases into one AndroidManifest.xml file. Also added the not-exported test case.
Once the remaining comments are addressed, we can request a docs review @egregius313. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your patience in waiting on a review from the docs team. Great to have such clear references.
I've added some text suggestions based on my understanding from reading the help file. Very happy to discuss if I've misunderstood the intended meaning.
java/ql/src/Security/CWE/CWE-926/ContentProviderIncompletePermissions.qhelp
Outdated
Show resolved
Hide resolved
java/ql/src/Security/CWE/CWE-926/ContentProviderIncompletePermissions.qhelp
Outdated
Show resolved
Hide resolved
java/ql/src/Security/CWE/CWE-926/ContentProviderIncompletePermissions.qhelp
Outdated
Show resolved
Hide resolved
java/ql/src/Security/CWE/CWE-926/ContentProviderIncompletePermissions.qhelp
Outdated
Show resolved
Hide resolved
java/ql/src/Security/CWE/CWE-926/ContentProviderIncompletePermissions.ql
Outdated
Show resolved
Hide resolved
Co-authored-by: Felicity Chapman <felicitymay@github.com>
Co-authored-by: Felicity Chapman <felicitymay@github.com>
Co-authored-by: Felicity Chapman <felicitymay@github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update @egregius313
Add a query for checking for an exported
<provider>
element inAndroidManifest.xml
which has improperly configured permissions.Cf. GHSL Research, CVE-2021-41166