The vulnerability is a format string injection located in the C extension of the json gem. It is triggered when parsing a JSON document with the allow_duplicate_key: false option. If the JSON document contains a duplicate key with format string specifiers, the vulnerability can be exploited.
The analysis of the patch commit 393b41c3e5f87491e1e34fa59fa78ff6fa179a74 reveals the root cause. The raise_duplicate_key_error function in ext/json/ext/parser/parser.c would create an error message containing the user-supplied duplicate key. This message was then passed as the format argument to the raise_parse_error function, which in turn used it in a call to rb_sprintf. This direct use of user-controlled data as a format string is the source of the vulnerability.
The patch addresses this by refactoring the error handling logic. It ensures that the user-provided key is treated as literal text and is not interpreted as a format string, thus preventing the injection.