Where the shaft is housed at either end, is a small rubber cup,
if this is perished and fails, it allows the impellor to move in the chamber,
Thereby creating a rattle.
I'm not sure if the shaft is ceramic, which break very easily and are not the cheapest to replace. But you should, if necessary find a replacement in your LFS.
They use to be unbreakable stainless steel, makes ya wonder why they changed, or was it just another way to grind more money from the hobbiest.
Sand or similar between the housing and the impellor drive can also create noises.
Alan 104