Ok let me start with Hadith
Sahi Muslim
It has been narrated on the authority of Jabir that the Messenger of Allah (may peace be upon him) said: Who will
kill Ka'b b. Ashraf? He has maligned Allah, the Exalted, and His Messenger. Muhammad b. Maslama said: Messenger of Allah, do you wish that I should
kill him? He said: Yes. He said: Permit me to talk (to him in the way I deem fit). He said: Talk (as you like)....... (Book
#019, Hadith
#4436)
So in that Hadith you may find what you ask for. one may say that It was not the only fault of Kaab it was also something else.
then READ THIS.
Sahi Abud Dawood
(1) Narrated Abdullah Ibn Abbas: A blind man had a slave-mother who used to
abuse the Prophet (peace_be_upon_him) and disparage him. He forbade her but she did not stop. He rebuked her but she did not give up her habit. One night she began to slander the Prophet (peace_be_upon_him) and
abuse him. So he took a dagger, placed it on her belly, pressed it, and
killed her. A child who came between her legs was smeared with the blood that was there. When the morning came, the Prophet (peace_be_upon_him) was informed about it. He assembled the people and said: I adjure by Allah the man who has done this action and I adjure him by my right to him that he should stand up. Jumping over the necks of the people and trembling the man stood up. He sat before the Prophet (peace_be_upon_him) and said: Apostle of Allah! I am her master; she used to
abuse you and disparage you. I forbade her, but she did not stop, and I rebuked her, but she did not abandon her habit. I have two sons like pearls from her, and she was my companion. Last night she began to
abuse and disparage you. So I took a dagger, put it on her belly and pressed it till I
killed her. Thereupon the Prophet (peace_be_upon_him) said:
Oh be witness, no retaliation is payable for her blood. (Book
#38, Hadith
#4348)
So did you read. He did not say that You did a wrong thing . If that is not the punishment
I hope now it is clear for you(and others)
And if someone think that why this "harsh" punishment well think yourself if cant find then i have an answer