Cipher block chaining (CBC) is a block cipher mode of operation. Used correctly, CBC enables a block cipher, such as AES, to provide confidentiality over data larger than the block size.
To overcome the problem of patterns emerging in ciphertext output as a result of individually and separately encrypting each block of plaintext, CBC mixes the output of each encrypted block with the input to the next block. That is, after a block is encrypted, the encrypted block is XORed with the next input block before encipherment. This creates a “chain” between the encryption of the first block all the way to the last. In fact, if you change just one bit in the first block, the entire output will change.
The first block is also XORed with a random Initialization Vector (IV) before encryption. The IV prevents an attacker from deterministically mapping inputs to outputs. For example, if CBC encryption (using whatever block cipher) was used without an IV for file encryption, and if the key was used for each file, an attacker could tell if the first blocks of files were the same. After all, if the plaintext is the same, and the key is the same, the output is the same. The use of a random, unique IV ensures that the ciphertext is always unique, even for the same inputs.