Simple answer- yes they can be, but not if you manage your composting system properly.
There are two reasons why rats are attracted to compost. The first is food. Vegetative food scraps that are easily accessible (i.e. have not been buried within the composting material) or high protein scraps such as meat, fish, bones or cheese will attract rodents looking for something to eat. The second is that compost piles can be a warm and dry home for nesting, especially in winter months. If you find that rats are nesting in your bin, you can simply turn the pile to disrupt nesting behaviour.
To discourage rats from getting in your compost system, bury all vegetative food scraps within composting garden materials, avoid composting foods of animal origin and place the bin on a surface they can’t burrow under like hard plastic or thick wire mesh.