Skip to content

Could they bypass all the intent checks? #3

@lowrebswrd

Description

@lowrebswrd

Hi, Michal. I'd like to ask one question. For an unpatched version of code corresponding to CVE-2023-45777.

https://android.googlesource.com/platform/frameworks/base/+/b0f6558fb36eb76df35c516ec5a65030a34a8734/services/core/java/com/android/server/accounts/AccountManagerService.java

Please look at the following code, you said getParcelable without the second typed parameter will return null. But getParcelable(AccountManager.KEY_INTENT,
Intent.class) will throw exception. as readValue will check the intent.class And the following 1,2,3,4 will not bypass the intent check. Am I right? I cannot understand it.


        private boolean checkKeyIntentParceledCorrectly(Bundle bundle) {
            Parcel p = Parcel.obtain();
            p.writeBundle(bundle);
            p.setDataPosition(0);
            Bundle simulateBundle = p.readBundle();
            p.recycle();
            Intent intent = bundle.getParcelable(AccountManager.KEY_INTENT);//1. intent will return null because it has an ingenious layout.
            if (intent != null && intent.getClass() != Intent.class) {
                return false;
            }
            Intent simulateIntent = simulateBundle.getParcelable(AccountManager.KEY_INTENT,
                    Intent.class); //2. As you know, it will throw exception because it cannot bypass the check of readValue() function. The process will crash. How could you reach 3. and all return null?
            if (intent == null) {
                return (simulateIntent == null); //3. Couldn't be here.
            }
            if (!intent.filterEquals(simulateIntent)) {
                return false;
            }
            if (intent.getSelector() != simulateIntent.getSelector()) {
                return false;
            }
            int prohibitedFlags = Intent.FLAG_GRANT_READ_URI_PERMISSION
                    | Intent.FLAG_GRANT_WRITE_URI_PERMISSION
                    | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION
                    | Intent.FLAG_GRANT_PREFIX_URI_PERMISSION;
            return (simulateIntent.getFlags() & prohibitedFlags) == 0;
        }
      
			
	      protected boolean checkKeyIntent(int authUid, Bundle bundle) {
            if (!checkKeyIntentParceledCorrectly(bundle)) {
            	EventLog.writeEvent(0x534e4554, "250588548", authUid, "");
                return false;
            }
            Intent intent = bundle.getParcelable(AccountManager.KEY_INTENT, Intent.class);  //4. Because the second typed parameter which is Intent.class not equal to array of SecImageClipData  will has an exception.
            if (intent == null) {
                return true;
            }
			

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions