SpaceX is building a network of hundreds of spy satellites under a classified contract with a US intelligence agency, five sources familiar with the programme said, demonstrating deepening ties between billionaire entrepreneur Elon Musk's space company and national security agencies.