It's exactly five seconds. It looks like it applies for every corrosive hit - and while effect does not stack, it can be prolonged. Example: Hit 1 gives you 5 seconds. You hit the target again 4 seconds later - and while 1st debuff wears off, the 2nd one is still active, thus giving you 9 seconds of debuff.
Debuff itself works for any hits - your weapons, your fighter's weapons and even NPC weapons.
Timer is usually around 6-8 seconds based on my experience
It definitely applies to all weapon damage that ship takes both from you and anyone else attacking. I don't believe it applies to ram/scenery damage but could be wrong.