Facebook was warned that its users were at risk two years before the data of 50 million people was accessed by a controversial political firm, the Telegraph can disclose.

In 2011, the social media giant’s European regulator cautioned that it was failing to ensure that data was protected when passed to third-party software developers.

Facebook responded with minor changes to the way users were notified about how apps were gathering data but did not fully block the practice for another four years.

The discovery of the warning raises new questions about why Facebook did not act sooner to protect users’ private information.

In 2013, two years after the warning, Aleksandr Kogan, a Cambridge professor, used a personality quiz on Facebook to obtain data from 50 million users without their knowledge.

Prof Kogan then allegedly passed the data to Cambridge Analytica the following year, in violation of Facebook’s rules and without the company knowing.

The Irish Data Protection Commissioner (DPC) initially warned Facebook of this oversight in December 2011, claiming it could not “assure users of the security of their data”.