CVE-2022-4903 (Java, published 2023-02-10T15:15Z)
Description: value: A vulnerability was found in CodenameOne 7.0.70. It has been classified as problematic. Affected is an unknown function. The manipulation leads to use of implicit intent for sensitive communication. It is possible to launch the attack remotely. The complexity of an attack is rather high. The exploitability is told to be difficult. Upgrading to version 7.0.71 is able to address this issue. The patch is identified as dad49c9ef26a598619fc48d2697151a02987d478. It is recommended to upgrade the affected component. VDB-220470 is the identifier assigned to this vulnerability.
Severity: nan (CVSS v3 base score: 8.1)
Weakness: CWE-668 \u2014 Exposure of Resource to Wrong Sphere
The product exposes a resource to the wrong control sphere, providing unintended actors with inappropriate access to the resource.
Repository: https://github.com/codenameone/CodenameOne
Files changed:
Ports/Android/src/com/codename1/impl/android/AndroidImplementation.java
Ports/Android/src/com/codename1/impl/android/CodenameOneActivity.java
Ports/Android/src/com/codename1/impl/android/PushNotificationService.java
Ports/Android/src/com/codename1/location/AndroidLocationPlayServiceManager.java
Ports/Android/src/com/codename1/media/BackgroundAudioService.java
Commit message: Fixed #3583 Pending Intent vulnerability


Vulnerable code:
    
            PendingIntent contentIntent = PendingIntent.getActivity(context, requestCode++, newIntent, PendingIntent.FLAG_CANCEL_CURRENT);
        PendingIntent contentIntent = PendingIntent.getActivity(getContext(), 0, notificationIntent, 0);
            PendingIntent pendingIntent = PendingIntent.getService(context, 0,
                    intent,
                    PendingIntent.FLAG_UPDATE_CURRENT);
        PendingIntent pendingContentIntent = PendingIntent.getActivity(getContext(), 0, contentIntent, PendingIntent.FLAG_UPDATE_CURRENT);
        PendingIntent pendingIntent = PendingIntent.getBroadcast(getContext(), 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
        PendingIntent pendingIntent = PendingIntent.getBroadcast(getContext(), 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
        registrationIntent.putExtra("app", PendingIntent.getBroadcast(this, 0, new Intent(), 0)); // boilerplate
        unregIntent.putExtra("app", PendingIntent.getBroadcast(this, 0, new Intent(), 0));
    
            PendingIntent contentIntent = PendingIntent.getActivity(this, 0, newIntent, PendingIntent.FLAG_CANCEL_CURRENT);
                            PendingIntent pendingIntent = PendingIntent.getService(context, 0,
                                    intent,
                                    PendingIntent.FLAG_UPDATE_CURRENT);
            PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
            PendingIntent pendingIntent = PendingIntent.getService(context, 0,
                    intent,
                    PendingIntent.FLAG_UPDATE_CURRENT);
                            PendingIntent pendingIntent = PendingIntent.getService(context, 0,
                                    intent,
                                    PendingIntent.FLAG_UPDATE_CURRENT);
            geofencePendingIntent = PendingIntent.getBroadcast(AndroidNativeUtil.getContext().getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
            PendingIntent pendingIntent = PendingIntent.getService(context, 0,
                    intent,
                    PendingIntent.FLAG_UPDATE_CURRENT);



        PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, mediaButtonIntent, 0);

Fixed code:

    public static PendingIntent createPendingIntent(Context ctx, int value, Intent intent) {
        if (android.os.Build.VERSION.SDK_INT >= 23) {
            // PendingIntent.FLAG_IMMUTABLE
            return PendingIntent.getActivity(ctx, value, newIntent, 67108864);
        } else {
            return PendingIntent.getActivity(ctx, value, newIntent, PendingIntent.FLAG_CANCEL_CURRENT);
        }
    }

    public static PendingIntent getPendingIntent(Context ctx, int value, Intent intent) {
        if (android.os.Build.VERSION.SDK_INT >= 23) {
            // PendingIntent.FLAG_IMMUTABLE
            return PendingIntent.getService(ctx, value, newIntent, 67108864);
        } else {
            return PendingIntent.getService(ctx, value, newIntent, PendingIntent.FLAG_CANCEL_CURRENT);
        }
        PendingIntent.getService
    }

    public static PendingIntent getBroadcastPendingIntent(Context ctx, int value, Intent intent) {
        if (android.os.Build.VERSION.SDK_INT >= 23) {
            // PendingIntent.FLAG_IMMUTABLE
            return PendingIntent.getBroadcast(ctx, value, newIntent, 67108864);
        } else {
            return PendingIntent.getBroadcast(ctx, value, newIntent, PendingIntent.FLAG_CANCEL_CURRENT);
        }
        PendingIntent.getService
    }

            PendingIntent contentIntent = createPendingIntent(context, requestCode++, newIntent);
        PendingIntent contentIntent = createPendingIntent(getContext(), 0, notificationIntent);
            PendingIntent pendingIntent = getPendingIntent(context, 0,
                    intent);
        PendingIntent pendingContentIntent = createPendingIntent(getContext(), 0, contentIntent);
        PendingIntent pendingIntent = getBroadcastPendingIntent(getContext(), 0, notificationIntent);
        PendingIntent pendingIntent = getBroadcastPendingIntent(getContext(), 0, notificationIntent);
        registrationIntent.putExtra("app", AndroidImplementation.getBroadcastPendingIntent(this, 0, new Intent())); // boilerplate
        unregIntent.putExtra("app", AndroidImplementation.getBroadcastPendingIntent(this, 0, new Intent()));


            PendingIntent contentIntent = AndroidImplementation.createPendingIntent(this, 0, newIntent);
                            PendingIntent pendingIntent = AndroidImplementation.getPendingIntent(context, 0,
                                    intent);
            PendingIntent pendingIntent = AndroidImplementation.getBroadcastPendingIntent(context, 0, intent);
            PendingIntent pendingIntent = AndroidImplementation.getPendingIntent(context, 0,
                    intent);
                            PendingIntent pendingIntent = AndroidImplementation.getPendingIntent(context, 0,
                                    intent);
            geofencePendingIntent = AndroidImplementation.getBroadcastPendingIntent(AndroidNativeUtil.getContext().getApplicationContext(), 0, intent);
            PendingIntent pendingIntent = AndroidImplementation.getPendingIntent(context, 0,
                    intent);
import com.codename1.impl.android.AndroidImplementation;
        PendingIntent pendingIntent = AndroidImplementation.getBroadcastPendingIntent(this, 0, mediaButtonIntent);