matrix-org / sygnal

Sygnal: reference Push Gateway for Matrix
Apache License 2.0
155 stars 140 forks source link

`TypeError: 'NoneType' object is not iterable` in apnspushkin.py and gcmpushkin.py #291

Closed squahtx closed 2 years ago

squahtx commented 2 years ago

In gcmpushkin.py and apnspushkin.py, we attempt to use device.data["default_payload"] as a dictionary without verifying its type. Since device.data is arbitrary client or homeserver-supplied JSON, this can lead to errors. We ought to check the type of device.data["default_payload"] before using it: https://github.com/matrix-org/sygnal/blob/v0.11.0/sygnal/gcmpushkin.py#L425-L426 https://github.com/matrix-org/sygnal/blob/v0.11.0/sygnal/apnspushkin.py#L353-L354

For reference, webpushpushkin.py does include a check: https://github.com/matrix-org/sygnal/blob/v0.11.0/sygnal/webpushpushkin.py#L245-L248

squahtx commented 2 years ago

Looks like "default_payload": null was coming from this code that got fixed: https://github.com/ruma/ruma/commit/932fe4fa38accee577d1ab09ad004fb68e84d1d9