Commit Graph

119 Commits

Author SHA1 Message Date
Rahul Tank
f6fcd6470c fix(nimble): update sbom file with cve details 2026-07-28 21:25:14 +05:30
Rahul Tank
16f9e082dd feat(protocomm): Add support for BLE 5 for bluedroid 2026-07-28 16:20:15 +05:30
Rahul Tank
e08609e451 fix(nimble): Migrate to NimBLE 1.9.0 2026-07-27 14:14:35 +05:30
Shreeyash Bhakare
c368c13d55 fix(nimble): Added security related fixes 2026-07-25 08:54:16 +05:30
Ashish Sharma
aebc7fa691 fix(protocomm): fix response leaks and stale key IDs on error paths 2026-07-15 15:46:58 +08:00
yi chen
1fa38c2f25 Avoid re-destroying a released Security1 key
The second cipher-update failure destroys the volatile symmetric key but left its identifier cached in session state. Clear it immediately so sec1_close_session() cannot try to destroy the same key again.

Constraint: Follow-up to maintainer review on espressif/esp-idf#18813

Confidence: high

Scope-risk: narrow

Tested: security1.c cross-compiled for ESP32 with Xtensa GCC 14.2.0; test_security1.c compiled with the test app flags; git diff --check

Not-tested: Full master test-app link or on-target execution; local IDF 5.4.3 differs from the PR's master baseline in PSA ABI and Mbed TLS headers
2026-07-14 16:08:42 +08:00
yi chen
641c2f7c53 fix(protocomm): free response buffers on 2nd psa_cipher_update failure
In handle_session_command1(), if the second psa_cipher_update()
call (encrypting the device verify data to send back to the client)
fails, the error path only frees the outbuf ciphertext buffer. The
out (Sec1Payload) and out_resp (SessionResp1) structures allocated
just before it are never freed, and neither the cipher operation
(cur_session->ctx_aes) nor the imported key (key_id) are released.

The caller (sec1_req_handler(), via sec1_session_setup()) returns
immediately on a non-ESP_OK result without doing any cleanup of its
own here - sec1_session_setup_cleanup() only runs on the success
path, once resp->sec1 has actually been assigned - so nothing else
ever frees these on this path.

Add psa_cipher_abort()/psa_destroy_key() and free() for out/out_resp,
matching the cleanup already done for every other failure branch
earlier in this same function.

Fixes #18804

Signed-off-by: yi chen <94xhn1@gmail.com>
2026-07-10 06:53:44 +08:00
Ashish Sharma
fae2038058 fix(protocomm): null output buffer pointer on crypto failure 2026-06-09 11:48:46 +08:00
Rahul Tank
3f33d345cf fix(protocomm): harden nimble transport size handling 2026-06-02 15:03:52 +05:30
Andrii Anoshyn
3fcc127672 fix(protocomm): prevent out-of-bounds write in console line buffer
The console transport read loop passed &linebuf[i] to uart_read_bytes()
before checking i < LINE_BUF_SIZE, so a line of LINE_BUF_SIZE or more
bytes without a terminator wrote one byte past the 256-byte linebuf
stack array.

Gate the read on the bounds check and reserve the final byte for the NUL
terminator (LINE_BUF_SIZE - 1), so the buffer handed to esp_console_run()
stays terminated even when an overlong line is truncated.

Closes https://github.com/espressif/esp-idf/issues/18638

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 22:18:59 +03:00
Jim
688eef5dff fix(protocomm): Add GATT service initialization that when gatt service changed, the peer can refresh gatt service 2026-05-09 10:24:08 +08:00
Mahavir Jain
35fe22582a Merge branch 'fix/protocomm-security2-srp-hd-double-free' into 'master'
fix(protocomm): null srp_hd after free in sec2 command0 error paths

Closes IDF-15579

See merge request espressif/esp-idf!47888
2026-04-27 08:50:20 +05:30
Mahavir Jain
322eabd390 fix(protocomm): null srp_hd after free in sec2 command0 error paths
handle_session_command0() freed cur_session->srp_hd on every error path
without clearing the pointer. A subsequent sec2_close_session() call
(e.g. on BLE disconnect, or via sec2_new_session evicting the old
session) checks `if (cur_session->srp_hd)` and frees it again,
double-freeing a dangling pointer.
2026-04-23 13:43:09 +05:30
Aditya Patwardhan
bf56fad62d Merge branch 'fix/protocomm-close-session-id-mismatch' into 'master'
fix(protocomm): pass current session id when closing existing session

See merge request espressif/esp-idf!47562
2026-04-21 19:55:01 +05:30
Aditya Patwardhan
9dc64a7402 fix(protocomm): pass current session id when closing existing session
sec1_new_session()/sec2_new_session() were calling sec*_close_session()
with the *new* session_id parameter instead of the existing
cur_session->id. The close handler validates `cur_session->id ==
session_id` before performing teardown, so the call always failed with
ESP_ERR_INVALID_STATE.

Effect: when a peer started a new provisioning session while another was
already active, the previous session's PSA keys, AES context, SRP handle
and username buffer were leaked instead of being destroyed. The cleared
session struct was overwritten by the new session, leaking the previous
key handles inside PSA Crypto and (for security2) leaking heap memory
for the username and SRP context.

Fix: pass cur_session->id so the close path actually executes the
teardown (psa_destroy_key/psa_cipher_abort/esp_srp_free/free) before the
new session takes over.
2026-04-14 11:05:51 +05:30
Ashish Sharma
14731c19f0 fix(esp_srp): reject SRP client public key when A mod N is zero 2026-04-10 17:12:53 +08:00
Ashish Sharma
a2f4554f10 fix(protocomm): fixes potential issues that can lead to crash during device provisioning 2026-04-01 10:08:00 +08:00
Rahul Tank
9e581d7d68 fix(nimble): Bugfixes for various issues 2026-02-16 10:53:34 +05:30
Alexey Lapshin
72a3697c6c fix(protocomm): fix error handling for esp_srp_exchange_proofs() 2026-02-06 14:21:25 +07:00
Ashish Sharma
773411a9b0 feat: migrates protocomm to PSA APIs 2025-12-30 09:31:49 +05:30
Rahul Tank
47552ff4fd fix(protocomm): Add security checks for buffer overflow and incorrect length handling 2025-12-16 10:16:05 +05:30
Mahavir Jain
9c6f6c7470 fix(protocomm): add validation for Security1 client verifier data
Add checks to validate client_verify_data pointer and length before
processing in handle_session_command1. Prevents NULL pointer dereference
when client omits verifier data in Session_Command1, which could cause
device crash during provisioning (remote DoS attack).
2025-11-20 14:22:40 +05:30
Rahul Tank
2738c5ac76 fix(nimble): Address compilation issues in nimble examples 2025-10-30 10:54:36 +05:30
gongyantao
179a730a03 feat(bt): remove the deprecated functions and parametes 2025-08-19 16:07:05 +08:00
Mahavir Jain
3bd5a22f5a fix(provisioning): fix incorrect AES-GCM IV usage in security2 scheme
Using same IV in AES-GCM across multiple invocation of
encryption/decryption operations can pose a security risk. It can help
to reveal co-relation between different plaintexts.

This commit introduces a change to use part of IV as a monotonic
counter, which must be incremented after every AES-GCM invocation
on both the client and the device side.

Concept of patch version for a security scheme has been introduced here
which can help to differentiate a protocol behavior for the provisioning
entity. The security patch version will be available in the JSON
response for `proto-ver` endpoint request with the field
`sec_patch_ver`.

Please refer to documentation for more details on the changes required
on the provisioning entity side (e.g., PhoneApps).
2025-03-07 13:49:10 +05:30
Mahavir Jain
641f461346 fix(protocomm): memory leak issue for session command0 failure case 2025-03-07 13:49:09 +05:30
hrushikesh.bhosale
e9844bd613 fix(protocomm): Added check for cur_cookie_session_id
Added check to check whether the value of cur_cookie_session_id
is -1 or not, if yes the return with error log message
2024-12-03 14:48:46 +05:30
Rahul Tank
fb55646270 fix(nimble): Add notify characteristic flag support 2024-09-05 16:16:08 +05:30
Rahul Tank
338d9f40d9 fix(wifi_prov): Add support for ESP IP controller chips in bluedroid 2024-08-29 14:56:46 +05:30
shreeyash
6e6fd2f6a3 fix(wifi_prov_mgr): Api to keep BLE on after provisioning 2024-08-13 12:42:35 +05:30
Rahul Tank
35e88684db fix(wifi_prov): Use calloc instead of malloc to zero initialize variable 2024-08-02 10:33:28 +05:30
Rahul Tank
928117e999 fix(wifi_prov): Added API to set random address 2024-07-21 15:37:37 +05:30
zhiweijian
b9a1756202 fix(ble/bluedroid): Remove BLE functions discard declaration
fix(nt/bluedroid): Split the device name set functions

feat(bt/bluedroid): added APIs to get/set device name on BT GAP side

change(bt/common): Marked some APIs in device module as deprecated

1. esp_bt_dev_set_device_name
2. esp_bt_dev_get_device_name

change(bt/bluedroid): use BT GAP APIs to set/get device name in bluetooth classic examples

change(bt/bluedroid): use BT/BLE GAP APIs to set/get device name in coexist examples
2024-04-18 15:53:54 +08:00
zhiweijian
5725595d84 fix(ble/bluedroid): Remove esp_bluedroid_init() discard declaration 2024-04-18 15:53:30 +08:00
Jin Cheng
a3f68aef8a feat(bt/bluedroid): Added API to get local device name 2023-12-15 19:30:12 +08:00
Vikram Dattu
08f2422ff8 feat(provisioning): Generate Salt and verifier pair for given username and password
This commit adds a new feature to generate a salt and verifier pair for a given username and
password during the provisioning process. This is useful in scenarios where the pairing pin is
randomly generated and shown via some interface such as a display or console.

- Uses the provided username and password to generate a salt and verifier pair
- Adds support for dev mode where the pin/password can still be read from flash
2023-11-21 18:06:24 +05:30
Vikram Dattu
b97322c521 refactor(esp_srp): Expose esp_srp.h and add API docs
- Also added missing `protocomm_security2` reference in `protocomm.rst`
2023-11-21 18:06:24 +05:30
Rahul Tank
e689cc55d8 Merge branch 'feature/protocomm_update_params' into 'master'
fix(protocomm): added Protocomm BLE Event Structure and Event Handling

See merge request espressif/esp-idf!26707
2023-11-03 14:09:27 +08:00
darshan
e1ec13548f fix(protocomm): added Protocomm BLE Event Structure and Event Handling 2023-11-02 15:37:50 +05:30
Jin Cheng
fc174f5811 feat(bt/bluedroid): Added mode to use BlueDroid host only without Bluetooth Controller 2023-10-30 00:52:26 +00:00
WanqQixiang
5435c9b04a fix(protocomm): Remove the configuration check of wifi_provisioning for protocomm component 2023-09-25 15:32:03 +08:00
liqigan
0df585dc35 feat(bt/bluedroid): Add new version of API for Bluedroid host stack initialization 2023-08-31 12:28:38 +00:00
KonstantinKondrashov
e72061695e all: Removes unnecessary newline character in logs
Closes https://github.com/espressif/esp-idf/issues/11465
2023-06-09 03:31:21 +08:00
Laukik Hase
f695c1a788 wifi_prov: Exposed events for secure session establishment 2023-05-23 12:00:40 +05:30
isha.pardikar@espressif.com
f29430239c wifi_prov_mgr: Fixed memory leak after bluetooth stack was stopping. 2023-04-24 17:45:41 +05:30
isha.pardikar@espressif.com
e72d223737 wifi_prov_mgr : Fixed return value of characteristic read operation 2023-03-06 15:23:26 +05:30
Alexey Lapshin
a7e51b2509 protocomm: fix gcc-12 compile errors 2023-02-22 05:33:03 +00:00
Rahul Tank
826495a145 Nimble: Added return value (success / failure ) to nimble_port_init 2023-01-31 12:01:02 +05:30
Laukik Hase
7759079362 protocomm: Fix Kconfig dependency on wifi_provisioning component config
- `protocomm` depends on a config option `CONFIG_WIFI_PROV_BLE_FORCE_ENCRYPTION`
  from `wifi_provisioning`; however, a lower layer component (`protocomm`) should
  not have any `#ifdef` guard dependent on an upper layer component (`wifi_provisioning`).
- Added a new `ble_link_encryption` flag in `protocomm_ble_config_t` to manage the same

Closes https://github.com/espressif/esp-idf/issues/9443
2023-01-20 11:01:01 +05:30
Mahavir Jain
3a56807568 protocomm: remove "Wno-format" cflag and fix formatting errors 2022-12-21 14:13:55 +05:30