It's possible to get high from secondhand smoke.
It has to happen under a specific set of circumstances (little to no ventilation, for example.)
A common stoner trope (and a well-worn excuse for those teenagers trying to hide their stoner status from their parents) is that of the secondhand high from marijuana smoke. It is not something taken lightly by scientists, either, especially in light of a wave of marijuana legalization across the United States; studies have investigated the effects of secondhand cannabis smoke on nonsmokers for decades.
While this work comes with notable limitations, the consensus is that it is, in fact, possible to get high from secondhand cannabis smoke, at least under certain extremely unventilated and confined conditions.
A relevant example of such conditions — and actually a model for researchers studying the effects of second hand cannabis smoke — would be "hotboxing," which in cannabis culture is the process of smoking marijuana with a group of people in an unventilated car or room, potentially increasing the degree to which participants are exposed to cannabis smoke.
Early research sought to recreate these conditions primarily to see if people not directly smoking would absorb the active components of cannabis to the point where they could be detected in urine or blood. Though small in sample size, numerous studies conducted in the 1980s have shown that under these extreme conditions passive participants could absorb enough THC and other cannabinoids so that they could be detected in blood or urine (and, as a result, potentially affect drug screening tests for a short period of time following exposure.)
A 1986 study also reported that the subjective effects of being exposed indirectly to 16 "marijuana cigarettes" were similar to those produced by directly smoking a single joint, though it bears mentioning that this 1986 marijuana was up to 10 times weaker than modern high-potency medical or recreational marijuana.
The question of a second-hand high was most recently investigated in a 2015 study performed at Johns Hopkins University. Researchers confined groups of six smokers (who were each provided with ten joints) and six non-smokers in a chamber under both ventilated and unventilated conditions, letting the smokers toke at their leisure for an hour in the company of the non-smokers. Using a battery of tests following these sessions, the scientists concluded that getting high indirectly (and mildly) is possible, though dependent on how ventilated a space is:
Room ventilation has a pronounced effect on exposure to secondhand cannabis smoke. Under extreme, unventilated conditions, secondhand cannabis smoke exposure can produce detectable levels of THC in blood and urine, minor physiological and subjective drug effects, and minor impairment on a task requiring psychomotor ability and working memory.
The authors of the study caution that it took specific and "extreme" conditions to produce effects from the second hand high, and that their study design may not accurately reflect the real world:
The size of room, amount of cannabis consumed, duration of exposure, and frequency of such exposure are all variables that likely would influence outcomes in the real world.
Their results do suggest, however, that secondhand highs are possible but that you would probably have to work pretty hard to get there. That means, if you're in a position where you're trying to brazen out a story about how you accidentally got a contact high after a long night, you might have to think up another excuse.