I've heard that sugar, and especially brown sugar, loses its flavor over time. Is this true?
White sugar is generally sucrose and has been heavily refined, so it won't undergo any chemical changes over time.  In fact, sugar is actually used as a preservative.

Brown sugar is a bit different.  It gets hard simply because it loses moisture - i.e. the water evaporates - and that won't cause the taste to change.  However, some people have reported brown sugar actually fermenting on its own (also here).  This fermentation is more likely to happen than in white sugar due to the presence of molasses.

It takes a long time for fermentation to occur, but it can definitely occur, and that will most certainly change the flavour.  I'm not sure if I'd call it "losing" the flavour; some might argue that the presence of alcohol is a good thing, although fermented sugar obviously will not be as sweet.

I would not worry about the flavour of brown sugar that has merely hardened; if it smells like alcohol, though, you might want to be more careful.