Is this what you are seeing? : If you're asked to create a new iCloud security code - Apple Support
This was from iOS 8 when the Keychain servers changed, otherwise, there is no such thing as an iCloud security code anymore. If you use Two-Factor Authentication then it would send a code to log in to a new device to one of your trusted devices. Its dynamical generated, so no way for you to actually know it.
Link-> Two-factor authentication for Apple ID - Apple Support
If neither of these is is, please provide a screen shot of what you are seeing.