To dream that you are undercover indicates that you are hiding your true feelings or true nature. Perhaps the dream is trying to tell you that you are being someone that you are not.

In particular, to dream that you are an undercover cop implies that you are going against your conscience.