General Relativity says that it is energy that gravitates rather than mass. So while massless particles may have no mass, they have energy.
In general relativity, it's usually not best to think of gravity as a force. Gravity is the result of energy changing the geometry of space-time.
When viewing gravity as geometry, it is much easier to understand how massless particles are influenced under gravity.