No this isn’t something on Star Trek. This is a real treaty that was signed on January 29, 1967.
The Outer Space Treaty represents the basic legal framework of international space law. Among its principles, it bars States Parties to the Treaty from placing nuclear weapons or any other weapons of mass destruction in orbit of Earth, installing them on the Moon or any other celestial body, or to otherwise station them in outer space. It exclusively limits the use of the Moon and other celestial bodies to peaceful purposes and expressly prohibits their use for testing weapons of any kind, conducting military maneuvers, or establishing military bases, installations, and fortifications (Art.IV). However, the Treaty does not prohibit the placement of conventional weapons in orbit.
PS. Check out this guy trying to sell the moon.