Pipe rattling is often caused by low pressure at the mainline of your house. The house is wanting more water then the pressure you have will allow, often this is a sign of a failed Pressure Reducing Valve. However, if you notice it only on one fixture you may need a Hammer Arrestor that will dampen the change in pressure allowing that device to absorb the rattle so it doesn't shake your system. This is very dangerous as it can cause pipe joints to break apart or wear against other items in the wall leading to a leak over time. It is best to reach out to a professional plumber to check your pipes.