If a programmer (P) releases a game, and a modder (M) releases a game modification which includes copyrighted content, can P be held liable for the copyright infringement in the mod?
I'm going to start off by being That Guy and noting that this site is the wrong place for this question. It's a potentially non-trivial legal issue whose precise answer, under various circumstances, will likely depend on details of local law and legal precedent, as well as on the relative abilities of the lawyers on each side to twist said law and precedents to their advantage and the attitude and preconceptions of whoever happens to be chosen to adjudicate the case. In short, if you want a real answer, ask a lawyer.
That said, out of the cases mentioned in your question before it was shortened, the M = P case is the easy one if that fact can be proven. Note that, again depending on jurisdiction, even just reasonable cause for suspicion might be enough to obtain a subpoena or a search warrant to acquire confirming evidence, e.g. from ISP logs (as noted in another answer) or even directly from P's computers, which might contain revealing traces of their activities as M.
The case where M's identity is known (and M ≠ P) is also usually simple for P, since any plaintiff's attention will probably be mostly focused on M, and since P typically has a fairly good defense against any accusations by pointing to M and saying "he did it, I had nothing to do with it!" That said, as I'll note below, that defense isn't necessarily ironclad, if the plaintiff does decide that they want to go after P as well (e.g. because M is out of their reach, or too poor to pay for any damages even if found guilty, or just because they can).
Now, on to the meat of the answer: If P does get sued, either alongside M or because M could not be identified, it will likely be for contributory infringement. Basically, the claim would be that P knowingly aided and encouraged M's infringement, and materially benefited from it, by making the game moddable in the first place and continuing to sell it after becoming aware of M's mod's popularity.
It should be noted that, under most circumstances, that would be a rather tenuous claim. Making games moddable is standard industry practice, and, indeed, it shouldn't be hard to find expert witnesses to testify that making a game unmoddable is often difficult or impossible. As long as P's original product was a playable and salable game in itself (and did not, for instance, feature blank sprites and textures with "PLACEHOLDER" written on them) it would typically also be hard to argue deliberate intent to encourage infringement.
As for profiting from the sales driven by M's mod, that might depend on just how popular the mod actually became, but in most jurisdictions there should be either case or statute law — such as, notably, the "Betamax case" (Sony v. Universal) in the U.S. — exempting makers of products used by individuals to infringe copyright from contributory liability, as long as the product also has "substantial non-infringing uses" (to quote the Betamax decision). Indeed, if such an exemption did not exist, what would prevent the plaintiffs from just going directly after, say, Intel and Microsoft for making computers that could run the game that could host the infringing mod?
Of course, the situation could be different if it really could be demonstrated that an overwhelming fraction of all sales of P's game were driven by M's mod, and that P should have been aware of this. At least, someone could then argue that P should have patched the game (or at least any subsequently sold copies of it) to not run M's infringing mod (and to communicate this to prospective buyers). Of course, such efforts would likely be ultimately futile (as M could just patch the mod to compensate), but it could be argued that, if P hadn't even made any such effort after explicitly being made aware of M's mod and its popularity (and illegality), that could constitute evidence of willful encouragement.
For an example of similar arguments, see e.g. the recent Megaupload case (which, of course, has not actually proceeded to trial, but at least illustrates the kind of arguments that could be made).
"If M, how ? It's easy for him to avoid any kind of punishment as "the mod" is free and therefore there are no business entities and hence M can simply leave no information about himself."
It doesn't matter whether it is non-commercial/free or not. Copyright always applies if something is being distributed. M only wouldn't be guilty if he wouldn't have distributed it at all (e.g. wouldn't have uploaded that to that public server), as long as the mod is kept in private it doesn't matter.
It's unprobable that P could get in trouble because he wasn't the one distributing that mod, whether he profited from it or not doesn't matter. In the case of P = M it first would have to be proved that P = M or at least a relation between P and M.
It would have been a different point if the mod was on P's server, because in that case he would have to make sure that CC isn't uploaded there and/or that it isn't he is not responsible for the content.
Note: This answer is in response to an earlier version of the question, which asked both whether P is liable in general and whether if P = M allows P to profit from copyright infringement"
As I understand it, the primary question is "If a modder breaks the law, is the creator of the base game liable?" The answer to this is generally no. The other answers have covered this pretty well.
However, you make some assumptions (If M, how? It's easy for him to avoid any kind of punishment as "the mod" is free and therefore there are no business entities and hence M can simply leave no information about himself.). I would disagree with these assumptions. As recent events with file-sharers have found out, if you are on the internet, you are not truly anonymous. Your ISP can and will be subpoena'ed for your information. Regardless of whether the modder is anonymous or not, it is undeniable that he is infringing.
This leads us to the final point "In the case when P = M, and we've established that the modder is guilty(but hard to find), does this mean that P can make money without being caught?" You are basically asking, "If P breaks the law, but do not get caught, does that mean he can make a profit off copyright infringement?"
This is a nonquestion. Of course, if you break the law and don't get caught, you can make a profit. This is how crime works. But let us consider what happens when you do get caught (I am not a lawyer, and my answer is based on information such as http://itlaw.wikia.com/wiki/Copyright_infringement#Willful_infringement)
- Copyright infringement becomes a felony when it is both for-profit and willful. If M is caught (via subpoenas, investigators, etc.), it becomes obvious that M = P, and the legal argument that he was infringing willfully becomes that much more convincing.
Willful Infringement carries not only a higher limit on the statutory damages you will be sued for (and if you are making a lot of profit, do not expect that the suit will be just for statutory damages) it also raises the level of felony the infringement constitutes.
Valve does this kind of thing very well. Like I believe they do, you can basically state, "If someone modifies our game, that is outside our control and therefor not our responsibility"
Hypothetically, if you're both P and M, then this is copyright infringement. If the P side of you makes tons of money with this, the copyright holder might get angry about it. In this case I hope that you were really anonymous while publishing this mod. IANAL, but the simple fact that you're the only one making a profit might be charged against you.
Conlusion: this is a dangerous move. Forewarned is forearmed.