amsmath does all sorts of tricks with the labels in its environments. You need to restore the standard definition which is stored in \ltx@label and the syntax here is a little non-standard (as you will discover if you try a simple \let):
You need to ensure that the hyperref destination name is unique. hyperref uses (if it exists) a \theH<counter> command. As your codebox has no counter, one must number the labels:
The problem seems to be, that \crefname doesn't define global commands. A workaround is to use the capability of cleveref to read a file cleveref.cfg befor compilation. By writing the \crefname directives to that file, the desired solution is achieved.
Note that the command hanling has been altered, which however is not the actual point of the ...
The problem with commands in section titles is that they must either be expandable or robust. Both \Cref and \hypersetup are neither.
Since \hypersetup will change the setting only when typesetting text, it doesn't need to be expandable (and it's impossible to make it so). Thus you make it robust with: