Gastrointestinal (GI) cancers, especially gastric cancer and colorectal cancer (CRC), represent a major global health burden. A large population of microorganisms residing in the GI tract regulate physiological processes, such as the immune response, metabolic balance, and homeostasis. Accumulating evidence has revealed the alteration of microbial communities in GI tumorigenesis. Experimental studies in cell lines and animal models showed the functional roles and molecular mechanisms of several bacteria in GI cancers, including Helicobacter pylori in gastric cancer as well as Fusobacterium nucleatum, Escherichia coli, Peptostreptococcus anaerobius, and Bacteroides fragilis in CRC. The transcriptional factor NF-κB plays a crucial role in the host response to microbial infection through orchestrating innate and adaptive immune functions. Moreover, NF-κB activity is linked to GI cancer initiation and development through its induction of chronic inflammation, cellular transformation and proliferation. Here, we provide an overview and discussion of modulation of the NF-κB signaling pathway by microbiota, especially infectious bacteria, in GI tumorigenesis, with a major focus on gastric cancer and CRC.