The definition of "insider trading" is that it is taking advantage of information that is not available to "the public". Like many laws, this can be tricky to evaluate in real life.
At the extremes: If you see a news story on a major TV network saying that XYZ Company just got a big new government contract, and you then buy stock in XYZ, that's pretty clear public information. On the other hand, if your brother-in-law is president of XYZ and he tells you that he's just gotten a big new government contract, and an hour before the public announcement you rush out and buy stock, that pretty clearly IS insider trading.
But there are many tough questions. Suppose you are walking down the street and see someone that you recognize as the president of company X walk out of the office of company Y with a broad smile on his face. You suspect that X has just made some profitable deal with Y, and so you buy stock in X. That's completely legal. But if you stopped the president and talked to him, and he told you that he had just made a profitable deal with Y, and you buy stock in X, that would be illegal insider trading.
Or if a tech company announces that it is investing in some new invention, and you are a brilliant physicist and know that it is scientifically impossible for this invention to ever work so you quickly sell your stock in the company, that's legal. But if you work for the company, and you see that development on the invention is running into problems, and so you dump your stock, probably illegal.
In your example, insider trading laws generally involve a scienter requirement, that is, you must know that the information is non-public. If you overhear two people in a bar discussing a rumor they heard, and you buy or sell stock based on that, that's probably legal because you have no way to know if their information is public or not. So -- usual disclaimer, I am not a lawyer -- the farther from the source you are, the more likely you don't know that information is non-public, and the tougher it would be to prosecute you. And of course if somebody told his brother who told his wife who told all her girlfriends one of whom posted it on her Facebook page, etc, at some point so many people have heard this that you could argue it is now "public".