
Incident report on memory leak caused by Cloudflare parser bug
2/24/2017
This post details a critical memory leak bug caused by Cloudflare's use of the Ragel HTML parser. The bug, present for years but only triggered under specific conditions due to changes in buffering introduced by the migration to a new parser (cf-html), allowed edge servers to return memory containing sensitive user data. The post explains the root cause as a pointer error in the Ragel-generated C code, specifically an equality check (`==`) instead of a greater-than-or-equal-to check (`>=`) when reaching the end of a buffer, combined with a missing `fhold` operation in the error handling path. The incident led to rapid mitigation by disabling affected features via global kill switches and a subsequent patch deployment. The post also highlights the ongoing migration from the old Ragel parser to the new cf-html parser.
