From dd05e44ef38990c9236332e354b5c9bf146004c8 Mon Sep 17 00:00:00 2001 From: sashass1315 Date: Tue, 23 Dec 2025 17:46:21 +0200 Subject: [PATCH] fix: avoid panic when fork schedule is empty (#16175) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SortedForkSchedule should never be empty for a properly initialized network schedule, but the handler already had a branch to support an empty result. Without an early return, we wrote a JSON response and then still accessed schedule[0], which could panic and double-write the HTTP response in misconfigured setups. --------- Co-authored-by: Radosław Kapka --- beacon-chain/rpc/eth/config/handlers.go | 1 + changelog/sashass1315_fix-panic.md | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 changelog/sashass1315_fix-panic.md diff --git a/beacon-chain/rpc/eth/config/handlers.go b/beacon-chain/rpc/eth/config/handlers.go index 6ef4da6e17..38c29839d2 100644 --- a/beacon-chain/rpc/eth/config/handlers.go +++ b/beacon-chain/rpc/eth/config/handlers.go @@ -40,6 +40,7 @@ func GetForkSchedule(w http.ResponseWriter, r *http.Request) { httputil.WriteJson(w, &structs.GetForkScheduleResponse{ Data: data, }) + return } previous := schedule[0] for _, entry := range schedule { diff --git a/changelog/sashass1315_fix-panic.md b/changelog/sashass1315_fix-panic.md new file mode 100644 index 0000000000..d3b2771869 --- /dev/null +++ b/changelog/sashass1315_fix-panic.md @@ -0,0 +1,3 @@ +### Fixed + +- avoid panic when fork schedule is empty [#16175](https://github.com/OffchainLabs/prysm/pull/16175)