You can control whether your Firebase Service Data may be used by Google toprovide more in depth analysis, insights, and recommendations aboutnon-Firebase Google services and improve non-Firebase Google services.You can configure this in your Firebase data privacy settings page.
Next let's look at how we can send a payload with a push message so that when our web app receives a push message, it can access the data it receives.A common question that arises from any who've used other push services is why does the web push payload need to be encrypted? With native apps, push messages can send data as plain text.Part of the beauty of web push is that because all push services use the same API (the web push protocol), developers don't have to care who the push service is. We can make a request in the right format and expect a push message to be sent. The downside of this is that developers could conceivably send messages to a push service that isn't trustworthy. By encrypting the payload, a push service can't read the data that's sent. Only the browser can decrypt the information. This protects the user's data.The encryption of the payload is defined in the Message Encryption spec.Before we look at the specific steps to encrypt a push messages payload, we should cover some techniques that'll be used during the encryption process. (Massive hat tip to Mat Scales for his excellent article on push encryption.)ECDH and HKDF #Both ECDH and HKDF are used throughout the encryption process and offer benefits for the purpose of encrypting information.ECDH: Elliptic Curve Diffie-Hellman key exchange #Imagine you have two people who want to share information, Alice and Bob. Both Alice and Bob have their own public and private keys. Alice and Bob share their public keys with each other.The useful property of keys generated with ECDH is that Alice can use her private key and Bob's public key to create secret value 'X'. Bob can do the same, taking his private key and Alice's public key to independently create the same value 'X'. This makes 'X' a shared secret and Alice and Bob only had to share their public key. Now Bob and Alice can use 'X' to encrypt and decrypt messages between them.ECDH, to the best of my knowledge, defines the properties of curves which allow this "feature" of making a shared secret 'X'.This is a high level explanation of ECDH, if you want to learn more I recommend checking out this video.In terms of code; most languages / platforms come with libraries to make it easy to generate these keys.In node we'd do the following:
Wikipedia has a succinct description of HKDF:HKDF is an HMAC based key derivation function that transforms any weak key material into cryptographically strong key material. It can be used, for example, to convert Diffie Hellman exchanged shared secrets into key material suitable for use in encryption, integrity checking or authentication.Essentially, HKDF will take input that is not particular secure and make it more secure.The spec defining this encryption requires use of SHA-256 as our hash algorithm and the resulting keys for HKDF in web push should be no longer than 256 bits (32 bytes).In node this could be implemented like so:
We've covered the headers used for JWT / Application Server Keys (i.e. how to identify the application with the push service) and we've covered the headers used to send an encrypted payload.There are additional headers that push services use to alter the behavior of sent messages. Some of these headers are required, while others are optional.TTL header #RequiredTTL (or time to live) is an integer specifying the number of seconds you want your push message to live on the push service before it's delivered. When the TTL expires, the message will be removed from the push service queue and it won't be delivered.
Pub/Sub uses theenvelope encryption pattern with CMEK.In this approach, the messages are not encrypted by Cloud KMS. InsteadCloud KMS is used to encrypt Data Encryption Keys (DEKs) created byPub/Sub for each topic. These DEKs are stored only in encrypted,or wrapped, form by Pub/Sub. Before storing a DEK, the servicesends the DEK to Cloud KMS to be encrypted with the key encryptionkey (KEK) specified on the topic. A new DEK is generated foreach topic approximately every six hours.
The internet-wide push to encrypt more web traffic has resulted in a wave of safer, snoop-proof connections. The next challenge, though, is completing that transition from using a mixture of unencrypted HTTP and protected HTTPS to requiring that baseline protection everywhere. And over the past year, Google has been publicly offering a simple and straightforward way for websites to eliminate these subtle weak spots.
To fully understand how encryption in transit works at Google, it isalso necessary to explain how traffic gets routed through the Internet. Thissection describes how requests get from an end user to the appropriateGoogle Cloud service or customer application, and how traffic is routedbetween services.
GFEs proxy traffic to Google Cloud services. GFEs route the user's request overour network backbone to a Google Cloud service. This connection is authenticatedand encrypted from GFE to the front-end of the Google Cloud service or customerapplication, when those communications leave a physical boundary controlled byGoogle or on behalf of Google. Figure 1 shows this interaction(labeled connection A).
With Private Google Access, VMsthat don't have external IP addresses can access supported Google APIs andservices, including customerapplications hosted on App Engine. For more information about access toGoogle APIs and services, see Private access options forservices.
From the VM to the GFE, Google Cloud services support protecting theseconnections with TLS by default2. The connection isauthenticated from the GFE to the service and encrypted if the connection leavesa physical boundary. In addition to these default protections, you can applyenvelope encryption. For more information, seeEncrypt your data.
Routing from one production service to another takes place on our networkbackbone and may require routing traffic outside of physical boundariescontrolled by or on behalf of Google. Figure 1 shows this interaction(labeled connection E). An example of this kind of traffic is a Google CloudStorage event triggering Google Cloud Functions. Connections between productionservices are encrypted if they leave a physical boundary, and authenticatedwithin the physical boundary.
When a user sends a request to a Google Cloud service, we secure the data intransit; providing authentication, integrity, and encryption, using HTTPSwith a certificate from a web (public) certificate authority. Any datathe user sends to the GFE is encrypted in transit with Transport Layer Security(TLS) or QUIC. GFE negotiates a particular encryption protocol with the clientdepending on what the client is able to support. GFE negotiates more modernencryption protocols when possible.
GFE's scaled TLS encryption applies not only to end-user interactions withGoogle, it also facilitates API interactions with Google over TLS, includingGoogle Cloud. Additionally, our TLS encryption is used in Gmail to exchangeemail with external mail servers (more detail inRequire TLS in Gmail).
For Google Cloud services, RPCs are protected using ALTS. Forcustomer applications hosted on Google Cloud, if traffic is routed via theGoogle Front End, for example if they are using the Google Cloud Load Balancer,traffic to the VM is protected using Google Cloud's virtual network encryption,described in the next section.
Encryption in ALTS can be implemented using a variety of algorithms, dependingon the machines that are used. For example, most services use AES-128-GCM12.More information on ALTS encryption can be found in Table 2.
Communications between VMs and Google Cloud Platform services use TLS tocommunicate with the Google Front End, not ALTS. We describe thesecommunications in Virtual machine to Google Front Endencryption.
Most push notification services are proprietary, meaning that the services can spy on app users when they handlenotifications. If information like sender, content preview and more is sent along with the push notification, the servicecan even read and track this kind of information.
Here, HTTPS can only guarantee that no one can snoop on the message in transit to the push service provider. Once they receive it, they are free to do what they like, including re-transmitting the payload to third-parties or maliciously altering it to something else. To protect against this we use encryption to ensure that push services can't read or tamper with the payloads in transit.
On the server side, things change a bit more. The basic process is that you use the encryption key information you got from the client to encrypt the payload and then send that as the body of a POST request to the endpoint in the subscription, adding some extra HTTP headers.
The details are relatively complex, and as with anything related to encryption it's better to use an actively developed library than to roll your own. The Chrome team has published a library for Node.js, with more languages and platforms coming soon. This handles both encryption and the web push protocol, so that sending a push message from a Node.js server is as easy as webpush.sendWebPush(message, subscription).
Facebook parent Meta, which owns WhatsApp, has said that it competes directly with Apple because of how widely used iMessage is in the United States. Messaging has also drawn attention from some policymakers who are pushing to force competing services to work with each other under fair competition rules.