A Melbourne woman has fended off a sex attacker by hitting the man with a bag of shopping.

The 23-year-old Elwood woman was waiting at the front gate of a local apartment block when approached by a man from behind.

The man lifted her skirt and indecently assaulted her, police say.

The woman hit the man with a bag of shopping before he fled the scene in a blue sedan.

Police are appealing for a witness to the attack, which occurred last Tuesday at 10.45pm (AEDT).

The witness asked the woman if she was ok and told her he saw the assault and the offender drive away.