Today I played with CubeMX and USB CDC device and I found very silly bug in generated code.
I chose USB FS Device only mode and I used CDC class. Nothing else set. I did not enable VBUS.
Generated code enabled VBUS sensing but VBUS sense pin was not enabled.
I spent 2 hours to figure that out.
Please correct this mistake, disable VBUS sense by default or if you enable VBUS sense, then also initialize VBUS pin to sense voltage.
Have a nice day.