A Tory MP tipped as a future Prime Minister has admitted breaking the law by hacking into a Labour opponent’s website.

Kemi Badenoch, a newly appointed vice-chairman of the party, confessed that she launched the cyber-attack on the Labour MP’s site in order to write pro-Tory propaganda under their name.

Hacking into websites is a criminal offence – and can be punished with a prison sentence of up to two years.

Her confession, in an interview obtained by The Mail on Sunday, is particularly embarrassing for Downing Street because Ms Badenoch is a rising star who has been tasked by Theresa May with increasing the number of women and ethnic-minority MPs in the party.

Ms Badenoch, MP for Saffron Walden, Essex, made the admission when she was asked what was the ‘naughtiest’ thing she had ever done.

She replied that before she became an MP she had ‘hacked into a Labour MP’s website’, adding: ‘I changed all the stuff in there to say nice things about the Tories.’

Last night, Ms Badenoch apologised for what she described as a ‘foolish prank’.

She declined to identify the Labour MP.

Tory chairman Brandon Lewis is standing by Ms Badenoch.

Ms Badenoch, MP for Saffron Walden, Essex, made the admission when she was asked what was the ‘naughtiest’ thing she had ever done

A Tory HQ source described it as a case of ‘youthful exuberance’ which occurred before she was a candidate and involved ‘guessing a password’ rather than ‘real hacking’.

She was 28 when she committed the act.

Ms Badenoch, who was elected to Parliament for the first time at last year’s General Election, is being fast-tracked to the top by a Tory Party desperate to shed its ‘pale, stale and male’ image.

Her closeness to No 10 was illustrated on Friday evening when she was the guest speaker at the Prime Minister’s annual constituency dinner.

Footage of the interview was obtained by this newspaper from Core Politics, an online politics channel, which filmed it as part of a series of profiles of new MPs.

Ms Badenoch, 38, told the channel that she had mounted the cyber-attack ten years ago.

Under the 1990 Computer Misuse Act, a person is guilty of an offence if they ‘cause a computer to perform any function with intent to secure access to any program or data held in any computer, or to enable any such access to be secured’ and ‘knows at the time that that is the case’.

Judges can hand down a fine or a prison sentence of two years for the offence.

Ms Badenoch was made a vice-chair of the party earlier this year, with responsibility for spearheading efforts to increase the diversity of Tory candidates for Commons seats.

Her confession, in an interview obtained by The Mail on Sunday, is particularly embarrassing for Downing Street because Ms Badenoch is a rising star who has been tasked by Theresa May with increasing the number of women and ethnic-minority MPs in the party

Mrs May has asked her to find a ‘new generation’ of talented MPs from non-traditional backgrounds, with particular focus on women and ethnic-minority candidates.

Born in London, but raised in Nigeria, she moved back to the UK when she was 16 and studied for engineering and law degrees.

She wowed the selectors in her constituency by citing Margaret Thatcher as her political hero, going on to win the seat with a majority of nearly 25,000 in June.

She backed Brexit in her maiden Commons speech, describing it as ‘the greatest-ever vote of confidence in the project of the United Kingdom’, and hailed the ‘British dream’ that allowed her to go from immigrant to MP.

Born in London, but raised in Nigeria, she moved back to the UK when she was 16 and studied for engineering and law degrees.

Ms Badenoch was also given the plum role of introducing Mrs May for her party conference speech last year, leading her to be tipped as a future leader.

The MP, who has two children with husband Hamish, a South London Tory councillor who works for Deutsche Bank, has not been afraid to weigh in to controversial issues, backing the use of ‘stop and search’ to solve the problem of knife crime.

Pointing out that as a child in Nigeria she carried a machete to school – to cut the grass, not to ‘go carving each other up’ in fights – she said: ‘If you let people think they can get away with a certain type of behaviour, people will take advantage of it.’

She also waded into the sexual harassment storm at Westminster last year by criticising the ‘puritanical’ sexual morality of young people who she said were in the grip of ‘fits and seizures’ about public conduct.

Ms Badenoch was also given the plum role of introducing Mrs May for her party conference speech last year, leading her to be tipped as a future leader.

After her speech to Mrs May’s Maidenhead dinner on Friday, Ms Badenoch posed with her husband for the picture with the Prime Minister.

Ms Badenoch posted it on Instagram with the comment: ‘Could not resist getting selfie with @theresamay!’ She had been billed by the Maidenhead party in advance as ‘impressive’ and ‘one to watch’.

Ms Badenoch said: ‘This was a foolish prank over a decade ago, for which I apologise.’