CVE-2026-58945 AI-generated analysis
platform/packages/modules/Bluetooth, system/stack/gatt (GATT server) and system/btif (btif_gatt_server)
Adds attribute-permission security checks to server-side GATT notifications and indications in the Bluetooth stack: if the link lacks the required encryption or MITM authentication, the value is queued, encryption is started, and the value is resubmitted once encryption completes (or dropped with an error callback if encryption fails).
Root cause
GATTS_HandleValueIndication and GATTS_HandleValueNotification in system/stack/gatt/gatt_api.cc sent the value to the peer without checking the attribute's permission bits (GATT_READ_AUTH_REQUIRED, GATT_READ_MITM_REQUIRED, GATT_READ_ENCRYPTED_REQUIRED, GATT_PERM_READ_IF_ENCRYPTED_OR_DISCOVERABLE) against the link security state. Permission logic existed in gatt_db.cc (gatts_check_attr_readability, gatts_read_attr_perm_check) but was not consulted on these send paths. As a result, characteristic values that an application marked as needing encryption or authentication could be sent to a connected peer over an unencrypted or unauthenticated link. The bulletin classifies this as an information disclosure.
How the fix works
- system/stack/gatt/gatt_db.cc: new static gatts_check_attr_notifiability mirrors gatts_check_attr_readability (auth required, MITM required, encrypted required, key size, read-if-encrypted-or-discoverable). New exported gatts_notify_attr_perm_check looks up the attribute by handle (find_attr_by_handle) and calls it. It returns GATT_NOT_FOUND if the handle is absent.
- system/stack/gatt/gatt_api.cc: new static check_notification_perm gets the link security flags via gatt_sr_get_sec_info, finds the service via gatt_sr_find_i_rcb_by_handle and calls gatts_notify_attr_perm_check. On GATT_INSUF_AUTHENTICATION or GATT_INSUF_ENCRYPTION it calls BTM_SetEncryption with BTM_BLE_SEC_ENCRYPT_MITM or BTM_BLE_SEC_ENCRYPT and returns false (queue). Any other result, or a BTM_SetEncryption status other than BTM_SUCCESS/BTM_CMD_STARTED, returns true (send).
- system/stack/gatt/gatt_api.cc: GATTS_HandleValueIndication calls check_notification_perm before sending. On false it calls gatt_add_pending_ind and returns GATT_PENDING. GATTS_HandleValueNotification does the same with gatt_add_pending_notif and now stores notif.conn_id. GATTS_HandleMultipleValueNotification becomes a public function taking conn_id (it was static and only built under GATT_UPPER_TESTER_MULT_VARIABLE_LENGTH_NOTIF). It now validates p_reg/p_tcb and the handles and checks every handle; if any check fails, the whole vector is queued via gatt_add_pending_multi_notif and GATT_PENDING is returned. In the Android 15 commit the PTS upper-tester block in GATTS_HandleValueNotification is removed entirely.
- system/stack/gatt/gatt_int.h and gatt_utils.cc: tGATT_TCB.pending_ind_q changes from fixed_queue_t* to std::list<tGATT_VALUE>. A new pending_notif_q is a std::list<tGATT_PENDING_NOTIF> (std::variant<tGATT_VALUE, std::vector<tGATT_VALUE>>). gatt_add_pending_ind, gatt_add_pending_notif, gatt_add_pending_multi_notif, gatt_free_pending_ind, gatt_is_srv_chg_ind_pending and gatt_allocate_tcb_by_bdaddr are rewritten for the new containers. In gatt_main.cc, gatt_free clears both lists and gatt_act_connect clears pending_ind_q, replacing the fixed_queue_free calls.
- system/stack/gatt/gatt_sr.cc: gatts_chk_pending_ind becomes non-static; it pops one indication and resubmits it through GATTS_HandleValueIndication. New gatts_chk_pending_notif drains the notification queue (bounded by its initial size), resubmitting each single or multiple notification. When the result is not GATT_PENDING, it delivers GATTS_REQ_TYPE_CONF via gatt_sr_send_req_callback with the resulting status.
- system/stack/gatt/gatt_auth.cc: in gatt_enc_cmpl_cback, after the GATT_SEC_ENC_PENDING early return, BTM_SUCCESS leads to calls to gatts_chk_pending_ind and gatts_chk_pending_notif. On failure it drains both queues and reports GATTS_REQ_TYPE_CONF with GATT_INSUF_ENCRYPTION for each entry. gatt_notify_enc_cmpl also calls both check functions at its end.
- system/stack/gatt/gatt_api.cc GATTS_DeleteService: before gatt_update_for_database_change, it goes through all in-use tcbs and prunes pending_ind_q and pending_notif_q entries whose handle falls in the deleted service's handle range. Multi-notification vectors are filtered and removed if they become empty.
- system/btif/src/btif_gatt_server.cc btapp_gatts_handle_cback: BTA_GATTS_CONF_EVT no longer invokes indication_sent_cb when status is GATT_PENDING.
- system/stack/include/gatt_api.h declares GATTS_HandleMultipleValueNotification. Test mocks (mock_gatt_layer.cc, mock_stack_gatt_api.cc/.h, gatt_sr_test.cc) are updated for the new and changed symbols.
Completeness
- Covers all three server send paths (GATTS_HandleValueIndication, GATTS_HandleValueNotification and GATTS_HandleMultipleValueNotification). Queued items are resubmitted through these same functions, so permissions are checked again after encryption completes.
- check_notification_perm fails open in several cases, meaning the value is sent anyway: if gatt_sr_find_i_rcb_by_handle does not find the handle; if gatts_notify_attr_perm_check returns GATT_NOT_FOUND or GATT_INSUF_KEY_SIZE (only GATT_INSUF_AUTHENTICATION and GATT_INSUF_ENCRYPTION cause queuing); and if BTM_SetEncryption returns anything other than BTM_SUCCESS/BTM_CMD_STARTED.
- Only the attribute's read-permission bits are evaluated (a notification is treated as a read).
- gatt_notify_enc_cmpl flushes the queues without a result parameter. Resubmitted items are checked again and re-queued (GATT_PENDING) if security is still insufficient, so a flush does not bypass the check.
- gatts_chk_pending_ind resubmits only one queued indication per call, and on a send failure it only logs, with no conf callback.
- gatt_free_pending_ind clears both queues without issuing any conf callback for the dropped entries.
Behavior changes
- GATTS_HandleValueIndication, GATTS_HandleValueNotification and GATTS_HandleMultipleValueNotification can now return GATT_PENDING. The data is held and resubmitted later, or dropped with a GATT_INSUF_ENCRYPTION conf callback if encryption fails.
- The stack now starts link encryption (BTM_SetEncryption, with MITM when authentication is required) when an application notifies or indicates a protected characteristic over a link that is not secure enough.
- indication_sent_cb (BTA_GATTS_CONF_EVT) is suppressed for GATT_PENDING. For queued notifications, a conf with the final status is sent after resubmission. For indications, the final callback depends on the normal indication flow.
- Pending notifications and indications for a service are discarded when that service is deleted via GATTS_DeleteService.
- GATTS_HandleMultipleValueNotification becomes a public API (declared in gatt_api.h), and on Android 15 the PTS-only multiple-notification path in GATTS_HandleValueNotification is removed.
- tGATT_TCB.pending_ind_q changes type from fixed_queue_t* to std::list<tGATT_VALUE> (internal stack structure).
Per major
- Android 14: adapted fix (f2741f1c70f8, android-security-14.0.0_r29): same logic with legacy LOG()/VLOG logging, gatt_tcb_get_payload_size_tx, an extra include of stack/include/btm_client_interface.h and an extern declaration of gatts_notify_attr_perm_check. The PTS upper-tester block in GATTS_HandleValueNotification is kept and its call is updated to GATTS_HandleMultipleValueNotification(conn_id, ...). gatt_sr_test.cc gets a gatts_notify_attr_perm_check stub. Patched region present at android-security-14.0.0_r31.
- Android 15: this commit (e18383876445, android-security-15.0.0_r17): log:: logging, direct BTM_SetEncryption call, PTS upper-tester block removed from GATTS_HandleValueNotification. Patched region present at android-security-15.0.0_r19.
- Android 16: adapted fix (cec4b7bfe86d, android-security-16.0.0_r8): tCONN_ID types, gatt_get_gatt_if/gatt_get_tcb_idx, get_btm_client_interface().security.BTM_SetEncryption and the tBTM_STATUS enum class. The #endif of the PTS block remains in the diff context, so the block is kept. Patched region present at android-security-16.0.0_r10.
- Android 17: adapted fix (aa513b35ec64, android-security-17.0.0_r1): the BTIF change is in btif_gatts_send_indication (early return on GATT_PENDING) instead of the BTA_GATTS_CONF_EVT handler. gatt_auth.cc and gatt_sr.cc call p_reg->app_cb.p_req_cb->conf_cb directly instead of gatt_sr_send_req_callback. Uses get_security_client_interface().BTM_SetEncryption. The fixed_queue_free removal is in GATT_BR_Connect in gatt_api.cc. Mocks are under system/stack/mock. Patched region present at android-security-17.0.0_r3.
Unknowns
- The diff does not show where GATT_PENDING is defined. The commit message calls it a new error code, but no header change adding it appears in the material.
- The material does not show whether the PTS upper-tester block kept in the Android 16/17 trees still compiles against the new GATTS_HandleMultipleValueNotification signature (the block is behind GATT_UPPER_TESTER_MULT_VARIABLE_LENGTH_NOTIF).
- The material does not state which built-in profiles or app-registered characteristics with protected permissions were the concrete disclosure vector.
- Whether the stack checks CCC subscription before sending is not shown in the material.
- The callers of gatt_free_pending_ind (for example, the disconnect path) and the indication-confirmation path that drains any further queued indications are not shown.