There is a chance of transmitting an STD that way, but it is small. The two biggest chances you would have contracting an STD from your friend's cum are:
1 - If you have an open cut or abrasion on your penis (or hand, or any other body part with a cut that comes in contact with his cum), from masturbating too hard, fingernail, etc.
2 - If you have a wide open urethral opening at the tip of your penis, it is possible for some semen to get inside, and a virus or bacteria to work its way up the urethra. Less likely than the first one, but some guys do have really large pee hole openings that are problematic with this.
Other than that, not much of a risk at all.
<i>My avatar is a picture of my own sperm under a microscope. Pretty cool huh?</i><br />Drugs are garbage. I'm high on my own testosterone.