Doesn't `Hash[context[:whitelist] || WHITELIST]` create a shallow copy of the hash, just like the `.dup` I have on line 113? Assuming that's true, your code is missing a `.dup` on the `:protocols` hash.