X-linked immunodeficiency with hyper IgM (XHIM) is caused by mutations of the CD40ligand (CD40L) gene. Nine of 53 boys with XHIM developed carcinomas affecting the liver, pancreas, biliary tree and associated neuroectodermal endocrine cells. The tumors were fatal in 8 cases and in most instances were preceded by chronic cholangiopathy and/or cirrhosis. The incidence of liver disease in XHIM boys without malignancy increased from 10% at 5 years to 26% at 10 years and 75% at 20 years of age. Many XHIM patients had biliary tree or intestinal infections with cryptosporidia. CD40-CD40L interactions have recently been reported to mediate non-specific anti-viral immunity and we now report that a CD40+ hepatocellular carcinoma cell line becomes resistant to cryptosporidial infection when cell surface CD40 is crosslinked by a CD40L fusion protein. Since CD40 is expressed on regenerating or inflammed bile duct epithelium we propose that activation of CD40 on biliary epithelium may contribute to defense against infection by intracellular pathogens. We propose that the CD40L mutations which cause XHIM deprive the biliary epithelium of one line of defense against intracellular pathogens and that malignant transformation in the biliary tree follows chronic infection or inflammation. The resulting tumors may then progress without check by an effective immune response. XHIM patients developing abnormal liver function tests should be considered at increased risk for cholangiopathy or malignancy.