Closed Bug 1525872 Opened 7 years ago Closed 7 years ago

PushEvent.data is null for push messages encrypted with aes128gcm

Categories

(Firefox for Android Graveyard :: General, defect, P2)

Firefox 65
ARM
Android
defect

Tracking

(firefox65 wontfix, firefox66 fixed, firefox67 fixed)

RESOLVED FIXED
Firefox 67
Tracking Status
firefox65 --- wontfix
firefox66 --- fixed
firefox67 --- fixed

People

(Reporter: sven, Assigned: andrei.a.lazar)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:65.0) Gecko/20100101 Firefox/65.0

Steps to reproduce:

To reproduce, first create a push subscription:

  1. Open https://mozilla-services.github.io/WebPushDataTestPage/ with Firefox for Android
  2. Click "Register the service worker..."
  3. Click "Get subscription info"
  4. Copy the values for ENDPOINT, KEY and AUTH

Next send a aes128gcm push message to the device, for example with the Node.js web-push library:

$ npx web-push send-notification --endpoint=ENDPOINT --key=KEY --auth=AUTH --payload=hello --encoding=aes128gcm

Unfortunately, no notification shows up :/ . Note that a push message with aesgcm works as expected (use --encoding=aesgcm with the command above), i.e. we get a notification. On Firefox Desktop, both encodings work as expected.

Looking closer at the issue, we could examine that the client receives the message, i.e. a push event is dispatched, but for aes128gcm PushEvent.data is null.

Related bug, where the implementation of aes128gcm is marked as complete: https://bugzilla.mozilla.org/show_bug.cgi?id=1345665

Also, thanks everyone for your awesome work on Firefox <3

Thank you for this report!
I was able to reproduce this issue on the latest Nightly build with a Samsung Galaxy S9 (Android 8.1.0) following the steps from the description.
The push message with aesgcm worked as expected but with aes128gcm the notification was never received.
Based on my comment I will set this issue as new.

Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Unspecified → Android
Hardware: Unspecified → ARM
Assignee: nobody → andrei.a.lazar
Priority: -- → P2

After further investigations this is what I discovered:

  • when sending a notification with the payload encoded in AESGCM will result in Fennec receiving a collection of 5 key/value pairs (e.g:
    "channelID": "af7ac8fb98934d629d53713e5a45e923", "con": "aesgcm", "enc": "salt=IFnm2z9P_12FNgo3XffJMg", "cryptokey": "dh=BH_Dwv3jOeYRR42DeWCFuFxncuk6GD9lrT8fAxsenXpWkw2o-LzqdL4Z3CsM8jsjTwJWQAq9BwNjDKEISn44XXI", "message": "kH0kIdGmyMQ5xv0SzgE6pWd98dzM3nU")

  • when sending a notification with the payload encoded in AES128GCM will result in Fennec receiveing a collection of 3 key/value pairs (e.g:
    "channelID": "af7ac8fb98934d629d53713e5a45e923", "con": "aes128gcm", "message": "itN2GhLmyxGczKI4Gtad8wAAEABBBMkGXKbFZCsiB3XuSMevevJCC24lA_sxr0Bbmq5APr7dXP4FkgWuEsD30ueD6OAQV_JVsSVkMFW4FdUwLq-VyhpKW4KAh12a93ZIFXBl4bmwjwdB4217")

As you can see, "enc" and "cryptokey" are missing, and they are missing from here, which is the GCM's very first entry in Fennec, so there is no way for that data to be altered in the meantime.

I also made a sanity check by hardcoding these missing values (here and here) and the whole flow works as expected.

JR, do you have any idea why would this happen? Is something missing on my side?

Flags: needinfo?(jrconlin)
Flags: needinfo?(vlad.baicu)
Flags: needinfo?(petru.lingurar)
Flags: needinfo?(vlad.baicu)
Flags: needinfo?(petru.lingurar)

(In reply to Andrei Lazar from comment #3)

That's normal. aes128gcm embeds several of the required decryption values into the header of the body, so you no longer need the salt and dh values as separate values.

What it sounds like is that whatever you're using to encode the body of the message is using the older "aesgcm" format, even though the content encoding is specifying "aes128gcm". (I say that because if you're correct that specifying the values independently causes the body to be decrypted correctly, then that's the only way that could happen. Otherwise, the body would fail to decrypt because of the extra data.)

Now, as to why you're not seeing the push message display.

I've tried pushing a message using the Web Push Test Page using the following steps:

  1. create a new subscription using
    https://mozilla-services.github.io/WebPushDataTestPage/

2)Carefully copy the endpoint, p256dh and auth key to a JSON template file:
e.g.

{"endpoint": "https://updates.push.services.mozilla.com/wpush/v1/gAAAAABcZEWQv9ToKWHUl0AnxLQpw_2HjweS62ldU...",
"keys": {
"auth": "OmAskgGhC5S7EgSbZo6S9A",
"p256dh": "BEKk0dWm5v82zPfsIJmmfL17IJ6MSsuD0kTbLsKs14T3boxIRQRxZwy6xpkEWpItgzfkxcjgY9cYXzIvfGE5l5g"
}
}

I save this as something like "ff_info.json" (Yes, I really should update that page to dump out the data to the console so it's easier to fetch, as well as use "aes128gcm" data encryption.)

  1. using (pywebpush)[https://github.com/web-push-libs/pywebpush], send a message

pywebpush --encoding aes128gcm --data message.txt --info ff_info.json

This works for me, and I'm able to verify the decryption by monitoring the Browser Console:

**** Recv'd a push message:: {"isTrusted":true} sw.js:12:5
Service worker just got: {"title": "hello", "body": "world", "format":"aes128gcm"}
sw.js:25:9
Service worker found clients {} sw.js:31:15
Service Worker sent: {"type":"content","content":"{\"title\": \"hello\", \"body\": \"world\", \"format\":\"aes128gcm\"}\n"} WebPushDataTestPage:686:5
Service worker sending to client... [object WindowClient]

I'm not familiar with the npm push app so I can't offer why it may be using an incorrect encoding format. The web page can decrypt both forms, provided that the data is correct and meets expectations. (Correct encoding, required data elements present, etc.)

Does that help?

Flags: needinfo?(jrconlin)

Thanks for the fast reply, it helped me a lot! I found the issue and I am working on a fix.

Added check for AES128GCM encoding since we won't have separate enckey and cryptokey but rather encoded in the body.

Keywords: checkin-needed

Pushed by csabou@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/15a0cccc792c
PushEvent.data is null for push messages encrypted with aes128gcm r=JanH

Keywords: checkin-needed
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 67

Want to request beta uplift? Would you consider it safe? Thanks !

Flags: needinfo?(andrei.a.lazar)

Comment on attachment 9043918 [details]
Bug 1525872 PushEvent.data is null for push messages encrypted with aes128gcm r=JanH

Beta/Release Uplift Approval Request

Feature/Bug causing the regression

Bug 1525872

User impact if declined

Users won't be able to send/receive notifications encrypted with AES128GCM.

Is this code covered by automated tests?

Unknown

Has the fix been verified in Nightly?

No

Needs manual test from QE?

No

If yes, steps to reproduce

List of other uplifts needed

None

Risk to taking this patch

Low

Why is the change risky/not risky? (and alternatives if risky)

The change is small and easy to understand.

String changes made/needed

Flags: needinfo?(andrei.a.lazar)
Attachment #9043918 - Flags: approval-mozilla-beta?

Comment on attachment 9043918 [details]
Bug 1525872 PushEvent.data is null for push messages encrypted with aes128gcm r=JanH

Support for encryption, looks like a sensible change.
OK to uplift for beta 10.

Attachment #9043918 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: