Intergranular corrosion (IGC), also known as intergranular attack (IGA), is a form of corrosion where the boundaries of crystallites of the material are more susceptible to corrosion than their insides. (Cf. transgranular corrosion.)
This situation can happen in otherwise corrosion-resistant alloys, when the grain boundaries are depleted, known as grain boundary depletion, of the corrosion-inhibiting elements such as chromium by some mechanism. In nickel alloys and austenitic stainless steels, where chromium is added for corrosion resistance, the mechanism involved is precipitation of chromium carbide at the grain boundaries, resulting in the formation of chromium-depleted zones adjacent to the grain boundaries (this process is called sensitization). Around 12% chromium is minimally required to ensure passivation, a mechanism by which an ultra thin invisible film, known as passive film, forms on the surface of stainless steels. This passive film protects the metal from corrosive environments. The self-healing property of the passive film make the steel stainless. Selective leaching often involves grain boundary depletion mechanisms.
These zones also act as local galvanic couples, causing local galvanic corrosion. This condition happens when the material is heated to temperature around 700 °C for too long time, and often happens during welding or an improper heat treatment. When zones of such material form due to welding, the resulting corrosion is termed weld decay. Stainless steels can be stabilized against this behavior by addition of titanium, niobium, or tantalum, which form titanium carbide, niobium carbide and tantalum carbide preferentially to chromium carbide, by lowering the content of carbon in the steel and in case of welding also in the filler metal under 0.02%, or by heating the entire part above 1000 °C and quenching it in water, leading to dissolution of the chromium carbide in the grains and then preventing its precipitation. Another possibility is to keep the welded parts thin enough so that, upon cooling, the metal dissipates heat too quickly for chromium carbide to precipitate. The ASTM A923, ASTM A262, and other similar tests are often used to determine when stainless steels are susceptible to intergranular corrosion. The tests require etching with chemicals that reveal the presence of intermetallic particles, sometimes combined with Charpy V-Notch and other mechanical testing.
Another related kind of intergranular corrosion is termed knifeline attack (KLA). Knifeline attack impacts steels stabilized by niobium, such as 347 stainless steel. Titanium, niobium, and their carbides dissolve in steel at very high temperatures. At some cooling regimes (depending on the rate of cooling), niobium carbide does not precipitate and the steel then behaves like unstabilized steel, forming chromium carbide instead. This affects only a thin zone several millimeters wide in the very vicinity of the weld, making it difficult to spot and increasing the corrosion speed. Structures made of such steels have to be heated in a whole to about 1065 °C (1950 °F), when the chromium carbide dissolves and niobium carbide forms. The cooling rate after this treatment is not important, as the carbon that would otherwise pose risk of formation of chromium carbide is already sequestered as niobium carbide. 
Aluminium-based alloys may be sensitive to intergranular corrosion if there are layers of materials acting as anodes between the aluminium-rich crystals. High strength aluminium alloys, especially when extruded or otherwise subjected to high degree of working, can undergo exfoliation corrosion (metallurgy), where the corrosion products build up between the flat, elongated grains and separate them, resulting in lifting or leafing effect and often propagating from edges of the material through its entire structure.  Intergranular corrosion is a concern especially for alloys with high content of copper.
Other kinds of alloys can undergo exfoliation as well; the sensitivity of cupronickel increases together with its nickel content. A broader term for this class of corrosion is lamellar corrosion. Alloys of iron are susceptible to lamellar corrosion, as the volume of iron oxides is about seven times higher than the volume of original metal, leading to formation of internal tensile stresses tearing the material apart. Similar effect leads to formation of lamellae in stainless steels, due to the difference of thermal expansion of the oxides and the metal. 
Copper-based alloys become sensitive when depletion of copper content in the grain boundaries occurs.
Intergranular corrosion induced by environmental stresses is termed stress corrosion cracking. Inter granular corrosion can be detected by ultrasonic and eddy current methods.
Sensitization refers to the precipitation of carbides at grain boundaries in a stainless steel or alloy, causing the steel or alloy to be susceptible to intergranular corrosion or intergranular stress corrosion cracking.
Certain alloys when exposed to a temperature characterized as a sensitizing temperature become particularly susceptible to intergranular corrosion. In a corrosive atmosphere, the grain interfaces of these sensitized alloys become very reactive and intergranular corrosion results. This is characterized by a localized attack at and adjacent to grain boundaries with relatively little corrosion of the grains themselves. The alloy disintegrates (grains fall out) and/or loses its strength.
The photos show the typical microstructure of a normalized (unsensitized) type 304 stainless steel and a heavily sensitized steel. The samples have been polished and etched before taking the photos, and the sensitized areas show as wide, dark lines where the etching fluid has caused corrosion. The dark lines consist of carbides and corrosion products.
Intergranular corrosion is generally considered to be caused by the segregation of impurities at the grain boundaries or by enrichment or depletion of one of the alloying elements in the grain boundary areas. Thus in certain aluminium alloys, small amounts of iron have been shown to segregate in the grain boundaries and cause intergranular corrosion. Also, it has been shown that the zinc content of a brass is higher at the grain boundaries and subject to such corrosion. High-strength aluminium alloys such as the Duralumin-type alloys (Al-Cu) which depend upon precipitated phases for strengthening are susceptible to intergranular corrosion following sensitization at temperatures of about 120 °C. Nickel-rich alloys such as Inconel 600 and Incoloy 800 show similar susceptibility. Die-cast zinc alloys containing aluminum exhibit intergranular corrosion by steam in a marine atmosphere. Cr-Mn and Cr-Mn-Ni steels are also susceptible to intergranular corrosion following sensitization in the temperature range of 420°-850 °C. In the case of the austenitic stainless steels, when these steels are sensitized by being heated in the temperature range of about 520° to 800 °C, depletion of chromium in the grain boundary region occurs, resulting in susceptibility to intergranular corrosion. Such sensitization of austenitic stainless steels can readily occur because of temperature service requirements, as in steam generators, or as a result of subsequent welding of the formed structure.
Several methods have been used to control or minimize the intergranular corrosion of susceptible alloys, particularly of the austenitic stainless steels. For example, a high-temperature solution heat treatment, commonly termed solution-annealing, quench-annealing or solution-quenching, has been used. The alloy is heated to a temperature of about 1,060° to 1,120 °C and then water quenched. This method is generally unsuitable for treating large assemblies, and also ineffective where welding is subsequently used for making repairs or for attaching other structures.
Another control technique for preventing intergranular corrosion involves incorporating strong carbide formers or stabilizing elements such as niobium or titanium in the stainless steels. Such elements have a much greater affinity for carbon than does chromium; carbide formation with these elements reduces the carbon available in the alloy for formation of chromium carbides. Such a stabilized titanium-bearing austenitic chromium-nickel-copper stainless steel is shown in U.S. Pat. No. 3,562,781. Or the stainless steel may initially be reduced in carbon content below 0.03 percent so that insufficient carbon is provided for carbide formation. These techniques are expensive and only partially effective since sensitization may occur with time. The low-carbon steels also frequently exhibit lower strengths at high temperatures.