Isn’t the issue that they are using magic strings? If the strings were something like RoleConstants.Admin then this is avoided?
Though I don’t understand the point of the Unicode characters in the comment string so I must be missing something.
Isn’t the issue that they are using magic strings? If the strings were something like RoleConstants.Admin then this is avoided?
Though I don’t understand the point of the Unicode characters in the comment string so I must be missing something.
There is no comment string.
My mistake was thinking the initial Unicode character was changing the comparison string similar to a non printable character could. But instead it flips the ordering so that the comment is part of the comparison string and then the string is terminated.
The idea here is that you make part of the comment appear to be outside of it, and thus appear to be code that will be executed. You can reshuffle the text arbitrarily, so you can move text backwards to appear to be before the start of the comment, or forwards to appear to be after the end of the comment. If you really want to, you can treat the whole line as an anagram, and rearrange the individual letters into any order you like. This could enable really clever attacks where any use of an enum constant appears to be a use of a different one.