Specifically, between midnight and 5 AM.
I understand that the station might be closed, but Roma Termini closes in the night too, and we were allowed to stay overnight there after showing the tickets for next morning.
Usually for French network (Ventimiglia being at the end of French rail network), stations close not so long after the last train (and particularly they close at night).
As for Ventimiglia specifically, one can find 1.(in French) the opening times for French ticket office and 2.(in Italian) the opening times for Italian ticket office. According to them, the station (the building, not the platform) opens at least from 6.15am to 7.55pm everyday (including holidays). The platform is most likely always accessible.
EDIT: thanks to mouviciel for mentioning the Italian service in the station, the post is updated.