malware – Is it possible for a compressed file to contain malicious code?

A compressed archive could of course contain arbitrary files inside, including malware. But in this case unpacking and explicitly executing would be needed.

But, bugs in the archive program (i.e. WinRAR in your case) could cause a code execution simply by trying to open an archive, if the archive was specifically prepared to exploit the security issue. Such bugs actually happen, see Nasty code-execution bug in WinRAR threatened millions of users for 14 years.

And code execution then can be done anything, including contacting a remote server to reveal your IP address. Or also encrypt all your files on the system and demand a ransom – which is likely worse than just exposing your IP address.