What happens to you if you use code from StackOverflow but it turns out to be copyright protected?
<p>Code posted on StackOverflow is under a <a href="https://stackoverflow.com/help/licensing">CC license</a> but if someone were to post proprietary, copyrighted code that you use in your own project unknowingly, could the copyright holder come after you with a cease-and-desist order? What would be your options at that point?</p>

<p>In general, using content provided by another who incorrectly posted it under a permissive license, such as a CC license, does not grant a valid license from the real copyright holder.</p>
<p>That is, if A writes some code (or a song, or creates an image, or whatever else), it is protected by copyright. If B then posts it to the web, with a statement that it is released under a particular license, without having obtained permission from A, then B's &quot;release&quot; is of no value, because B had no rights to grant. If C downloads and uses this content, relying on B's license, then A could take legal action against C. C would probably be considered (in the US) an &quot;innocent infringer&quot; which reduces the minimum statutory damage amount, but does not otherwise change C's legal position. A could, if it chose, bring suit and possibly obtain a judgement including some damages.</p>
<p>But to return to the practical case of code posted on one of the SE sites. Given the comparatively short code sections usually posted, and that they do not usually form a complete working program, and given further the stated educational purpose of SE, it is likely that in US law such a posting would constitute <em><strong>fair use</strong></em>, and in the law of other countries fall under one or another <em><strong>exception to copyright</strong></em>. That is a general conclusion, the details would matter.</p>
<p>I have not heard of a case similar to that suggested in the question. I find it unlikely that an SE poster would post copyright-protected code without permission, that is valuable enough to be worth an infringement suit, and substantial enough and having enough effect on th market for the original to be outside the protection of fair use. Such a situatiion is, of course, possible, even if unlikely.</p>
<p>Note that a cease-and-desist letter is not a court order, and is really only a threat of court action. its only <strong>legal</strong> effect is to put the recipient on notice, so that continued infringement is not without awareness of the copyright claim.  To have legal effect the claimant must actually bring an infringement suit, which is not without cost.</p>

<p>SE code is not Fair Use despite what the comment to another answer says. It's <a href="https://creativecommons.org/licenses/by-sa/2.0/" rel="nofollow noreferrer">Creative Commons &quot;Data Dump&quot;</a> which makes a pretty huge difference.</p>

copyright licensing