Stainless steel is known for its corrosion resistance in many environments in which carbon and low alloy tool steels would corrode. The corrosion resistance is a result of a very thin oxide layer on the steel's surface. This oxide layer is referred to as a passive layer since it renders the surface electrochemically passive in the presence of corrosive environments.
The passive layer forms because of the chromium added to stainless steel. Stainless steel must have at least 10.5% chromium in order for the passive layer to form. The more chromium that is added, the more stable the passive layer becomes, and the better the corrosion resistance. Other elements such as nickel, manganese, and molybdenum can be added to enhance stainless steel corrosion resistance.
Another requirement for the formation and maintenance of the passive layer is that the steel surface must be exposed to oxygen. Corrosion resistance is greatest when the steel is boldly exposed and the surface is maintained free of deposits. If passivity is destroyed under conditions that do not permit restoration of the passive film, then stainless steel will corrode much like a carbon or low-alloy steel. For example, covering a portion of the surface - for example, by biofouling, painting, or installing a gasket - produces an oxygen-depleted region under the covered region. The oxygen-depleted region is anodic relative to the well-aerated boldly exposed surface, possibly resulting in the corrosion of the covered region.
Under certain circumstances, the passive layer can break down at localized spots on a well exposed stainless steel surface. When this happens, the metal can corrode in the localized spots. This is called pitting corrosion. One common cause of pitting corrosion is exposure to aqueous environments that contain chloride. Examples are coastal atmospheres, road salt combined with rain water, and even tap water containing high levels of chloride.
During the fabrication of stainless steel components or structures it is possible to degrade the corrosion resistance. This occurs when austenitic stainless steels (e.g. 304) are exposed to temperatures between about 425 °C (797 °F) and 870 °C (1598 °F). If the exposure time is too long, then the areas near the metal's grain boundaries lose their corrosion resistance and can be preferentially attacked when exposed to a corrosive environment. This is called intergranular corrosion and the grains fall out and the metal loses strength. The increased susceptibility to corrosion by this change in microstructure is called sensitization.
For more information about stainless steel corrosion and corrosion in general take our Corrosion of Metals course or read Corrosion: Understanding the Basics by J.R. Davis or Corrosion and Corrosion Control by R.W. Revie and H.H. Uhlig.