The vulnerability lies in the erb library's handling of deserialized objects. The ERB class has an @_init instance variable that is set during initialization to prevent methods that evaluate code from running on objects reconstructed from Marshal.load. However, the methods def_method, def_module, and def_class did not perform this check before evaluating the @src instance variable, which can contain user-controlled code.
The patch was applied to def_method to include the @_init check. Since def_module and def_class both call def_method, this single patch mitigates the vulnerability for all three methods. An attacker could exploit this by crafting a serialized ERB object with malicious code in the @src variable. When a Ruby application deserializes this object and a method like def_module is called on it (which can happen in gadget chains), the malicious code is executed.