nimble/host: characteristic value reading for notification/indication compromises security set-up #1962
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If a GATT server provides the characteristic which requires encryption (
BLE_GATT_CHR_F_READ_ENC
) than a client should connect and pair with the server to read the characteristic. But if notification (BLE_GATT_CHR_F_NOTIFY
) or indication (BLE_GATT_CHR_F_INDICATE
) is enabled for the characteristic than the client could connect and subscribe to notifications/indications getting characteristic value even if the connection is not encrypted. So the security of the characteristic is compromised.As I see it there are 3 alternatives for the solution:
ble_gatts_notify
. But it's kind of weird.We could reproduce the behavior using nRF Connect app on Android. Start the device, open the app, connect to the advertising device.
Review:
ble_gatts_notify_multiple
, so I removed it fromble_gatts_notify_multiple_custom
as well. Eventually the handle is checked during reading.ble_gatts_notify
callsble_gatts_notify_custom
, therefore I moved logic fromble_gatts_notify_multiple
toble_gatts_notify_multiple_custom
, so it handles both cases. (As it did before, but made it more DRY).ble_gatts_notify_multiple_custom
when multiple notifications are not supported (iterating over passed handles/values structure taking out of bounds element on each iteration and also not returning after the for loop).If this changes are ok, a consideration should be taken of the necessity of
ble_att_svr_read_local
function as it was used to bypass permission checks. And is not used in other functions.