Any toys used by babies carry a risk. A rattle isn't particularly dangerous, but there are risks you should be aware of when buying one and when your child is playing with one.
Obviously, anything with small parts carries a choking hazard. But you also need to be aware of how hard the rattle is - some are quite hard, and could hurt if your child shakes it a bit too hard.