The smoke from a woodstove includes unburned particles, tar and other hydrocarbons. As they move upward, condensation occurs on the inside walls of the chimney, especially near the top where it's cooler. The resulting residue is called creosote, and it is highly combustible.
When the creosote in a chimney catches fire, it can crack the liner, allowing hot gases and even direct flames to contact the framing in the attic or walls, resulting in a full-blown house fire. Excess heating of nearby framing materials can lower their ignition point, making them more likely to smolder and catch fire when exposed to heat at a later date. Sparks from the flaming chimney can ignite the roof.
The best way to avoid a chimney fire is to keep your chimney clean. To minimize creosote buildup, burn only well seasoned wood. Small, hot fires are safer than smoldering, damped-down fires with a large volume of firewood. Have your chimney cleaned regularly by a professional.