medium · M6 · MASVS-PRIVACY-1 · PTKD-DS-ADS-BEFORE-CONSENT

    Ads start before the user's consent (text search)

    An ads SDK is initialized at app start, either with no consent SDK (UMP or another CMP) in the app, or before the consent form runs. Google's EU User Consent Policy and the GDPR require consent before personalized ads load in the EEA and UK.

    How it is exploited

    Not an attack: MobileAds.initialize() runs in Application.onCreate and the first banner requests personalized ads before the consent form has shown. For users in the EEA and UK that is personal-data processing without consent.

    Why it matters

    Google can limit or stop ad serving under its EU User Consent Policy, Play can act on the app, and data protection authorities can fine under GDPR.

    How to fix it

    1. Add Google's User Messaging Platform (or a certified CMP) and request consent info on every launch.
    2. Show the form when required, and only then initialize the ads SDK when canRequestAds() is true.
    3. Give users a way to change their choice later (a 'Privacy options' entry in Settings).

    Kotlin (UMP)

    val ci = UserMessagingPlatform.getConsentInformation(this)
    ci.requestConsentInfoUpdate(this, ConsentRequestParameters.Builder().build(), {
      UserMessagingPlatform.loadAndShowConsentFormIfRequired(this) {
        if (ci.canRequestAds()) MobileAds.initialize(this)
      }
    }, { /* log, keep ads off */ })

    Does your app have this?

    PTKD checks your build or your source project for PTKD-DS-ADS-BEFORE-CONSENT and every other check in this knowledge base.

    Scan your app

    References

    Related checks (M6)