A teenage boy has been jailed for more than six years for the "unrelenting" sexual assault of an elderly woman, which left her in chronic pain and needing a frame to walk.

WARNING: This story contains details that some readers may find disturbing.

Key points: The woman disturbed the boy after he broke into her house

The woman disturbed the boy after he broke into her house He used pepper spray on her before and during the protracted attack

He used pepper spray on her before and during the protracted attack The woman was left with ongoing physical and psychological injuries

The Children's Court heard that the woman, who is aged in her 70s, was asleep in her home in the WA Goldfields town of Leonora and woke up just before midnight when she heard someone had entered her home.

She picked up a pepper spray canister and found the 17-year-old boy in the spare bedroom.

The boy was also armed with pepper spray that he had found in the woman's kitchen, and used it on her before she could escape to her own bedroom.

He held her down on her bed with his arm against her neck and demanded money. He then sexually assaulted her while continuing to spray her in the face and body with the pepper spray.

The woman eventually escaped and alerted police after the youth grabbed her handbag and let go of her hair.

The teenager was later driven to the Leonora police station by relatives before being charged.

The attack took place in Leonora in the northern WA Goldfields. ( ABC Goldfields-Esperance: Nathan Morris )

Attack just days after prison release

The Children's Court heard the 17-year-old had been released from juvenile detention on a conditional order at the end of May, 2018.

Almost immediately after being released he used methylamphetamine, sniffed glue and paint, and drank alcohol.

The home invasion and sexual assault on the woman occurred in early June, just days after his release.

The court heard the woman has lost her independence following the attack, and now needed to walk with the help of a frame due to the leg and back injuries she sustained.

She felt like she was "on edge all the time", had trouble doing anything physically and needed painkillers to deal with constant back pain.

Attacker 'appalled' by his actions

The teenager had pleaded guilty just before his trial was due to start.

His defence lawyer said his client had committed an "unrelenting" attack on a "highly vulnerable" victim, whose injuries and ongoing pain were aggravating features of the crime.

He said his client had accepted responsibility for the attack and was "appalled by what he's done".

But he said his client had a troubled childhood and started smoking cigarettes when he was seven, marijuana when he was 13 and started using methylamphetamines intravenously at the age of 15.

The teenager's "mild intellectual impairment" could be a result of foetal alcohol syndrome, head injuries or substance abuse, he told the court.

He said his client was also a father.

In sentencing the boy, Children's Court President Julie Wager considered the teenager's circumstances, including the intellectual impairment and domestic violence he had suffered when he was child.

But she said the impact of the "terrible" assault on the victim, who now had an "ongoing disability" which affected her emotionally, meant it was necessary to impose a long sentence.

The boy was handed a total jail term of six years and eight months for aggravated sexual penetration, burglary and several other offences unrelated to the events in Leonora in June, including assault and stealing.

The President also handed down a lifetime violence restraining order to ensure the youth could not go near the woman after his release.