It's probably not a bug. You are probably dressed as a Stormcloak when you enter the city, or as that guy suggests, you become recognizable as a Stormcloak after progressing past a certain point in the civil war. Dressing as an Imperial will allow you to enter Imperial cities, but you'll then have the same problem in Stormcloak cities unless you change back. There is a Master of Disguise mod that allows subtler effects, tying your Disguise ability to both clothing worn and Stealth skill. I use it, but it now seems to be missing from Nexus. I see at least one other disguise mod still available that may help you complete your current mission, but I haven't tried any other disguise mods, so I can't recommend one.
It's possible, though, that there are other explanations for the behavior, for example severe vampirism or a bounty. Since you didn't provide much information on which cities are definitely affected, how you confirmed, how far along in the civil war you are, or whether you have been turned into a vampire or joined the Companions, it's hard to say for sure what might be happening. Make sure you don't have a bounty in any of the affected cities and that you don't have vampirism. Also, if you still suspect a glitch, try leaving the area and waiting a week before returning.