gdgmacguy is correct, there is no user-configurable firewall. However, the iPhone listens on remarkably few TCP ports -- one to be precise. I forget which one it is, it's up in the 60,000 range, and for me it disconnected immediately after completing the three-way handshake. I'm not sure what it's there for, but if it immediately kills the connection without sending or receiving data, I'm not sure how much of a potential threat it is.
Given that, and given the general robustness of the underlying OS (assuming it's still very darwin-ish), I'm not very worried about getting hacked simply by connecting to unknown wifi networks. SLAPSHOTW's and Allan Sampson's concerns are perfectly valid, however.