Files
esp-idf/components/esp_event
Konstantin Kondrashov f23fd35207 fix(esp_event): skip dispatch for internal cleanup events (SEC-221)
After processing an esp_event_handler_cleanup sentinel, execution fell
through into the regular dispatch block. Every loop-level (ANY_BASE/
ANY_ID) handler was invoked with base="cleanup" and event_data pointing
at the internal esp_event_remove_handler_context_t struct.

Consequences:
- Information disclosure: internal handler addresses and loop instance
  pointer are exposed to every loop-level handler.
- UAF: if a handler stores event_data for later use, post_instance_delete
  frees the ctx, turning the stored pointer into a dangling reference.
- Logic corruption: handlers that switch on base with a default branch
  misbehave on every unregister anywhere in the system.

Fix: wrap the regular dispatch block in an else clause so it is skipped
entirely for cleanup events. post_instance_delete, ticks accounting, and
xSemaphoreGiveRecursive remain in the shared tail executed for both paths.

Closes SEC_221
2026-07-21 16:50:53 +03:00
..