This occurs because of the ability to form a protective coating on the surface of the metal. The forming of this film is instant in an oxidizing atmosphere such as air, water, or any other atmosphere that has oxygen as an ingredient. Not like aluminum or silver, this passive is invisible on stainless steel. This is due to the combination of oxygen and the chrome in the stainless steel to form chrome oxide. This protective coating is common to most anti-corrosive materials.
Most salts can easily break through the passive film that allows corrosive attacks to occur.
The speed of attack is affected by the liquid concentration, heat level, liquid rate or speed, and stress on the metal parts subject to attack. Should you put two different metals or alloys in a similar electrolyte, and connect them with a voltmeter, it will display an electric current running between the two metals or alloys. When the current flows, materials will be removed from one of the metals or alloys and dissolved into the form of an electrolyte. The other metal will be totally protected. This occurs when the corrosive environment penetrates the passive film in only a few areas instead of the overall surface.